From a842ebb18b8e952456997605af1b9b4c86907f24 Mon Sep 17 00:00:00 2001 From: NarayanBavisetti Date: Wed, 20 Aug 2025 21:06:41 +0530 Subject: [PATCH 1/2] chore: changed the regex validation for html --- apps/api/plane/utils/content_validator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/api/plane/utils/content_validator.py b/apps/api/plane/utils/content_validator.py index 7b9932a35b9..10b460b3122 100644 --- a/apps/api/plane/utils/content_validator.py +++ b/apps/api/plane/utils/content_validator.py @@ -190,8 +190,8 @@ def validate_html_content(html_content): # Basic HTML structure validation - check for common malformed tags try: # Count opening and closing tags for basic structure validation - opening_tags = re.findall(r"<(\w+)[^>]*>", html_content) - closing_tags = re.findall(r"", html_content) + opening_tags = re.findall(r"<([A-Za-z][A-Za-z0-9:_-]*)[^>]*>", html_content) + closing_tags = re.findall(r"", html_content) # Filter out self-closing tags from opening tags opening_tags_filtered = [ From aed430450723ee2adff2ebb361d59ee4128088d2 Mon Sep 17 00:00:00 2001 From: NarayanBavisetti Date: Wed, 20 Aug 2025 21:18:33 +0530 Subject: [PATCH 2/2] chore: removed the tags calculation --- apps/api/plane/utils/content_validator.py | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/apps/api/plane/utils/content_validator.py b/apps/api/plane/utils/content_validator.py index 10b460b3122..d28b83fc700 100644 --- a/apps/api/plane/utils/content_validator.py +++ b/apps/api/plane/utils/content_validator.py @@ -187,24 +187,6 @@ def validate_html_content(html_content): f"HTML content contains dangerous JavaScript in event handler: {handler_content[:100]}", ) - # Basic HTML structure validation - check for common malformed tags - try: - # Count opening and closing tags for basic structure validation - opening_tags = re.findall(r"<([A-Za-z][A-Za-z0-9:_-]*)[^>]*>", html_content) - closing_tags = re.findall(r"", html_content) - - # Filter out self-closing tags from opening tags - opening_tags_filtered = [ - tag for tag in opening_tags if tag.lower() not in SELF_CLOSING_TAGS - ] - - # Basic check - if we have significantly more opening than closing tags, it might be malformed - if len(opening_tags_filtered) > len(closing_tags) + 10: # Allow some tolerance - return False, "HTML content appears to be malformed (unmatched tags)" - - except Exception: - # If HTML parsing fails, we'll allow it - pass return True, None