Skip to content

Potential fix for code scanning alert no. 2: Incomplete string escaping or encoding#17

Merged
gmerlino merged 1 commit into
mainfrom
alert-autofix_
Jan 6, 2026
Merged

Potential fix for code scanning alert no. 2: Incomplete string escaping or encoding#17
gmerlino merged 1 commit into
mainfrom
alert-autofix_

Conversation

@gmerlino
Copy link
Copy Markdown
Contributor

@gmerlino gmerlino commented Jan 6, 2026

Potential fix for https://github.com/ProSoDiAC/prosodiac.github.io/security/code-scanning/2

In general, to fix this kind of problem you should either (a) use a well-tested library for whitespace/indentation normalization, or (b) ensure that your replace call uses a global regular expression (with the g flag) so that all intended occurrences are replaced, not just the first.

For this specific case in assets/js/distillpub/template.v2.js, inside the Code class’s renderContent method, the goal of the “normalize the tab indents” block is to normalize indentation across the entire content string. On line 4246, content.replace(/\n/, "") currently removes only the first newline. The minimal, behavior-preserving fix is to change this to content.replace(/\n/g, ""), which removes all newline characters before the code computes tabs and performs the subsequent normalization. No other lines, imports, or helper methods are required; the change is purely in the regular expression literal.

Concretely:

  • In assets/js/distillpub/template.v2.js, in the if (this.hasAttribute("block")) { block, update the content = content.replace(/\n/, ""); line to use /\n/g instead of /\n/.
  • No new imports or definitions are needed.

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

…ng or encoding

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@gmerlino gmerlino marked this pull request as ready for review January 6, 2026 19:13
@gmerlino gmerlino merged commit 702eee1 into main Jan 6, 2026
8 checks passed
@gmerlino gmerlino deleted the alert-autofix_ branch January 6, 2026 20:03
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.

1 participant