Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

escape html #1415

Merged
merged 1 commit into from Oct 16, 2023
Merged

escape html #1415

merged 1 commit into from Oct 16, 2023

Conversation

ArtificialOwl
Copy link
Member

No description provided.

Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
@ArtificialOwl
Copy link
Member Author

/backport to stable27

@ArtificialOwl
Copy link
Member Author

/backport to stable26

@ArtificialOwl
Copy link
Member Author

/backport to stable25

Comment on lines +135 to +140
return text.toString()
.split('&').join('&amp;')
.split('<').join('&lt;')
.split('>').join('&gt;')
.split('"').join('&quot;')
.split('\'').join('&#039;');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return text.toString()
.split('&').join('&amp;')
.split('<').join('&lt;')
.split('>').join('&gt;')
.split('"').join('&quot;')
.split('\'').join('&#039;');
const parser = new DOMParser();
const doc = parser.parseFromString(text, 'text/html');
return doc.body.textContent;

Copy link

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

Copy link
Member Author

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 :)

Copy link

@Fenn-CS Fenn-CS left a 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

@ArtificialOwl ArtificialOwl merged commit c71c5c4 into master Oct 16, 2023
9 checks passed
@delete-merged-branch delete-merged-branch bot deleted the fix/noid/escapehtml-inshares branch October 16, 2023 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants