bep40 commited on
Commit
f80e77f
·
verified ·
1 Parent(s): 6c3add6

FIX: Handle truncated HTML tags <a href=" src=" in _clean function

Browse files
Files changed (1) hide show
  1. ai_patch.py +3 -1
ai_patch.py CHANGED
@@ -22,7 +22,9 @@ except Exception:
22
 
23
  def _clean(s):
24
  s = html_lib.unescape(s or "")
25
- # FIX: Remove malformed HTML artifacts like <a href=" src="..."> (missing closing >)
 
 
26
  s = re.sub(r'<a\s+[^>]*href\s*=\s*"[^"]*"\s*src\s*=\s*"[^"]*"[^>]*', '', s, flags=re.I)
27
  # Remove HTML tags like <a href=...>, <img src=...>
28
  s = re.sub(r'<[^>]+>', '', s)
 
22
 
23
  def _clean(s):
24
  s = html_lib.unescape(s or "")
25
+ # FIX: Remove malformed HTML artifacts (truncated tags without closing >)
26
+ s = s.replace('<a href=" src="', '').replace("<a href=' src='", '')
27
+ s = s.replace('<a href=" src=', '').replace("<a href=' src=", '')
28
  s = re.sub(r'<a\s+[^>]*href\s*=\s*"[^"]*"\s*src\s*=\s*"[^"]*"[^>]*', '', s, flags=re.I)
29
  # Remove HTML tags like <a href=...>, <img src=...>
30
  s = re.sub(r'<[^>]+>', '', s)