Skip to content

fix: replace 100+ unsafe innerHTML assignments with textContent/escap…#6536

Merged
walterbender merged 8 commits intosugarlabs:masterfrom
karthik-dev56:fix-widespread-Innerhtml-300Instances
Apr 11, 2026
Merged

fix: replace 100+ unsafe innerHTML assignments with textContent/escap…#6536
walterbender merged 8 commits intosugarlabs:masterfrom
karthik-dev56:fix-widespread-Innerhtml-300Instances

Conversation

@karthik-dev56
Copy link
Copy Markdown
Contributor

@karthik-dev56 karthik-dev56 commented Apr 10, 2026

Files remediated:

  • musickeyboard.js, phrasemaker.js, temperament.js (HIGH risk)
  • pitchdrummatrix.js, status.js, modewidget.js, pitchslider.js (MEDIUM)
  • pitchstaircase.js, meterwidget.js, rhythmruler.js, timbre.js (MEDIUM)
  • statistics.js, arpeggio.js, sampler.js, jseditor.js (MEDIUM)

Test updates:

  • Added escapeHTML mock to temperament, statistics, meterwidget, status tests
  • Updated status test assertions from innerHTML to textContent

All 4192 tests passing, zero regressions introduced."

@github-actions
Copy link
Copy Markdown
Contributor

❌ Some Jest tests failed. Please check the logs and fix the issues before merging.

Failed Tests:

help.test.js

@github-actions github-actions Bot added bug fix Fixes a bug or incorrect behavior size/L Large: 250-499 lines changed area/javascript Changes to JS source files area/tests Changes to test files labels Apr 10, 2026
@Ashutoshx7
Copy link
Copy Markdown
Contributor

@karthik-dev56 eslint and jest failing

@karthik-dev56 karthik-dev56 force-pushed the fix-widespread-Innerhtml-300Instances branch from b83533e to c4f64b7 Compare April 10, 2026 20:31
@github-actions
Copy link
Copy Markdown
Contributor

✅ All Jest tests passed! This PR is ready to merge.

@karthik-dev56 karthik-dev56 force-pushed the fix-widespread-Innerhtml-300Instances branch from c4f64b7 to 76758f5 Compare April 10, 2026 20:34
@github-actions
Copy link
Copy Markdown
Contributor

✅ All Jest tests passed! This PR is ready to merge.

@Ashutoshx7
Copy link
Copy Markdown
Contributor

matting...
[warn] js/widgets/status.js
[warn] js/widgets/temperament.js
[warn] Code style issues found in 2 files. Run Prettier with --write to fix.
Error: Process completed with exit code 123.

run on these files itself and recommit

@karthik-dev56 karthik-dev56 force-pushed the fix-widespread-Innerhtml-300Instances branch from 76758f5 to 50f5c9e Compare April 10, 2026 20:38
@github-actions
Copy link
Copy Markdown
Contributor

✅ All Jest tests passed! This PR is ready to merge.

@karthik-dev56
Copy link
Copy Markdown
Contributor Author

Hey @Ashutoshx7 Now all test cases has been passed

@karthik-dev56
Copy link
Copy Markdown
Contributor Author

Hey @walterbender please have a look when u have time

@Ashutoshx7
Copy link
Copy Markdown
Contributor

hy yes i am testing it out

@Ashutoshx7
Copy link
Copy Markdown
Contributor

everything is fine
just one thing can u fix Expected '!==' and instead saw '!='
? in few files these has been flagged by ci

@karthik-dev56 karthik-dev56 force-pushed the fix-widespread-Innerhtml-300Instances branch from 50f5c9e to e76906f Compare April 10, 2026 20:59
@github-actions github-actions Bot added size/XL Extra large: 500-999 lines changed and removed size/L Large: 250-499 lines changed labels Apr 10, 2026
@github-actions
Copy link
Copy Markdown
Contributor

❌ Some Jest tests failed. Please check the logs and fix the issues before merging.

Failed Tests:

pitchslider.test.js

@karthik-dev56 karthik-dev56 force-pushed the fix-widespread-Innerhtml-300Instances branch from e76906f to 2b1a328 Compare April 10, 2026 21:04
@github-actions
Copy link
Copy Markdown
Contributor

✅ All Jest tests passed! This PR is ready to merge.

@karthik-dev56
Copy link
Copy Markdown
Contributor Author

Hey @Ashutoshx7 everything is perfect now!

@Ashutoshx7
Copy link
Copy Markdown
Contributor

image still a few lefts

