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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add escape_html_once and escape_html_once_as_safe_html #80

Merged
merged 1 commit into from
Jun 7, 2022

Conversation

casperisfine
Copy link

@casperisfine casperisfine commented Jun 7, 2022

Rebased version of #76
Fix: #76

This is a port of ActiveSupport's ERB::Util.html_escape_once method, which uses this regex to match characters that need encoding, while ignoring existing complete HTML entities.

I re-did the benchmark, I think the perf difference makes it still relevant:

Comparison:
EscapeUtils.escape_html_once:     2056.0 i/s
ERB::Util.html_escape_once:      148.3 i/s - 13.86x  (± 0.00) slower

@byroot byroot merged commit e93cf76 into brianmario:master Jun 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants