fix: replace innerHTML with safer DOM APIs#137
fix: replace innerHTML with safer DOM APIs#137yuvrajangadsingh wants to merge 2 commits intoRocketChat:masterfrom
Conversation
|
@yuvrajangadsingh thanks
Please DO PERFORM these tests that the agent indicated to be necessary - MANUALLY and supply the screen captures accordingly in the PR. ALSO
Wouldn't these two still expose the application to the SAME risk that you pointed out in #136 ???? If so, what good is this PR 🤔 |
|
tested locally. ran the app with leaderboard page:
admin panel:
regarding the 2 layer.js innerHTML instances: checked both files. they are safe:
these are vendored third-party code (layui layer.js v3.1.1 and mobile v2.0.0). the innerHTML calls consume internal config and hardcoded strings, not browser user input. modifying minified vendored code creates maintenance burden with no security benefit. |
|
@Sing-Li screenshots and vendored code analysis added above. let me know if you want me to dig deeper into the layer.js instances or if the explanation checks out. |
|
@yuvrajangadsingh very good work. Please resolve conflict and test one more time manually after. Please use the data file https://github.com/RocketChat/Opensource-Contribution-Leaderboard/blob/master/contrib/rocketchat/gsoc/2025/gsoc2025final.json when testing. |
Switch innerHTML assignments to textContent where content is plain text, and use createElement/appendChild where HTML structure is needed. Closes RocketChat#136
0df6896 to
aabcbfd
Compare
|
conflicts resolved, rebased on latest master. tested again with the gsoc 2025 data file (251 contributors):
ready for merge whenever you are @Sing-Li |



Replaces all
innerHTMLassignments in application code (src/index.jsandadmin/src/index.js) with safer alternatives:textContentwhere the content is plain text (total counts, repo names)createElement+appendChildwhere HTML structure is needed (anchor tags, remove buttons)table.deleteRow()loop instead oftable.innerHTML = table.rows[0].innerHTMLto clear table rows10 instances fixed across 2 files. 2 remaining
innerHTMLhits are in vendored third-party code (admin/src/assets/layer/layer.jsandadmin/src/assets/layer/mobile/layer.js) and left untouched.Closes #136
Server-side e2e tests pass (
node --test, 2/2). Frontend changes are not covered by existing tests. Not tested locally in the browser.AI disclosure: AI-assisted