/usr/share/perl5/JE/escape.pl is in libje-perl 0.066-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | package JE;
use strict;
use warnings; no warnings 'utf8';
use Encode 2.08 qw< decode_utf8 encode_utf8 FB_CROAK >;
sub _decodeURI {
my $global = shift;
my $str = shift;
$str = defined $str ? $str->to_string->value : 'undefined';
$str =~ /%(?![a-fA-F0-9]{2})(.{0,2})/
and require JE::Object::Error::URIError,
die
JE::Object::Error::URIError->new(
$global,
add_line_number
"Invalid escape %$1 in URI"
);
$str = encode_utf8 $str;
# [;/?:@&=+$,#] do not get unescaped
$str =~ s/%(?!2[346bcf]|3[abdf]|40)
([0-9a-f]{2})/chr hex $1/iegx;
if (do{
local $@;
eval {
$str = decode_utf8 $str, FB_CROAK;
};
$@
}) {
require JE'Object'Error'URIError;
die JE::Object::Error::URIError
->new(
$global,
add_line_number
'Malformed UTF-8 in URI'
);
}
$str =~
/^[\0-\x{10ffff}]*\z/
or require JE::Object::Error::URIError,
die JE::Object::Error::URIError->new(
$global, add_line_number
'Malformed UTF-8 in URI');
JE::String->_new($global, $str);
}
sub _decodeURIComponent {
my $global = shift;
my $str = shift;
$str = defined $str ? $str->to_string->value : 'undefined';
$str =~ /%(?![a-fA-F0-9]{2})(.{0,2})/
and require JE::Object::Error::URIError,
die
JE::Object::Error::URIError->new(
$global,
add_line_number
"Invalid escape %$1 in URI"
);
$str = encode_utf8 $str;
# [;/?:@&=+$,#] do not get unescaped
$str =~ s/%([0-9a-f]{2})/chr hex $1/iegx;
if (do{
local $@;
eval {
$str = decode_utf8 $str, FB_CROAK;
};
$@
}) {
require JE'Object'Error'URIError;
die JE::Object::Error::URIError
->new(
$global,
add_line_number
'Malformed UTF-8 in URI'
);
}
$str =~
/^[\0-\x{10ffff}]*\z/
or require JE::Object::Error::URIError,
die JE::Object::Error::URIError->new(
$global, add_line_number
'Malformed UTF-8 in URI');
JE::String->_new($global, $str);
}
sub _encodeURI {
my $global = shift;
my $str = shift;
$str = defined $str ? $str->to_string->value : 'undefined';
$str =~ /(\p{Cs})/ and
require JE::Object::Error::URIError,
die JE::Object::Error::URIError->new($global,
add_line_number sprintf
"Unpaired surrogate 0x%x in string", ord $1
);
$str = encode_utf8 $str;
$str =~
s< ([^;/?:@&=+\$,A-Za-z0-9\-_.!~*'()#]) >
< sprintf '%%%02X', ord $1 >egx;
JE::String->_new($global, $str);
}
sub _encodeURIComponent {
my $global = shift;
my $str = shift;
$str = defined $str ? $str->to_string->value : 'undefined';
$str =~ /(\p{Cs})/ and
require JE::Object::Error::URIError,
die JE::Object::Error::URIError->new(
$global, add_line_number sprintf
"Unpaired surrogate 0x%x in string", ord $1
);
$str = encode_utf8 $str;
$str =~ s< ([^A-Za-z0-9\-_.!~*'()]) >
< sprintf '%%%02X', ord $1 >egx;
JE::String->_new($global, $str);
}
sub _escape {
my $global = shift;
my $str = defined $_[0] ? shift->to_string->value16 : 'undefined';
no warnings 'utf8';
$str =~ s< ([^A-Za-z0-9\@*_+\-./]) >
[ sprintf '%%' . (
ord $1 <= 0xff
? '%02'
: 'u%04'
) . 'x', ord $1 ]egx;
JE::String->_new($global, $str);
}
sub _unescape {
my $global = shift;
my $str = defined $_[0] ? shift->to_string->value16 : 'undefined';
$str =~s<%(?:u([a-f0-9]{4})|([a-f0-9]{2}))>
< chr hex $+ >egix;
JE::String->_new($global, $str);
}
1
|