Skip to content

Potential fix for code scanning alert no. 59: DOM text reinterpreted as HTML#19

Merged
mokesano merged 4 commits into
mainfrom
alert-autofix-59
Jun 2, 2026
Merged

Potential fix for code scanning alert no. 59: DOM text reinterpreted as HTML#19
mokesano merged 4 commits into
mainfrom
alert-autofix-59

Conversation

@mokesano

Copy link
Copy Markdown
Owner

Potential fix for https://github.com/mokesano/editorial-pro/security/code-scanning/59

The safest fix without changing functionality is to stop concatenating unescaped dynamic strings into HTML. Build the list using DOM APIs (createElement, textContent, appendChild) so highlight text is always inserted as text, not interpreted as HTML.

Best concrete change in plugins/themes/sangiapub/js/ArticleHighlight_v1.js:

  • In displayArticleHighlights(), replace the html string construction loop and highlightsElement.innerHTML = html;.
  • Keep static structure/classes the same (li.react-xocs-list-item, span.list-label, span.u-ml-16, nested p).
  • Clear existing content safely (e.g., highlightsElement.textContent = '') and append constructed nodes.
  • This preserves visual output and behavior while eliminating XSS risk from highlight.

No new imports or external dependencies are needed.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

@mokesano mokesano self-assigned this Apr 28, 2026
@mokesano mokesano requested a review from archoun April 28, 2026 10:37
@mokesano mokesano added bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request labels Apr 28, 2026
@mokesano mokesano marked this pull request as ready for review April 28, 2026 10:37

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3c68456caa

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

contentSpan.className = 'u-ml-16';

const p = document.createElement('p');
p.textContent = highlight;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve readable highlight text when switching to text nodes

Assigning highlight via textContent makes any inline HTML in the generated summary render literally. In this file, highlights are derived from abstractElement.innerHTML, so abstracts containing tags/entities (for example <sub>, <i>, or &alpha;) will now display raw markup text to users instead of readable output. This is a user-visible regression introduced by the change; sanitize/normalize the abstract to plain text before scoring/generation to keep the XSS fix without degrading display.

Useful? React with 👍 / 👎.

@archoun archoun left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Came on boy

…as HTML

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@mokesano mokesano merged commit b658c72 into main Jun 2, 2026
11 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in wizdam-fork Jun 2, 2026
@mokesano mokesano deleted the alert-autofix-59 branch June 2, 2026 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants