Conversation
WalkthroughAdjusted the HTML closing-tag regex in validate_html_content to accept hyphenated tag names (e.g., Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 2
🔭 Outside diff range comments (1)
apps/api/plane/utils/content_validator.py (1)
202-203: Increase HTML tag mismatch tolerance and extend SELF_CLOSING_TAGSThe hard-coded tolerance of 10 unmatched tags combined with a very small set of self-closing tags (
img,br,hr, etc.) can easily be exceeded in real-world content (many images, inputs, Meta/Link tags or custom components like<Image />). This will produce false positives on otherwise valid HTML. Please:• In
apps/api/plane/utils/content_validator.py, expandSELF_CLOSING_TAGSto include all HTML5 void elements (area, base, col, embed, input, keygen, link, meta, param, source, track, wbr) and any framework-specific self-closing components you use.
• Replace the magic number10with a named constant (e.g.HTML_TAG_TOLERANCE) and choose a higher default (e.g. 20–30), or derive it dynamically based on total tag count.
• Optionally, filter out any tag matched by the self-closing regex/<\w+[^>]*\/>/so you don’t have to maintain an exhaustive list.Suggested diff:
--- a/apps/api/plane/utils/content_validator.py +++ b/apps/api/plane/utils/content_validator.py @@ -15,6 +15,15 @@ # HTML self-closing tags that don’t need closing tags SELF_CLOSING_TAGS = { "img", "br", "hr", + # void elements + "area", "base", "col", "embed", + "input", "keygen", "link", "meta", + "param", "source", "track", "wbr", + # Add any framework-specific self-closing components here +} + +# Maximum allowed unmatched tags for basic structure validation +HTML_TAG_TOLERANCE = 20 @@ -200,7 +209,7 @@ opening_tags_filtered = [ tag for tag in opening_tags if tag.lower() not in SELF_CLOSING_TAGS ] - if len(opening_tags_filtered) > len(closing_tags) + 10: + if len(opening_tags_filtered) > len(closing_tags) + HTML_TAG_TOLERANCE: return False, "HTML content appears to be malformed (unmatched tags)"
Description
Fixed an issue with HTML closing tag validation logic. The original regular expressions failed to properly recognize custom component tags (e.g.,
<image-component></image-component>), causing the system to incorrectly reject saves when documents contained more than 10 images due to perceived HTML structure issues.Type of Change
Screenshots and Media (if applicable)
Test Scenarios
<div>,<p>)<image-component>)References
Key Changes:
Summary by CodeRabbit