COMMON: Punycode more invalid characters in filenames

This commit is contained in:
Eugene Sandulenko 2021-08-01 10:41:20 +02:00
parent 5288422e26
commit 1f40958a65
No known key found for this signature in database
GPG Key ID: 014D387312D34F08
2 changed files with 4 additions and 5 deletions

View File

@ -303,9 +303,8 @@ String punycode_encodefilename(const String src) {
if ((byte)src[i] == 0x81) { // In case we have our escape character present if ((byte)src[i] == 0x81) { // In case we have our escape character present
dst += '\x81'; dst += '\x81';
dst += '\x79'; dst += '\x79';
// [\x00-\x1f\/":] // Encode special symbols and non-printables
} else if (src[i] == '/' || src[i] == '"' || src[i] == ':' || src[i] == '*' } else if (rindex("/\":*[]+|\\?%<>,;=", (byte)src[i]) || (byte)src[i] < 0x20) {
|| src[i] == '[' || src[i] == ']' || (byte)src[i] < 0x20) {
dst += '\x81'; dst += '\x81';
dst += (byte)src[i] + '\x80'; dst += (byte)src[i] + '\x80';
} else { } else {

View File

@ -441,8 +441,8 @@ sub encode_punycodefilename {
my $decfname = shift; my $decfname = shift;
$decfname =~ s/\x81/\x81\x79/g; $decfname =~ s/\x81/\x81\x79/g;
# escape non-printables, '/', '"', '*', '[', ']' and ':' # escape non-printables, "/"*[]:+|"
$decfname =~ s/([\x00-\x1f\/":\*\[\]])/\x81@{[chr(ord($1) + 0x80)]}/g; $decfname =~ s/([\x00-\x1f\/":\*\[\]\+\|\\?%<>,;=])/\x81@{[chr(ord($1) + 0x80)]}/g;
if ($decfname =~ /[\x80-\xff]/) { if ($decfname =~ /[\x80-\xff]/) {
$decfname = encode_punycode $decfname; $decfname = encode_punycode $decfname;