Skip to content
This repository was archived by the owner on Jul 31, 2022. It is now read-only.

Commit 20e83ef

Browse files
committed
fix: escape response html
1 parent c2c852b commit 20e83ef

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

package-lock.json

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@
242242
"babel-polyfill": "6.26.0",
243243
"capitalize": "^2.0.4",
244244
"dotenv": "^10.0.0",
245+
"escape-html": "^1.0.3",
245246
"graphql": "^15",
246247
"graphql-config": "~4.1.0",
247248
"graphql-language-service-server": "^2.7.7",

src/client/graphql-content-provider.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
WebviewPanel,
1111
WorkspaceFolder,
1212
} from "vscode"
13-
13+
import escapeHtml from "escape-html"
1414
import type { ExtractedTemplateLiteral } from "./source-helper"
1515
import { loadConfig, GraphQLProjectConfig } from "graphql-config"
1616
import { visit, VariableDefinitionNode } from "graphql"
@@ -199,9 +199,9 @@ export class GraphQLContentProvider implements TextDocumentContentProvider {
199199

200200
const updateCallback = (data: string, operation: string) => {
201201
if (operation === "subscription") {
202-
this.html = `<pre>${data}</pre>` + this.html
202+
this.html = `<pre>${escapeHtml(data)}</pre>` + this.html
203203
} else {
204-
this.html += `<pre>${data}</pre>`
204+
this.html += `<pre>${escapeHtml(data)}</pre>`
205205
}
206206
this.update(this.uri)
207207
this.updatePanel()

0 commit comments

Comments
 (0)