Skip to content

Commit e1a1687

Browse files
paulirishThiago Perrotta
andauthored
sanitize some unescaped HTML from CDP (#202)
Co-authored-by: Thiago Perrotta <tperrotta@chromium.org>
1 parent 03a1a80 commit e1a1687

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

pages/domainGenerator.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ const itemSort = (a, b) => {
1515
return (a.name || a.id).localeCompare(b.name || b.id);
1616
};
1717

18+
// This handles a few weird cases of raw HTML or over-escaping in the protocol JSON
19+
function parseSafeMarkdown(mdText) {
20+
// Inline codeblocks to doublecheck: IO.StreamHandle, Preload.PreloadingAttemptSource, Preload.RuleSet > backendNodeId, Accessibility.AXValueSource > nativeSource
21+
mdText = mdText.replaceAll('<', '&lt;').replaceAll('>', '&gt;');
22+
const html = marked(mdText, {escape: true});
23+
return html.replaceAll('&amp;lt;', '&lt;').replaceAll('&amp;gt;', '&gt;');
24+
}
25+
1826
export class DomainGenerator {
1927
constructor(version) {
2028
this.version = version;
@@ -48,7 +56,7 @@ export class DomainGenerator {
4856
// Some params have an emum: e.g. Debugger.continueToLocation
4957
return html`
5058
<div class="details-description">
51-
${description ? marked(description) : ''}
59+
${description ? parseSafeMarkdown(description) : ''}
5260
${item ? this.enumDetails(item) : ''}
5361
</div>
5462
`;

0 commit comments

Comments
 (0)