Skip to content
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

Applies DOMSanitize.sanitize to innerHTML write #8388

Merged
merged 3 commits into from
Oct 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/plugin-ext/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@
"@theia/timeline": "^1.6.0",
"@theia/workspace": "^1.6.0",
"@types/connect": "^3.4.32",
"@types/dompurify": "^2.0.2",
"@types/mime": "^2.0.1",
"@types/serve-static": "^1.13.3",
"connect": "^3.7.0",
"decompress": "^4.2.1",
"dompurify": "^2.0.11",
"escape-html": "^1.0.3",
"filenamify": "^4.1.0",
"jsonc-parser": "^2.2.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/plugin-ext/src/main/browser/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import URI from '@theia/core/lib/common/uri';
import { Command, CommandService } from '@theia/core/lib/common/command';
import { AbstractDialog } from '@theia/core/lib/browser';
import { WindowService } from '@theia/core/lib/browser/window/window-service';
import * as DOMPurify from 'dompurify';

@injectable()
export class OpenUriCommandHandler {
Expand Down Expand Up @@ -90,7 +91,7 @@ class OpenNewTabDialog extends AbstractDialog<string> {
showOpenNewTabDialog(uri: string): void {
this.value = uri;

this.linkNode.innerHTML = uri;
this.linkNode.innerHTML = DOMPurify.sanitize(uri);
this.linkNode.href = uri;
this.openButton.onclick = () => {
this.windowService.openNewWindow(uri);
Expand Down