Spaces:
Running
Running
FIX: Handle truncated HTML tags <a href=" src=" in _clean function
Browse files- 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
|
|
|
|
|
|
|
| 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)
|