Skip to content
Merged
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
18 changes: 12 additions & 6 deletions src/lib/flow-console/reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,18 @@
}

function sanitizeReaderHtml(value: string) {
const body = extractBody(value)
.replace(/<!doctype[^>]*>/gi, '')
.replace(/<head[^>]*>[\s\S]*?<\/head>/gi, '')
.replace(unsafeTagPattern, '')
.replace(unsafeSelfClosingTagPattern, '')
.replace(/<!--[\s\S]*?-->/g, '');
let body = extractBody(value);
let previous: string;

do {
previous = body;
body = body
.replace(/<!doctype[^>]*>/gi, '')
.replace(/<head[^>]*>[\s\S]*?<\/head>/gi, '')
.replace(unsafeTagPattern, '')

Check failure

Code scanning / CodeQL

Incomplete multi-character sanitization High

This string may still contain
<script
, which may cause an HTML element injection vulnerability.
Comment thread
CheFu-code marked this conversation as resolved.
Dismissed
.replace(unsafeSelfClosingTagPattern, '')

Check failure

Code scanning / CodeQL

Incomplete multi-character sanitization High

This string may still contain
<script
, which may cause an HTML element injection vulnerability.
Comment thread
CheFu-code marked this conversation as resolved.
Dismissed
.replace(/<!--[\s\S]*?-->/g, '');
} while (body !== previous);

return body.replace(tagPattern, (match, tagName, rawAttributes) => {
const tag = String(tagName).toLowerCase();
Expand Down
Loading