Explorar o código

Prevent the history from being altered by the html script

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

+ 2 - 1
html_generator.py

@@ -233,7 +233,8 @@ def generate_chat_html(history, name1, name2, character):
             img = f'<img src="file/{i}">'
             break
 
-    for i,row in enumerate(history[::-1]):
+    for i,_row in enumerate(history[::-1]):
+        row = _row.copy()
         row[0] = re.sub(r"[\\]*\*", r"*", row[0])
         row[1] = re.sub(r"[\\]*\*", r"*", row[1])
         row[0] = re.sub(r"(\*)([^\*\n]*)(\*)", r"<em>\2</em>", row[0])