Escaping @ in email addresses in RT_SiteConfig.pm -- todo or not to do?

You ran into a Perlism :slight_smile: Single quotes don’t interpolate the special
character ‘@’ - double quotes do. Which is why you have to escape it
with double quotes.

You ran into a Perlism :slight_smile: Single quotes don’t interpolate the special
character ‘@’ - double quotes do. Which is why you have to escape it
with double quotes.

-----Original Message-----
From: rt-users-bounces@lists.bestpractical.com
[mailto:rt-users-bounces@lists.bestpractical.com] On Behalf
Of Hasan Muhammad
Sent: Monday, January 30, 2006 10:48 AM
To: rt-users@lists.bestpractical.com
Subject: [rt-users] escaping @ in email addresses in
RT_SiteConfig.pm – todo or not to do?

–when this address is set as…
Set($OwnerEmail, "admin@test-network.us");
…it results in this error…
Possible unintended interpolation of @test in string at
/etc/rt/RT_SiteConfig.pm line 34.
…when the database is created (or dropped)

–when the @ is escaped as…
Set($OwnerEmail, "admin@test-network.us");
…no error (message) occurs

–however, no error message occurs with the other email address…
Set($CorrespondAddress, ‘correspond@rt.test-network.us’);
Set($CommentAddress, ‘comment@rt.test-network.us’);
…whether they are escaped or not

–what is the correct method for specifying email addresses,
with or without the escape?

Hasan

CentOS 4.2server
rt-3.4.5-1

==============================================================

–Setup on Centos 4.2 Server per…
http://wiki.bestpractical.com/index.cgi?RPMInstall
…using (see INSTALLATION PROCEDURE below)…
yum install perl-DBD-Pg rt rt-mail-dispatcher mysql-server lynx

–then after making local configuration changes (see FILE
CHANGES and INSTALLATION PROCEUDURE
below)…
/usr/sbin/rt-setup-database --action init --dba root
–dba-password contribs.org
…results in error message…
Possible unintended interpolation of @test in string at
/etc/rt/RT_SiteConfig.pm line 34.

–FILE CHANGES: MADE AFTER BASE CENTOS 4.2 SERVER INSTALL…

— /etc/rt/RT_SiteConfig.pm.orig 2006-01-12
23:04:30.000000000 -0500
+++ /etc/rt/RT_SiteConfig.pm 2006-01-19 23:39:33.000000000 -0500

-Set( $rtname, ‘example.com’);
+Set($rtname, “test_network_us”);

