-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
escape html #1415
escape html #1415
Conversation
Signed-off-by: Maxence Lange <[email protected]>
/backport to stable27 |
/backport to stable26 |
/backport to stable25 |
return text.toString() | ||
.split('&').join('&') | ||
.split('<').join('<') | ||
.split('>').join('>') | ||
.split('"').join('"') | ||
.split('\'').join('''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return text.toString() | |
.split('&').join('&') | |
.split('<').join('<') | |
.split('>').join('>') | |
.split('"').join('"') | |
.split('\'').join('''); | |
const parser = new DOMParser(); | |
const doc = parser.parseFromString(text, 'text/html'); | |
return doc.body.textContent; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would escape any chars not thought about and handle more edge cases, it however looks okay
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tried it, it removes text within <> which might be excessive :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a similar function is shorter and would handle all edge cases for your testing and consideration but his looks good too! Thanks
No description provided.