Skip to content

Html Entities (→) #81

Answered by stephannv
robacarp asked this question in Q&A
Oct 11, 2024 · 1 comments · 4 replies
Discussion options

You must be logged in to vote

I will investigate this issue. I tried to replicate the Rails behavior:

HTML_ESCAPE = {
  "&" => "&",
  ">" => ">",
  "<" => "&lt;",
  %(") => "&quot;",
  "'" => "&#39;"
}
HTML_ESCAPE_ONCE_REGEXP = /["><']|&(?!([a-zA-Z]+|(#\d+)|(#[xX][\dA-Fa-f]+));)/

value.gsub(HTML_ESCAPE_ONCE_REGEXP, HTML_ESCAPE)

But Blueprint got much more slower than using HTML.escape (on benchmark it went from 8x slower than ECR to 14x slower). I will need tweak some things, eg. use faster escaping for attribute values and use this escape_once behavior for content.

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@stephannv
Comment options

@robacarp
Comment options

@stephannv
Comment options

@robacarp
Comment options

Answer selected by robacarp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants