Repository navigation
security: linear trailing-newline trim and complete escaping (redos + incomplete-sanitization) - #78
Merged
Merged
Conversation
…lynomial-redos, 2 js/incomplete-sanitization) - lib/library.js: replace content.replace(/\n*$/, '\n') with a linear scan (withOneTrailingNewline); same output, no polynomial backtracking. - lib/export.js: markdown table cells escape backslashes before pipes. - public/js/app.js: CSS.escape fallback escapes backslashes as well as quotes. Tests: 2 new cases in existing files.
…ping # Conflicts: # test/unit.test.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the remaining 2
js/polynomial-redosand 2js/incomplete-sanitizationCodeQL alerts (follow-up to #77).Triage
lib/library.jscontent.replace(/\n*$/, '\n')in serializeLibraryFile / serializeInstalledFile (content comes from the library API body)withOneTrailingNewline(); output identical.lib/export.jsmarkdown metadata cell.replace(/|/g, '\|')\(e.g. a Windows cwd) turned|back into a live column separator. Now escapes backslashes first, then pipes (escapeTableCell).public/js/app.jsCSS.escape fallbackid.replace(/"/g, '\\"')CSS.escapeis missing): backslashes weren't escaped. Nowid.replace(/["\\]/g, '\\$&'). Legacy UI is frozen except security fixes; this is one.No dismissals.
Tests (existing files; file count stays 22)
C:\proj|x\rendersC:\\proj\|x\\, every pipe preceded by an odd backslash run.Local evidence (Node 22.23.3)
npm test:# tests 358 # pass 358 # fail 016 machine-checked · 16 ok · 0 failed · 0 error · 3 manual