Skip to content

Stricter html string check #639

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

wxiaoguang
Copy link

Fix #638

/^\s*<[a-zA-Z]/.test(" \n\t<a") => true

The real world case is like this:

const s = `
  <div ...>
   ...
  </div>
`;

@Copilot Copilot AI review requested due to automatic review settings June 30, 2025 11:09
@wxiaoguang wxiaoguang requested a review from a team as a code owner June 30, 2025 11:09
@wxiaoguang wxiaoguang requested a review from arelia June 30, 2025 11:09
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR ensures that HTML literal strings correctly handle leading whitespace by updating the regex match pattern.

  • Updated regex in unescaped-html-literal.js to allow for preceding whitespace before an HTML tag.
  • Fixes potential false negatives in matching real-world HTML snippets.
Comments suppressed due to low confidence (1)

lib/rules/unescaped-html-literal.js:18

  • Consider adding a comment explaining that the updated regex now supports leading whitespace before an HTML tag to aid future maintainability.
    const htmlOpenTag = /^\s*<[a-zA-Z]/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make unescaped-html-literal more strict
1 participant