Skip to content
Open
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
11 changes: 10 additions & 1 deletion images/chromium-headful/client/src/components/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ interface HTMLAttributes {

interface MarkdownState extends State {}

function escapeAttr(value: string): string {
return value
.replace(/&/g, '&')
.replace(/"/g, '"')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/'/g, '&#x27;')
}

function htmlTag(
tagName: string,
content: string,
Expand All @@ -58,7 +67,7 @@ function htmlTag(
let attributeString = ''
for (const attr in attributes) {
if (Object.prototype.hasOwnProperty.call(attributes, attr) && attributes[attr]) {
attributeString += ` ${attr}="${attributes[attr]}"` // md.sanitizeText(attr)
attributeString += ` ${attr}="${escapeAttr(attributes[attr])}"`
}
}

Expand Down