[Scummvm-git-logs] scummvm branch-2-5 -> 4758b58fb20cb2b436c90e0c52880844feda9bd3
sev-
sev at scummvm.org
Wed Nov 10 19:27:06 UTC 2021
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
4758b58fb2 COMMON: Sync punycode with JS/Python code:
Commit: 4758b58fb20cb2b436c90e0c52880844feda9bd3
https://github.com/scummvm/scummvm/commit/4758b58fb20cb2b436c90e0c52880844feda9bd3
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-11-10T20:26:56+01:00
Commit Message:
COMMON: Sync punycode with JS/Python code:
* Allow [] in file names
* Process files ending with spaces or dots
Changed paths:
common/punycode.cpp
diff --git a/common/punycode.cpp b/common/punycode.cpp
index a526a4768f..b9820b5700 100644
--- a/common/punycode.cpp
+++ b/common/punycode.cpp
@@ -59,7 +59,7 @@ namespace Common {
#define INITIAL_BIAS 72
#define SMAX 2147483647 // maximum Unicode code point
-#define SPECIAL_SYMBOLS "/\":*[]+|\\?%<>,;="
+#define SPECIAL_SYMBOLS "/\":*|\\?%<>,;="
static uint32 adapt_bias(uint32 delta, unsigned n_points, int is_first) {
uint32 k;
@@ -78,7 +78,7 @@ static uint32 adapt_bias(uint32 delta, unsigned n_points, int is_first) {
static char encode_digit(int c) {
assert(c >= 0 && c <= BASE - TMIN);
if (c > 25) {
- return c + 0x30 - 26; /* '0'..'9' */
+ return c + 22; /* '0'..'9' */
} else {
return c + 0x61; /* 'a'..'z' */
}
@@ -144,8 +144,15 @@ String punycode_encode(U32String src) {
size_t b = h;
// If every character is ASCII, return the original string.
- if (h == srclen)
+ if (h == srclen) {
+ // If string ends with space or dot, still punycode it
+ // because certain FSes do not support files with those
+ // endings
+ if (src[h - 1] == ' ' || src[h - 1] == '.')
+ return dst + '-';
+
return src;
+ }
// If we have any ASCII characters, add '-' to separate them from
// the non-ASCII character insertions.
@@ -205,6 +212,10 @@ bool punycode_needEncode(const String src) {
}
}
+ // If name ends with space or dot, we have to encode it
+ if (src[src.size() - 1] == ' ' || src[src.size() - 1] == '.')
+ return true;
+
return false;
}
More information about the Scummvm-git-logs
mailing list