[Scummvm-git-logs] scummvm-sites integrity -> 940a36779f7e30d2e8328af9685b356cafb3c84b

sev- noreply at scummvm.org
Sun May 4 05:20:38 UTC 2025


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm-sites' repo located at https://api.github.com/repos/scummvm/scummvm-sites .

Summary:
940a36779f INTEGRITY: Sync punycode code with Dumper Companion


Commit: 940a36779f7e30d2e8328af9685b356cafb3c84b
    https://github.com/scummvm/scummvm-sites/commit/940a36779f7e30d2e8328af9685b356cafb3c84b
Author: ShivangNagta (shivangnag at gmail.com)
Date: 2025-05-04T13:20:35+08:00

Commit Message:
INTEGRITY: Sync punycode code with Dumper Companion

Changed paths:
    .gitignore
    db_functions.py


diff --git a/.gitignore b/.gitignore
index eea87ae..08646ae 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
 *.dat
 mysql_config.json
 __pycache__
+.DS_Store
diff --git a/db_functions.py b/db_functions.py
index 99245df..8677164 100644
--- a/db_functions.py
+++ b/db_functions.py
@@ -9,6 +9,8 @@ from pymysql.converters import escape_string
 from collections import defaultdict
 import re
 
+SPECIAL_SYMBOLS = '/":*|\\?%<>\x7f'
+
 def db_connect():
     base_dir = os.path.dirname(os.path.abspath(__file__))
     config_path = os.path.join(base_dir, 'mysql_config.json')
@@ -158,7 +160,6 @@ def insert_file(file, detection, src, conn):
         detection = 0
     detection_type = f"{checktype}-{checksize}" if checktype != "None" else f"{checktype}"
     if punycode_need_encode(file['name']):
-        print(encode_punycode(file['name']))
         query = f"INSERT INTO file (name, size, checksum, fileset, detection, detection_type, `timestamp`) VALUES ('{encode_punycode(file['name'])}', '{file['size']}', '{checksum}', @fileset_last, {detection}, '{detection_type}', NOW())"
     else:
         query = f"INSERT INTO file (name, size, checksum, fileset, detection, detection_type, `timestamp`) VALUES ('{escape_string(file['name'])}', '{file['size']}', '{checksum}', @fileset_last, {detection}, '{detection_type}', NOW())"
@@ -204,7 +205,7 @@ def my_escape_string(s: str) -> str:
             new_name += "\x81" + chr(0x80 + ord(char))
         else:
             new_name += char
-    return new_name
+    return escape_string(new_name)
 
         
 def encode_punycode(orig):
@@ -232,7 +233,9 @@ def punycode_need_encode(orig):
     - 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
@@ -990,4 +993,4 @@ def add_usercount(fileset, conn):
         cursor.execute(f"SELECT user_count from fileset WHERE id = {fileset}")
         count = cursor.fetchone()['user_count']
         if count >= 3:
-            cursor.execute(f"UPDATE fileset SET status = 'ReadyForReview' WHERE id = {fileset}")
\ No newline at end of file
+            cursor.execute(f"UPDATE fileset SET status = 'ReadyForReview' WHERE id = {fileset}")




More information about the Scummvm-git-logs mailing list