From e5cf74245aaf4871c9bf3ef71a440123e1bb5e96 Mon Sep 17 00:00:00 2001 From: rattatwinko Date: Thu, 23 Apr 2026 08:25:52 +0200 Subject: [PATCH] add link and logging --- src/profiles.py | 2 ++ src/sanitizer.py | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/profiles.py b/src/profiles.py index 359d202..01d2576 100644 --- a/src/profiles.py +++ b/src/profiles.py @@ -89,6 +89,7 @@ def build_profiles_from_cfg(cfg: Optional[Dict[str, Any]] = None) -> Dict[str, D "table": ["summary", "class"], "th": ["scope", "colspan", "rowspan"], "td": ["colspan", "rowspan"], + "link": ["href", "rel"], "time": ["datetime"], "meta": ["charset", "name", "content"], "html": ["lang"], @@ -129,6 +130,7 @@ def build_profiles_from_cfg(cfg: Optional[Dict[str, Any]] = None) -> Dict[str, D "span": ["class", "id", "style"], "pre": ["class"], "code": ["class"], + "link" : ["href", "rel"], "meta": ["charset", "name", "content"], "html": ["lang"], "*": ["class", "id", "style"] diff --git a/src/sanitizer.py b/src/sanitizer.py index 79b10bd..6f982bf 100644 --- a/src/sanitizer.py +++ b/src/sanitizer.py @@ -59,6 +59,19 @@ def sanitize(html: str, mode: str, profiles: dict) -> str: pretty_body = BeautifulSoup(cleaned_body_content, "html.parser").prettify() pretty_head = BeautifulSoup(cleaned_head_content, "html.parser").prettify() + logger.log_debug( + # very ugly string concationation for logging + "parser args: " + str( + "Tags: " + str(config.get("tags")) + "\n" + + "Attributes: " + str(config.get("attributes")) + "\n" + + "Protocols: " + str(config.get("protocols")) + "\n" + + "Strip: " + str(config.get("strip")) + "\n" + ) + + "input html: " + str(html) + + "clean head: " + str(pretty_head) + + "clean body: " + str(pretty_body) + ) + return f"""