-
Notifications
You must be signed in to change notification settings - Fork 96
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
Applying strip_html filter to escaped html will unescape the string #306
Comments
This happened because we use Jsoup library for stripping html, while the Ruby's implementation is simple and naive: STRIP_HTML_BLOCKS = Regexp.union(
/<script.*?<\/script>/m,
/<!--.*?-->/m,
/<style.*?<\/style>/m
)
STRIP_HTML_TAGS = /<.*?>/m
def strip_html(input)
empty = ''
result = input.to_s.gsub(STRIP_HTML_BLOCKS, empty)
result.gsub!(STRIP_HTML_TAGS, empty)
result
end And we probably should go naive implementation too |
Will it be safer? |
Fixed in <dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.15.3</version>
</dependency> As for this library the Jsoup has single use here. |
very much appreciate the fix here! Now that the fix is in place though, is there any other way to unescape strings at this point? |
@ugenl probably not. as unescaping is destructive operation - you never know which symbol before unescaping was represented via escape sequence and which not. |
yeah, fair enough - and people can directly substitute via |
Encountered this on liqp 0.9, though it could go further back.
Ex.
{{ "<em>test</em>" | escape }}
--><em>test</em>
{{ "<em>test</em>" | escape | strip_html }}
--><em>test</em>
The text was updated successfully, but these errors were encountered: