Skip to content

fix(Find): Replace single quotes in Finding’s html field#36

Merged
smockle merged 1 commit into
mainfrom
smockle/replace-single-quotes-in-html-snippet
Oct 22, 2025
Merged

fix(Find): Replace single quotes in Finding’s html field#36
smockle merged 1 commit into
mainfrom
smockle/replace-single-quotes-in-html-snippet

Conversation

@smockle

@smockle smockle commented Oct 21, 2025

Copy link
Copy Markdown
Collaborator

Addresses #22 (that issue will remain open until this fix is backported to the v1 and v2 series)

This PR escapes single quotes in the html field (other fields were escaped already). This prevents findings for elements with single quotes (e.g. <p>Hi y'all!</p>) from breaking workflows, specifically around action.yml#86, where a single-quoted shell string is sent to jq.

@smockle smockle requested a review from a team as a code owner October 21, 2025 19:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 fixes an issue where single quotes in HTML content were breaking downstream workflows that use shell string interpolation with jq. The fix applies HTML entity encoding (&apos;) to single quotes across all Finding fields.

Key Changes

  • Added single quote escaping to the previously unescaped html field
  • Standardized the escaping pattern across all fields from ' to &apos;

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

html: violation.nodes[0].html,
problemShort: violation.help.toLowerCase().replace(/[']/g, '’'),
problemUrl: violation.helpUrl.replace(/[']/g, '’'),
html: violation.nodes[0].html.replace(/'/g, "&apos;"),

Copilot AI Oct 21, 2025

Copy link

Choose a reason for hiding this comment

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

The html field should use HTML entity encoding for all special characters, not just single quotes. Consider using a proper HTML escaping function to handle <, >, &, \", and ' to prevent potential XSS vulnerabilities or data corruption when the HTML is processed downstream.

Copilot uses AI. Check for mistakes.

@smockle smockle Oct 21, 2025

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I'm open to this, but each of these specific examples is safe in a single-quoted shell string (where they are treated as string literals, not as shell operators, etc.)

@smockle smockle merged commit 72124dc into main Oct 22, 2025
5 checks passed
@smockle smockle deleted the smockle/replace-single-quotes-in-html-snippet branch October 22, 2025 14:39
smockle added a commit that referenced this pull request Oct 22, 2025
chore: Backport #36 to the `v1` branch

Partially addresses
#22
smockle added a commit that referenced this pull request Oct 22, 2025
chore: Backport #36 to the `v2` branch

Partially addresses
#22
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.

3 participants