-
-
Notifications
You must be signed in to change notification settings - Fork 138
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
Loofah removes #240
Comments
Hi! This unfortunately is not behavior that Loofah directly controls, it's how libxml2 parses:
although the gumbo parser used by
Because this behavior is inherited from libxml2, there's nothing we can easily do in Nokogiri or Loofah to change it. Note that we're planning to update Loofah to use Nokogiri::HTML5 when it's available: #239 which is blocked on Nokogiri v1.14.0 being released (soon!). |
Thanks for the explanation @flavorjones 👍 It looks like I'll have to hack around it with something like: string = "  != or  "
protected_string = string.gsub(/ /, "PROTECTEDNBSP").gsub(/ /, "PROTECTED160")
Loofah.fragment(protected_string).to_s.gsub(/PROTECTEDNBSP/, " ").gsub(/PROTECTED160/, " ") (Just have to hope that the input doesn't contain PROTECTEDNBSP or PROTECTED160 😬) Any other suggestions would be welcome. Cheers! |
Hello everyone, thanks for the answers! string = "    — « »"
protected_string = string.gsub(/&(.+?);/, '_PROTECTED\1_')
Loofah.fragment(protected_string).to_s.gsub(/_PROTECTED(.+?)_/, '&\1;') |
There are times when
is actually needed. Unfortunately,Loofah
removes them.Could you either make:
Loofah
not remove them at all, orThe text was updated successfully, but these errors were encountered: