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ā€¦
Request Tracker Wiki
ā€¦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

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

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