Skip to content

Commit

Permalink
docs(ui): add comments to add context on special characters escaping
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-D committed May 29, 2020
1 parent c828d2a commit 67e8538
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ui/src/helpers/formatConfigExtract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ export default function formatConfigExtract(configError: ConfigError): string {
try {
JSON.parse(configExtract)
} catch (err) {
// Escape special characters to display the config as text, not as HTML
const sanitizedConfigExtract = configExtract
.replace(/[\u00A0-\u9999<>&]/gim, (match) => {
// Replace with the HTML Entity of the character
return `&#${match.charCodeAt(0)};`
})
.replace(/\\\\/g, '\\')
Expand Down

0 comments on commit 67e8538

Please sign in to comment.