[Scummvm-git-logs] scummvm master -> 886743872bad429990a2c542cb63fafdd7e84e13

sev- noreply at scummvm.org
Mon Sep 2 14:00:02 UTC 2024


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:
886743872b DEVTOOLS: COMPANION: Fix needs_punyencoding function


Commit: 886743872bad429990a2c542cb63fafdd7e84e13
    https://github.com/scummvm/scummvm/commit/886743872bad429990a2c542cb63fafdd7e84e13
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2024-09-02T16:00:00+02:00

Commit Message:
DEVTOOLS: COMPANION: Fix needs_punyencoding function

When using non-ascii characters, the filename needs punyencoding.

Changed paths:
    devtools/dumper-companion.py


diff --git a/devtools/dumper-companion.py b/devtools/dumper-companion.py
index 347b4493cf9..82d49076cd0 100755
--- a/devtools/dumper-companion.py
+++ b/devtools/dumper-companion.py
@@ -86,6 +86,8 @@ decode_map = {
 }
 # fmt: on
 
+SPECIAL_SYMBOLS = '/":*|\\?%<>\x7f'
+
 
 class FileSystem(Enum):
     hybrid = 'hybrid'
@@ -225,7 +227,7 @@ def escape_string(s: str) -> str:
     for char in s:
         if char == "\x81":
             new_name += "\x81\x79"
-        elif char in '/":*|\\?%<>\x7f' or ord(char) < 0x20:
+        elif char in SPECIAL_SYMBOLS or ord(char) < 0x20:
             new_name += "\x81" + chr(0x80 + ord(char))
         else:
             new_name += char
@@ -259,7 +261,9 @@ def needs_punyencoding(orig: str) -> bool:
     - contains a char that should be escaped or
     - ends with a dot or a space.
     """
-    if orig != escape_string(orig):
+    if not all(
+        (0x20 <= ord(c) < 0x80) and
+        c not in SPECIAL_SYMBOLS for c in orig):
         return True
     if orig[-1] in " .":
         return True
@@ -1164,7 +1168,7 @@ def test_needs_punyencoding():
     checks = [
         ["Icon\r", True],
         ["ascii", False],
-        ["バッドデイ(Power PC)", False],
+        ["バッドデイ(Power PC)", True],
         ["ends_with_dot .", True],
         ["ends_with_space ", True],
         ["Big[test]", False],




More information about the Scummvm-git-logs mailing list