[Rt-commit] rt branch, 4.0/case-sensitive-rtaddressregexp, created. rt-4.0.0rc5-15-gf38fe73
Alex Vandiver
alexmv at bestpractical.com
Mon Feb 28 18:08:36 EST 2011
The branch, 4.0/case-sensitive-rtaddressregexp has been created
at f38fe734df50e3be59121312db0e17c03ce1f31b (commit)
- Log -----------------------------------------------------------------
commit a82140218467faecf6c96666fa2110ead5745d35
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Mon Feb 28 18:02:12 2011 -0500
Ensure that the generated RTAddressRegexp, when interpolated, is still /i
00e47c20 changed the generated RTAddressRegexp to be a regex, instead
of a string. It is matched using `... =~ /$RT::RTAddressRegexp/i` --
if the configuration variable is a Regexp, not a string, it maintains
its own local regex flags, making the /i ineffective. Thus, default
the generated regex to being /i to preserve the old behavior.
diff --git a/etc/upgrade/generate-rtaddressregexp.in b/etc/upgrade/generate-rtaddressregexp.in
index 693faf1..54b87f9 100644
--- a/etc/upgrade/generate-rtaddressregexp.in
+++ b/etc/upgrade/generate-rtaddressregexp.in
@@ -98,7 +98,7 @@ You can add the following to RT_SiteConfig.pm, but may want to collapse it into
Keep in mind that this only contains the email addresses that RT knows about, you should also examine
your mail system for aliases that reach RT but which RT doesn't know about.
ENDDESCRIPTION
-print "Set(\$RTAddressRegexp,qr{^(?:${re})\$});\n";
+print "Set(\$RTAddressRegexp,qr{^(?:${re})\$}i);\n";
sub merge {
my $merged = shift;
commit f38fe734df50e3be59121312db0e17c03ce1f31b
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Mon Feb 28 18:04:39 2011 -0500
Warn if RTAddressRegexp is a regex, and is case-sensitive
Case-sensitive email address matching is nearly always incorrect, as
at very least the domain part is specified to base case-insensitive.
At the same time, update our own use of it in the test config.
diff --git a/lib/RT/Config.pm b/lib/RT/Config.pm
index da57320..3126035 100644
--- a/lib/RT/Config.pm
+++ b/lib/RT/Config.pm
@@ -424,15 +424,24 @@ our %META = (
PostLoadCheck => sub {
my $self = shift;
my $value = $self->Get('RTAddressRegexp');
- return if $value;
-
- $RT::Logger->debug(
- 'The RTAddressRegexp option is not set in the config.'
- .' Not setting this option results in additional SQL queries to'
- .' check whether each address belongs to RT or not.'
- .' It is especially important to set this option if RT recieves'
- .' emails on addresses that are not in the database or config.'
- );
+ if (not $value) {
+ $RT::Logger->debug(
+ 'The RTAddressRegexp option is not set in the config.'
+ .' Not setting this option results in additional SQL queries to'
+ .' check whether each address belongs to RT or not.'
+ .' It is especially important to set this option if RT recieves'
+ .' emails on addresses that are not in the database or config.'
+ );
+ } elsif (ref $value and ref $value eq "Regexp") {
+ # Ensure that the regex is case-insensitive; while the
+ # local part of email addresses is _technically_
+ # case-sensitive, most MTAs don't treat it as such.
+ $RT::Logger->warning(
+ 'RTAddressRegexp is set to a case-sensitive regular expression.'
+ .' This may lead to mail loops with MTAs which treat the'
+ .' local part as case-insensitive -- which is most of them.'
+ ) if "$value" =~ /^\(\?[a-z]*-([a-z]*):/ and "$1" =~ /i/;
+ }
},
},
# User overridable mail options
diff --git a/lib/RT/Test.pm b/lib/RT/Test.pm
index 9375d58..ac651cc 100644
--- a/lib/RT/Test.pm
+++ b/lib/RT/Test.pm
@@ -231,7 +231,7 @@ Set( \$WebDomain, "localhost");
Set( \$WebPort, $port);
Set( \$WebPath, "");
Set( \@LexiconLanguages, qw(en zh_TW fr));
-Set( \$RTAddressRegexp , qr/^bad_re_that_doesnt_match\$/);
+Set( \$RTAddressRegexp , qr/^bad_re_that_doesnt_match\$/i);
};
if ( $ENV{'RT_TEST_DB_SID'} ) { # oracle case
print $config "Set( \$DatabaseName , '$ENV{'RT_TEST_DB_SID'}' );\n";
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list