LWP::Protocol::file is tripped up by a bug in -e

Father Chrysostomos <[email protected]> Sun, 15 Aug 2010 14:14:31 -0700
Newsgroups gmane.comp.lang.perl.modules.lwp
Message-ID <[email protected]>
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.