Skip to content

Commit

Permalink
Escape correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
verhovsky committed Jan 16, 2024
1 parent b3f4b9a commit 609ffa7
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/extension/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,19 @@ export class Config {
const showRulerCoverage = rootConfig.get("showRulerCoverage") as string;

const makeIcon = (colour: string): string | Uri => {
colour = colour
.trim()
.replaceAll('&', '&')
.replaceAll("'", ''')
.replaceAll('"', '"')
.replaceAll('<', '&lt;')
.replaceAll('>', '&gt;')
.replaceAll('\r\n', '&#13;')
.replace(/[\r\n]/g, '&#13;');
if (!colour) {
return "";
}

colour = colour
.replace('&', '&amp;')
.replace("'", '&apos;')
.replace('"', '&quot;')
.replace('<', '&lt;')
.replace('>', '&gt;')
.replace('\r\n', '&#13;')
.replace(/[\r\n]/g, '&#13;');
const svg = '<svg width="32" height="48" viewPort="0 0 32 48" xmlns="http://www.w3.org/2000/svg"><polygon points="16,0 32,0 32,48 16,48" fill="' + colour + '"/></svg>';

const icon = 'data:image/svg+xml;base64,' + Buffer.from(svg).toString('base64');
Expand Down

0 comments on commit 609ffa7

Please sign in to comment.