Skip to content

fix(core): make isContentEmpty robust to malformed and unclosed tags#60

Merged
Ndevu12 merged 1 commit intomainfrom
fix/is-content-empty-unclosed-tags
Mar 29, 2026
Merged

fix(core): make isContentEmpty robust to malformed and unclosed tags#60
Ndevu12 merged 1 commit intomainfrom
fix/is-content-empty-unclosed-tags

Conversation

@Ndevu12
Copy link
Copy Markdown
Owner

@Ndevu12 Ndevu12 commented Mar 29, 2026

Replace the regex-based strip (<[^>]*>) with a linear scan over angle brackets. The previous approach could misclassify strings with an unclosed '<' (e.g. literal text or partial tags) because the pattern left odd fragments or dropped visible characters in edge cases.

  • Treat text after '<' with no following '>' as visible content, so partial tags are not treated as empty.
  • Preserve existing behavior for normal HTML: empty/whitespace-only paragraphs and plain whitespace still count as empty.

Tests cover unclosed brackets, bare tags, multi-line ASCII whitespace inside tags, and tagless whitespace-only input.

Replace the regex-based strip (<[^>]*>) with a linear scan over angle brackets. The previous approach could misclassify strings with an unclosed '<' (e.g. literal text or partial tags) because the pattern left odd fragments or dropped visible characters in edge cases.

- Treat text after '<' with no following '>' as visible content, so partial tags are not treated as empty.
- Preserve existing behavior for normal HTML: empty/whitespace-only paragraphs and plain whitespace still count as empty.

Tests cover unclosed brackets, bare tags, multi-line ASCII whitespace inside tags, and tagless whitespace-only input.
@Ndevu12 Ndevu12 self-assigned this Mar 29, 2026
@Ndevu12 Ndevu12 added the fix Providing fixes for some issues/bugs label Mar 29, 2026
@Ndevu12 Ndevu12 merged commit 5b108e0 into main Mar 29, 2026
8 checks passed
@Ndevu12 Ndevu12 deleted the fix/is-content-empty-unclosed-tags branch March 29, 2026 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Providing fixes for some issues/bugs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant