URI: uninitialized value in substitution iterator

Bill Moseley <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.lwp
Message-ID <[email protected]>
Hi Gisle,

I'm not sure I'd consider this a bug, bit it did make for some very
noisy web logs.


In URI::_init there's this substitution:

    $str =~ s/([^$uric\#])/$URI::Escape::escapes{$1}/go;


I ended up with some utf8 in a URI and received warnings:

    Use of uninitialized value in substitution iterator
        at /usr/share/perl5/URI.pm at line 75 (or so)


$URI::Escape::escapes is keyed like this:

    for (0..255) {
        $escapes{chr($_)} = sprintf("%%%02X", $_);
    }

But if there's utf8 in the string the substitution will return unicode
characters.

For example, if I hack in some debugging lines into _init:

    warn " [$str] " . (Encode::is_utf8( $str ) ? "is utf8\n" : "is not utf8\n");
    my $x = $str;
    $x =~ s/([^$uric\#])/'[' . ord($1) . ']'/ge;
    warn "x= '$x'\n";
    $str =~ s/([^$uric\#])/$URI::Escape::escapes{$1}/go;

And pass in some random utf-8:


 [Платить] is utf8
x= '[1055][1083][1072][1090][1080][1090][1100]'
Use of uninitialized value in substitution iterator at /usr/share/perl5/URI.pm line 80.
Use of uninitialized value in substitution iterator at /usr/share/perl5/URI.pm line 80.
Use of uninitialized value in substitution iterator at /usr/share/perl5/URI.pm line 80.
Use of uninitialized value in substitution iterator at /usr/share/perl5/URI.pm line 80.
Use of uninitialized value in substitution iterator at /usr/share/perl5/URI.pm line 80.
Use of uninitialized value in substitution iterator at /usr/share/perl5/URI.pm line 80.
Use of uninitialized value in substitution iterator at /usr/share/perl5/URI.pm line 80.



-- 
Bill Moseley
[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.