#61 SOAP call breaks regex 'm/.*($n)/i' when using locale

0.60
closed-invalid
nobody
None
5
2007-10-03
2004-12-17
Tim
No

This is a very strange bug...

The following regular expression breaks when called
remotely via SOAP if 'locale' is used:

($match) = $haystack =~ m/.*($needle)/i;

Any search for a capital letter in $needle fails! For
example, if $needle = 'E' and $haystack = 'NEEDLE' the
the regex above returns $match = undef if called
remotely and locale is used.

I have verified on:

1) Windows XP using Perl v5.8.5 built for
cygwin-thread-multi-64int and SOAP-Lite-0.60a installed
via CPAN

2) Debian 'sarge' using Perl, v5.8.4 built for
i386-linux-thread-multi and libsoap-lite-perl (0.60-2)
installed via apt-get

I wrote a small test program to illustrate this bug
which calls the broken regex remotely and via a local
object call, with and without using 'locale'.

The output from this program is as follows:

--------------------------------------------------------

$ perl -I. Test_Client.pl E NEEDLE

Looking for 'E' in 'NEEDLE'

*** Without 'use locale' ***

Remote: 'E'
Object: 'E'

*** Include 'use locale' ***

Remote: ''
Object: 'E'

$ perl -I. Test_Client.pl e NEEDLE

Looking for 'e' in 'NEEDLE'

*** Without 'use locale' ***

Remote: 'E'
Object: 'E'

*** Include 'use locale' ***

Remote: ''
Object: 'E'

$ perl -I. Test_Client.pl E needle

Looking for 'E' in 'needle'

*** Without 'use locale' ***

Remote: 'e'
Object: 'e'

*** Include 'use locale' ***

Remote: 'e'
Object: 'e'

$ perl -I. Test_Client.pl e needle

Looking for 'e' in 'needle'

*** Without 'use locale' ***

Remote: 'e'
Object: 'e'

*** Include 'use locale' ***

Remote: 'e'
Object: 'e'

--------------------------------------------------------

Is this a know issue? Can anyone think of a workaround?

Any help on this subject will be greatly appreciated as
this bug is blocking our use of SOAP::Lite at the moment :(

Thanks!
Tim

--------------------------------------------------------
Test.pm
--------------------------------------------------------
#!/usr/bin/perl -w

use strict;
use warnings;

package Test;

sub test {
my ($self, $useLocale, $needle, $haystack) = @_;
my $match;

if ($useLocale == 1) {
use locale;
($match) = $haystack =~ m/.*($needle)/i;
}
else {
($match) = $haystack =~ m/.*($needle)/i;
}
return defined($match) ? $match : '';
}

1;

--------------------------------------------------------
Test_Daemon.pm
--------------------------------------------------------
#!/usr/bin/perl -w

use strict;
use warnings;
use SOAP::Transport::HTTP;
use Test;

my $daemon = SOAP::Transport::HTTP::Daemon
-> new (LocalPort => 7000)
-> dispatch_to('Test')
;

print "Connect to SOAP server at ", $daemon->url, "\n";
$daemon->handle;

--------------------------------------------------------
Test_Client.pm
--------------------------------------------------------
#!/usr/bin/perl -w

use strict;
use warnings;
use SOAP::Lite;
use Test;

my $needle = $ARGV[0];
my $haystack = $ARGV[1];
print "\nLooking for '$needle' in '$haystack'\n\n";

my $test = 'testing';
$test = bless(\$test, 'Test');
my $proxy = SOAP::Lite
-> uri('http://pomegranate/Test')
-> proxy('http://pomegranate:7000/');

print "*** Without 'use locale' ***\n\n";

print "Remote: '" . $proxy->test(0, $needle,
$haystack)->result . "'\n";
print "Object: '" . $test->test(0, $needle, $haystack)
. "'\n";

print "\n\n*** Include 'use locale' ***\n\n";

print "Remote: '" . $proxy->test(1, $needle,
$haystack)->result . "'\n";
print "Object: '" . $test->test(1, $needle, $haystack)
. "'\n";

--------------------------------------------------------
Run Using
--------------------------------------------------------
perl -I. Test_Deamon.pl
perl -I. Test_Client.pl E NEEDLE

Discussion

  • Tim
    Tim
    2004-12-17

    Testing Module which demonstrates bug when called VIA SOAP::Lite

     
    Attachments
  • Tim
    Tim
    2004-12-17

    HTTP Daemon code

     
    Attachments
  • Tim
    Tim
    2004-12-17

    Client code

     
    Attachments
  • Byrne Reese
    Byrne Reese
    2005-03-28

    Logged In: YES
    user_id=28043

    Please consult the following documentation:
    http://www.xav.com/perl/lib/Pod/perllocale.html#using%20locales

    The problem lies in the fact that when using locale, a case
    insenstive regular expression will not perform exactly as
    you might expect.

    "Finally, LC_CTYPE affects the POSIX character-class test
    functions--isalpha(), islower(), and so on. For example, if
    you move from the ``C'' locale to a 7-bit Scandinavian one,
    you may find--possibly to your surprise--that ``|'' moves
    from the ispunct() class to isalpha()."

     
  • Byrne Reese
    Byrne Reese
    2005-03-28

    • status: open --> open-invalid
     
  • Martin Kutter
    Martin Kutter
    2007-10-03

    • status: open-invalid --> closed-invalid