Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

Update script filter

Magnus Müller5c4bdc5534f7
diff --git a/examples/integrations/agentmail/email_tools.py b/examples/integrations/agentmail/email_tools.py
index 8fbbb83bc..0937c49d5 100644
--- a/examples/integrations/agentmail/email_tools.py
+++ b/examples/integrations/agentmail/email_tools.py
@@ -48,9 +48,9 @@ class EmailController(Tools):
"""
import re
- # Remove script and style elements
- html = re.sub(r'<script[^>]*>.*?</script>', '', html, flags=re.DOTALL | re.IGNORECASE)
- html = re.sub(r'<style[^>]*>.*?</style>', '', html, flags=re.DOTALL | re.IGNORECASE)
+ # Remove script and style elements - handle spaces in closing tags
+ html = re.sub(r'<script\b[^>]*>.*?</script\s*>', '', html, flags=re.DOTALL | re.IGNORECASE)
+ html = re.sub(r'<style\b[^>]*>.*?</style\s*>', '', html, flags=re.DOTALL | re.IGNORECASE)
# Remove HTML tags
html = re.sub(r'<[^>]+>', '', html)