fix: remove /s flag in markdown regex, add conversation delete
This commit is contained in:
27
fix_chat_v2.py
Normal file
27
fix_chat_v2.py
Normal file
@ -0,0 +1,27 @@
|
||||
"""Fix chat JS: replace the problematic /s regex flag with safe alternative."""
|
||||
path = "/home/ubuntu/ai-chat/app.py"
|
||||
|
||||
with open(path) as f:
|
||||
content = f.read()
|
||||
|
||||
# Replace the problematic regex with /s flag
|
||||
old = """s=s.replace(/(<li>.*<\\/li>)/s,'<ul>$1</ul>');"""
|
||||
new = """s=s.replace(/(<li>[^]*?<\\/li>)/g,function(m){return '<ul>'+m+'</ul>';});"""
|
||||
|
||||
if old in content:
|
||||
content = content.replace(old, new)
|
||||
print("Fixed /s flag regex")
|
||||
else:
|
||||
print("Pattern not found, checking alternatives...")
|
||||
# Try unescaped version
|
||||
old2 = "s=s.replace(/(<li>.*<\\/li>)/s,'<ul>$1</ul>');"
|
||||
if old2 in content:
|
||||
content = content.replace(old2, new)
|
||||
print("Fixed (alt)")
|
||||
|
||||
with open(path, "w") as f:
|
||||
f.write(content)
|
||||
|
||||
# Verify: count the _md function
|
||||
count = content.count("function _md(s)")
|
||||
print(f"_md definitions: {count}")
|
||||
Reference in New Issue
Block a user