RT 4.0.13 REST.pm faulty regex?

Hello,

We recently upgraded from RT 3.6 to RT 4.0.13, and suddenly a couple previously working Perl scripts that use the RT::Client::REST convenience library (version 0.44) stopped working, and started indicating an error with the regex in /rt-4.0.13/lib/RT/Interface/REST.pm line 141, which in turn references the $field variable defined on line 74 in that same file.

The regex defined there is as follows:

my $field = '[a-z][a-z0-9_- ~/]*’;

Perl is complaining about an “Invalid [] range “_- “ in regex” at this location, which you can see follows the 9 character.

I’m wondering if anyone else has come across this problem and if they have a suggested solution or knows what the correct regex should be.

Thanks,
Jason

Hello,

We recently upgraded from RT 3.6 to RT 4.0.13, and suddenly a couple previously working Perl scripts that use the RT::Client::REST convenience library (version 0.44) stopped working, and started indicating an error with the regex in /rt-4.0.13/lib/RT/Interface/REST.pm line 141, which in turn references the $field variable defined on line 74 in that same file.

The regex defined there is as follows:

my $field = '[a-z][a-z0-9_- ~/]*�;

Perl is complaining about an �Invalid [] range �_- � in regex� at this location, which you can see follows the 9 character.

I�m wondering if anyone else has come across this problem and if they have a suggested solution or knows what the correct regex should be.

Thanks,
Jason

To give a bit more information, Jason & I had added the characters
behind _- because some of our custom field names contain spaces, ~ & /.
If there’s a better way to represent that, we’re all ears.

---------- Forwarded message ----------
From: Gene Hsu <gene@hsufarm.com mailto:gene@hsufarm.com>
Date: Tue, Oct 29, 2013 at 6:53 AM
Subject: Re: [rt-devel] RT 4.0.13 REST.pm faulty regex?
To: Jason Baum <jbaum-contractor@marchex.com
mailto:jbaum-contractor@marchex.com>

‘-’ must be at the beginning or end of a character class in order to be
interpreted as a ‘-’, otherwise it is interpreted as a range separator.

I know nothing about the business logic around the regex, but it could
conceivably be this:

my $field = '[a-z][a-z0-9_ ~/-]*�;

The error exists because ‘_’ comes after ’ ’ in the character set, since
a range is specified from lower bounds to upper bounds.

– Gene

This makes sense to me. I’ll make the change & report back. Thank you.

---------- Forwarded message ----------
From: Gene Hsu <gene@hsufarm.com mailto:gene@hsufarm.com>
Date: Tue, Oct 29, 2013 at 6:53 AM
Subject: Re: [rt-devel] RT 4.0.13 REST.pm faulty regex?
To: Jason Baum <jbaum-contractor@marchex.com
mailto:jbaum-contractor@marchex.com>

‘-’ must be at the beginning or end of a character class in order to be
interpreted as a ‘-’, otherwise it is interpreted as a range separator.

I know nothing about the business logic around the regex, but it could
conceivably be this:

my $field = '[a-z][a-z0-9_ ~/-]*�;

The error exists because ‘_’ comes after ’ ’ in the character set, since
a range is specified from lower bounds to upper bounds.

That worked beautifully. Thank you for the regex help. I guess it’s
true that you learn something new every day.

my $field = '[a-z][a-z0-9_ ~/-]*’;

The error exists because ‘_’ comes after ’ ’ in the character set, since
a range is specified from lower bounds to upper bounds.

That worked beautifully. Thank you for the regex help. I guess
it’s true that you learn something new every day.

The regex you’re changing is actually the one for parsing

Subject:
Requestors:

from the REST submission. The code for handling
CF.{Foo} comes from the custom_field_spec and is much more liberal
already. I expect some other problem, but you didn’t show a REST
trace.

On 4.2.0 I can run
./bin/rt ls "‘CF.{F~G/Bar}’ = 1"
and see over the wire
CF.{F~G/Bar}: 1
and that gets parsed properly and returns values.

Your report did uncover another interesting thing, but not the bug as
reported/fixed by your change.

-kevin