|
1 | | -import {WaterfallEntry} from "../../typing/waterfall"; |
2 | | -import {getKeys, KvTuple} from "./extract-details-keys"; |
| 1 | +import { WaterfallEntry } from "../../typing/waterfall"; |
| 2 | +import { getKeys, KvTuple } from "./extract-details-keys"; |
3 | 3 |
|
4 | 4 | function makeDefinitionList(dlKeyValues: KvTuple[], addClass: boolean = false) { |
5 | 5 | let makeClass = (key: string) => { |
@@ -76,6 +76,15 @@ function makeTabBtn(name: string, tab: string) { |
76 | 76 | return !!tab ? `<li><button class="tab-button">${name}</button></li>` : ""; |
77 | 77 | } |
78 | 78 |
|
| 79 | +function escapeHtml(unsafe) { |
| 80 | + return unsafe |
| 81 | + .replace(/&/g, "&") |
| 82 | + .replace(/</g, "<") |
| 83 | + .replace(/>/g, ">") |
| 84 | + .replace(/"/g, """) |
| 85 | + .replace(/'/g, "'"); |
| 86 | +} |
| 87 | + |
79 | 88 | export function createDetailsBody(requestID: number, entry: WaterfallEntry, accordeonHeight: number) { |
80 | 89 |
|
81 | 90 | let html = document.createElement("html") as HTMLHtmlElement; |
@@ -129,7 +138,7 @@ export function createDetailsBody(requestID: number, entry: WaterfallEntry, acco |
129 | 138 | </div> |
130 | 139 | ${timingsTab} |
131 | 140 | <div class="tab raw-data"> |
132 | | - <pre><code>${JSON.stringify(entry.rawResource, null, 2)}</code></pre> |
| 141 | + <pre><code>${escapeHtml(JSON.stringify(entry.rawResource, null, 2))}</code></pre> |
133 | 142 | </div> |
134 | 143 | ${imgTab} |
135 | 144 | </div> |
|
0 commit comments