+Set($Organization , “rt.test-network.us”);
+Set($Timezone, ‘US/Eastern’);
+Set($WebBaseURL, “http://rt.test-network.us”);
+Set($WebPath, “/”);
+Set($WebURL , $WebBaseURL . $WebPath . “/”);
+
+Set($CorrespondAddress, ‘correspond@rt.test-network.us’);
+Set($CommentAddress, ‘comment@rt.test-network.us’);
+Set($SendmailPath, “/usr/sbin/sendmail”);
+Set($SendmailArguments , “-oi -t”);
+
+Set($LogToSyslog, ‘’);
+Set($LogToFile, ‘debug’);
+Set($LogDir, ‘/var/log/rt’);
+Set($LogToFileNamed , “rt.log”);
+
+Set($OwnerEmail, "admin@test-network.us");
+Set($MyTicketsLength, 20);
+
+Set($DatabasePassword , ‘contribs.org’);
+
+Set($AmbiguousDayInPast , 0);
+

1;

Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

You ran into a Perlism :slight_smile: Single quotes don’t interpolate the special
character ‘@’ - double quotes do. Which is why you have to escape it
with double quotes.

…but is not this line that caused the error message…

Set($OwnerEmail, "admin@test-network.us");
…already escaped with double quotes?

Hasan

Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

Hello!On Mon, 2006-01-30 at 10:57, Hasan Muhammad wrote:

— “Schultz, Eric” ESchultz@corp.untd.com wrote:

You ran into a Perlism :slight_smile: Single quotes don’t interpolate the special
character ‘@’ - double quotes do. Which is why you have to escape it
with double quotes.

…but is not this line that caused the error message…

Set($OwnerEmail, "admin@test-network.us");
…already escaped with double quotes?

Those double quotes cause Perl to examine the string between them,
looking for variable names to expand. Since Perl considers “@foo” the
same as join(" ", @foo), it wants to interpolate @test as a Perl array
… which it isn’t, so you get the complaint you mentioned. Putting a
backslash ahead of the @ explains to Perl that it’s really just an @.

If you put it all in single quotes, Perl considers that a string literal
which it shouldn’t examine, so no complaints.

The end result: Don’t put email addresses in double quotes if you can
avoid it; if you can’t avoid it, you need to use @.

Cheers!

–j
Jim Meyer, Geek at Large purp@acm.org

Hi all. I’m writing a custom scrip that performs some "business time"
calculations on tickets, with the idea of determining SLA compliance.

The business details are boring, but I’ve got a weird technical problem.

I’m using Jesse Vincent’s most excellent Business::Hours module to perform
the calculation that I want. It works fine. When it’s done, I’ve got a time
in UNIX epoch seconds.

Here is where things go weird. I want to convert the UNIX epoch seconds into
a string, along these lines:

MM/DD/YYYY hh:mm:ss AM|PM TZ

No problem, I’ll just use the POSIX package and the good old strftime
function. Let’s say the UNIX epoch seconds are stored in $MySeconds, then
I’ve got code like this:

my $TimeString = strftime(’%m/%d/%Y %r %Z’,localtime($MySeconds));

The problem is, about 5% of the time, this scrip fails, and the RT error log
shows:

[Tue Jan 31 00:10:58 2006] [error]: Scrip 339 Commit failed: Usage:
POSIX::strftime(fmt, sec, min, hour, mday, mon, year, wday = -1, yday = -1,
isdst = -1) at (eval 33876) line 50.

So, I figure, strftime just got bad data. So I use $RT::Logger->error to
send $MySeconds and localtime($MySeconds) to the error log.

My epoch seconds are good, but the output of localtime($MySeconds) seems to
vary, even when supplied with the same input data. Sometimes posting
localtime($MySeconds) to the error log results in a string posted to the
error log, like

Thu Jan 19 08:00:00 2006

Other times, it results in an ARRAY:

Time::tm=ARRAY(0xde1a0f0)

In the first case, I always get a good string out of strftime. In the second
case, I always get the POSIX::strftime error and the scrip execution fails.

Ideas? I’m thinking that PERL is calling different versions of localtime().
Maybe. How would I find out?

I’m also mystified why this code works literally 95 times out of 100, but
fails every once in awhile.

Rick R.

For computer help, call xHELP (x4357 or 713-348-4357)
On the web: http://helpdesk.rice.edu/
Rick Russell
Helpdesk Supervisor, Client Services
IT/Academic & Research Computing
Rice University
Voice: 713.348.5267 Fax: 713.348.6099
OpenPGP/GnuPG Public Key at ldap://certificate.rice.edu
761D 1C20 6428 580F BD98 F5E5 5C8C 56CA C7CB B669

rickr.vcf (560 Bytes)

signature.asc (252 Bytes)

Brandon S. Allbery KF8NH wrote:

Something is using Time::localtime, but not consistently. You can work
around it by calling CORE::localtime which always gets the Perl built-in.

Of course, about 5 minutes after I sent e-mail about it, I had an
inspiration and decided to change all instances of “localtime” and
"strftime" in my code to

POSIX::localtime

and

POSIX::strftime

respectively. I suspect (bearing further testing) that this will permanently
fix it.

For computer help, call xHELP (x4357 or 713-348-4357)
On the web: http://helpdesk.rice.edu/
Rick Russell
Helpdesk Supervisor, Client Services
IT/Academic & Research Computing
Rice University
Voice: 713.348.5267 Fax: 713.348.6099
OpenPGP/GnuPG Public Key at ldap://certificate.rice.edu
761D 1C20 6428 580F BD98 F5E5 5C8C 56CA C7CB B669

rickr.vcf (560 Bytes)

signature.asc (252 Bytes)

My epoch seconds are good, but the output of localtime($MySeconds)
seems to
vary, even when supplied with the same input data. Sometimes posting
localtime($MySeconds) to the error log results in a string posted
to the
error log, like

Thu Jan 19 08:00:00 2006

Other times, it results in an ARRAY:

Time::tm=ARRAY(0xde1a0f0)

Something is using Time::localtime, but not consistently. You can
work around it by calling CORE::localtime which always gets the Perl
built-in.

brandon s. allbery [linux,solaris,freebsd,perl]
allbery@kf8nh.com
system administrator [openafs,heimdal,too many hats]
allbery@ece.cmu.edu
electrical and computer engineering, carnegie mellon university
KF8NH