-
Notifications
You must be signed in to change notification settings - Fork 17
Add Chrome extension with host/toolbar architecture for viewing Interactive Document files #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: danmarshall <11507384+danmarshall@users.noreply.github.com>
…ntation Co-authored-by: danmarshall <11507384+danmarshall@users.noreply.github.com>
@copilot nice job. Now see that we should use the host/toolbar model that we do in web/frontend and vscode. lets make sure to have all mesasge types in the common project. perhaps you can even resuse some of those instead of creating new ones. the toolbar should enable 'view source', and 'download' |
Co-authored-by: danmarshall <11507384+danmarshall@users.noreply.github.com>
errorDiv.innerHTML = ` | ||
<h3>Error Loading Viewer</h3> | ||
<p>${error.message}</p> | ||
<button onclick="this.parentElement.remove()">Close</button> | ||
`; |
Check warning
Code scanning / CodeQL
Exception text reinterpreted as HTML Medium
Exception text
Exception text
Exception text
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 27 days ago
To fix this vulnerability, the exception message (error.message
) must be HTML-escaped before being inserted into a template string and assigned to innerHTML
. This prevents malicious input from being interpreted as markup or script. A simple HTML-escaping function must be added (e.g., converting <
, >
, &
, "
, and '
to their respective HTML entities). The fix should be inserted in the same file, with the escaping function defined locally or imported if appropriate (preferably local, as we're restricted to code within the shown file). Replace the direct reference to ${error.message}
on line 236 with the escaped version via escapeHtml(error.message)
.
Required changes:
- Add a utility function, e.g.,
escapeHtml(str: string): string
near the top of the file. - During error display (line 236), replace interpolation of
error.message
withescapeHtml(error.message)
.
-
Copy modified lines R6-R15 -
Copy modified line R246
@@ -3,6 +3,16 @@ | ||
* Licensed under the MIT License. | ||
*/ | ||
|
||
// Utility to escape HTML for safe insertion into innerHTML | ||
function escapeHtml(str: string): string { | ||
return str | ||
.replace(/&/g, '&') | ||
.replace(/</g, '<') | ||
.replace(/>/g, '>') | ||
.replace(/"/g, '"') | ||
.replace(/'/g, '''); | ||
} | ||
|
||
// Content script that runs on pages with .idoc files | ||
(function() { | ||
'use strict'; | ||
@@ -233,7 +243,7 @@ | ||
`; | ||
errorDiv.innerHTML = ` | ||
<h3>Error Loading Viewer</h3> | ||
<p>${error.message}</p> | ||
<p>${escapeHtml(error.message)}</p> | ||
<button onclick="this.parentElement.remove()">Close</button> | ||
`; | ||
document.body.appendChild(errorDiv); |
Co-authored-by: danmarshall <11507384+danmarshall@users.noreply.github.com>
I've refactored the Chrome extension to use the host/toolbar model as requested. The changes include:
The toolbar now properly supports viewing source code and downloading files as requested. The implementation follows the established host/toolbar model throughout the codebase. Commit: 52a0fdd |
@copilot can you undo your package-lock, merge main, and then regenerate it? |
…opilot/fix-2a1a315d-3920-477b-ae2a-6148752c1e85 # Please enter a commit message to explain why this merge is necessary, # especially if it merges an updated upstream into a topic branch. # # Lines starting with '#' will be ignored, and an empty message aborts # the commit.
Co-authored-by: danmarshall <11507384+danmarshall@users.noreply.github.com>
The Chrome extension now follows the established host/toolbar architecture and has been properly synchronized with the latest main branch. The package-lock.json has been regenerated to reflect the current dependency state after merging main.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.