-
The crystal HTML.escape which blueprint uses isn't as smart as it could be. It'll stubbornly re-escape things which are already escaped:
Rails provides something clever which will only escape things which don't appear to already be escaped:
This functionality exists on top of the ruby escape functionality, which is almost certainly what Crystal's is based off of. For now, I'm able to render an html entity manually in blueprint with |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
I will investigate this issue. I tried to replicate the Rails behavior: HTML_ESCAPE = {
"&" => "&",
">" => ">",
"<" => "<",
%(") => """,
"'" => "'"
}
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. |
Beta Was this translation helpful? Give feedback.
I will investigate this issue. I tried to replicate the Rails behavior:
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.