Explorar o código

Fix regex bug in loading character jsons with special characters

oobabooga %!s(int64=2) %!d(string=hai) anos
pai
achega
444cd69c67
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  1. 1 1
      server.py

+ 1 - 1
server.py

@@ -733,7 +733,7 @@ def tokenize_dialogue(dialogue, name1, name2):
     dialogue = re.sub('<start>', '', dialogue)
     dialogue = re.sub('(\n|^)[Aa]non:', '\\1You:', dialogue)
     dialogue = re.sub('(\n|^)\[CHARACTER\]:', f'\\g<1>{name2}:', dialogue)
-    idx = [m.start() for m in re.finditer(f"(^|\n)({name1}|{name2}):", dialogue)]
+    idx = [m.start() for m in re.finditer(f"(^|\n)({re.escape(name1)}|{re.escape(name2)}):", dialogue)]
     if len(idx) == 0:
         return _history