[rt-devel] Attempting to make Subject: tag matching a little more permissive, diff enclosed
Alexis Rosen
alexis at panix.com
Wed Sep 28 13:53:55 EDT 2016
Hi. I'm trying to make RT play nice with a certain large telecom vendor's ticketing system. They're trying to play nice too, but they're too dumb to get it right. :-( In particular, they're turning our "[tag #12345]" into "[tag#12345]" on subject lines. So I want to relax the requirement for whitespace between the tag and the ticket number.
I was a bit lazy for a cold source-dive, but fortunately google turned up a commit a few years back that looked like it was touching exactly the code I wanted, lib/RT/Interface/Email.pm: ParseTicketId().
It looks like the changes I need to make are:
--- Email.pm 2015-10-19 13:38:13.000000000 -0400
+++ Email.test.pm 2016-09-28 12:50:06.000000000 -0400
@@ -1139,11 +1139,11 @@
# We use @captures and pull out the last capture value to guard against
# someone using (...) instead of (?:...) in $EmailSubjectTagRegex.
my $id;
- if ( my @captures = $Subject =~ /\[$test_name\s+\#(\d+)\s*\]/i ) {
+ if ( my @captures = $Subject =~ /\[$test_name\s*\#(\d+)\s*\]/i ) {
$id = $captures[-1];
} else {
foreach my $tag ( RT->System->SubjectTag ) {
- next unless my @captures = $Subject =~ /\[\Q$tag\E\s+\#(\d+)\s*\]/i;
+ next unless my @captures = $Subject =~ /\[\Q$tag\E\s*\#(\d+)\s*\]/i;
$id = $captures[-1];
last;
}
In other words, just replace a "+" with a "*", so it'll match no whitespace as well as some.
So, questions:
1) Does this make sense?
2) Am I likely to screw anything up by doing this?
3) Did I leave out something else that needs to be adjusted, besides ParseTicketId()?
4) Do I really need the first change? (I'm not sure what "$test_name" is for)
And lastly, is it worth submitting this patch? In my estimation, it's still a unique enough match that it shouldn't scarf up things it shouldn't, so it might be generally useful to others trying to work with foreign ticketing systems, while not bothering anyone who isn't.
I can run this way in a test instance for a while, but my major concern is screwing up on real-world inbound mail, which I can't easily test.
I'll be monitoring this list on the web, but a direct reply would be appreciated anyway.
Thanks,
/a
More information about the rt-devel
mailing list