Explorar el Código

Fix validator problem with new version of python regex.

Cixo Develop hace 1 mes
padre
commit
604c1f6892

+ 9 - 2
server_source/validators_base.py

@@ -3,7 +3,9 @@ import re
 class validators_base:
     @staticmethod
     def _validate_generic_name(content: str, name: str = "it") -> str:
-        if re.search("\W ", content) is not None:
+        copy = content.replace("-", "").replace("_", "")
+
+        if not copy.isalpha():
             raise ValueError(
                 name.title() + " can contain only _ and alphanumeric chars."
             )
@@ -12,7 +14,12 @@ class validators_base:
 
     @staticmethod
     def _validate_white_chars(content: str, name: str = "it") -> str:
-        if re.search("\s", content) is not None:
+        contain = str(" ") in content
+        contain = contain or str("\t") in content
+        contain = contain or str("\r") in content
+        contain = contain or str("\n") in content
+
+        if contain:
             raise ValueError(
                 name.title() + " can not contain whitespace chars."
             )

+ 3 - 0
server_tests/8dhpYkkGTDRNpXGfZFZGI5USO0rd.txt

@@ -0,0 +1,3 @@
+# UwU
+ * First point
+ * Second point

+ 3 - 0
server_tests/GXdQfnBHlQm4MWbHUtomNK6v8TZmx.md

@@ -0,0 +1,3 @@
+# UwU
+ * First point
+ * Second point

+ 3 - 0
server_tests/Kn6WhE8Bu6AJPrvVGO4SEocf0qexB.md

@@ -0,0 +1,3 @@
+# UwU
+ * First point
+ * Second point

+ 3 - 0
server_tests/L2xRJKPDBrEHhs2rRSO749GhsyR4.txt

@@ -0,0 +1,3 @@
+# UwU
+ * First point
+ * Second point

+ 3 - 0
server_tests/jXfGdWjjkeFiHkfEUqIuAD856vfD.txt

@@ -0,0 +1,3 @@
+# UwU
+ * First point
+ * Second point