@karthik-dev56 karthik-dev56 force-pushed the fix-widespread-Innerhtml-300Instances branch from 2b1a328 to c9cc63e Compare April 10, 2026 21:24
@github-actions
Copy link
Copy Markdown
Contributor

✅ All Jest tests passed! This PR is ready to merge.

@karthik-dev56
Copy link
Copy Markdown
Contributor Author

@Ashutoshx7 yep its done now!

@karthik-dev56 karthik-dev56 force-pushed the fix-widespread-Innerhtml-300Instances branch from c9cc63e to 5f987c1 Compare April 10, 2026 21:32
@karthik-dev56 karthik-dev56 force-pushed the fix-widespread-Innerhtml-300Instances branch from 5f987c1 to 0292701 Compare April 11, 2026 11:38
@github-actions github-actions Bot added size/XXL XXL: 1000+ lines changed and removed size/XL Extra large: 500-999 lines changed labels Apr 11, 2026
@github-actions
Copy link
Copy Markdown
Contributor

❌ Some Jest tests failed. Please check the logs and fix the issues before merging.

Failed Tests:

status.test.js
temperament.test.js
meterwidget.test.js

@github-actions
Copy link
Copy Markdown
Contributor

❌ Some Jest tests failed. Please check the logs and fix the issues before merging.

Failed Tests:

status.test.js
temperament.test.js
meterwidget.test.js

@github-actions
Copy link
Copy Markdown
Contributor

❌ Some Jest tests failed. Please check the logs and fix the issues before merging.

Failed Tests:

meterwidget.test.js

@github-actions github-actions Bot added the area/docs Changes to documentation label Apr 11, 2026
@github-actions
Copy link
Copy Markdown
Contributor

❌ Some Jest tests failed. Please check the logs and fix the issues before merging.

Failed Tests:

status.test.js
pitchslider.test.js
meterwidget.test.js

@github-actions
Copy link
Copy Markdown
Contributor

✅ All Jest tests passed! This PR is ready to merge.

@github-actions
Copy link
Copy Markdown
Contributor

✅ All Jest tests passed! This PR is ready to merge.

@karthik-dev56
Copy link
Copy Markdown
Contributor Author

OMG!!! fixing this issue was crazy dude

@karthik-dev56
Copy link
Copy Markdown
Contributor Author

Hey @walterbender please have a look when u have time

@walterbender
Copy link
Copy Markdown
Member

A lot to review and test. So far everything checks out, but I am uncertain about several places where you changed:

!= null to !== null

I don't know if those checks were intended to look for undefined as well.

To be safe, maybe we leave those alone?
To be extra safe, maybe instead of changing != undefine to !== undefine, we go with != null ???

@karthik-dev56
Copy link
Copy Markdown
Contributor Author

hey @walterbender I'll revert those specific changes back to != null just to be completely safe and avoid any unintended side effects. Give me a few minutes

@github-actions github-actions Bot added the area/lib Changes to library files label Apr 11, 2026
@github-actions
Copy link
Copy Markdown
Contributor

✅ All Jest tests passed! This PR is ready to merge.

1 similar comment
@github-actions
Copy link
Copy Markdown
Contributor

✅ All Jest tests passed! This PR is ready to merge.

@karthik-dev56
Copy link
Copy Markdown
Contributor Author

Hey @walterbender i have fixed please have a look

@karthik-dev56 karthik-dev56 force-pushed the fix-widespread-Innerhtml-300Instances branch from 1893ee3 to b76a683 Compare April 11, 2026 14:20
@github-actions github-actions Bot removed the area/lib Changes to library files label Apr 11, 2026
@github-actions
Copy link
Copy Markdown
Contributor

✅ All Jest tests passed! This PR is ready to merge.

@karthik-dev56
Copy link
Copy Markdown
Contributor Author

Hey @walterbender I've force-pushed to restore the branch to its clean state, but how would you prefer we handle the != null checks without triggering hundreds of ESLint eqeqeq CI failures

@walterbender walterbender merged commit df7e037 into sugarlabs:master Apr 11, 2026
18 checks passed
@walterbender
Copy link
Copy Markdown
Member

In the future, please keep unrelated changes in a separate PR. This should have been at least 3 different PRs.

@karthik-dev56
Copy link
Copy Markdown
Contributor Author

@walterbender yeah sure i will keep in mind....I enjoyed solving this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/docs Changes to documentation area/javascript Changes to JS source files area/tests Changes to test files bug fix Fixes a bug or incorrect behavior size/XXL XXL: 1000+ lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Security: Widespread innerHTML usage without sanitization across widget files (300+ instances)

4 participants