Re: LWP::Protocol::file is tripped up by a bug in -e
Father Chrysostomos <[email protected]> Mon, 23 Aug 2010 06:21:35 -0700
| Newsgroups | gmane.comp.lang.perl.modules.lwp |
|---|---|
| Message-ID | <[email protected]> |
On Aug 22, 2010, at 6:24 AM, Gisle Aas wrote: > I'm not convinced this is the right thing to do. How did the $path > string end up utf8::upgraded() in the first place here? The URL was extracted from a page encoded in UTF-8. The first thing I do when reading a page is to decode it, regardless of the encoding. So it almost always ends up with the UTF8 flag on. > > --Gisle > > On Sun, Aug 15, 2010 at 23:14, Father Chrysostomos <[email protected]> wrote: >> Perl’s -e ignores the internal UTF8 flag. (See <http://rt.perl.org/rt3/Ticket/Display.html?id=77242>.) >> >> LWP::Protocol::file triggers this bug in this piece of code: >> >> # test file exists and is readable >> unless (-e $path) { >> return new HTTP::Response &HTTP::Status::RC_NOT_FOUND, >> "File `$path' does not exist"; >> } >> >> If you add >> $path =~ /[^\0-\xff]/ or utf8::downgrade($path); # work around perl bug #77242 >> before the ‘unless’ statement, it works. >> >>