Skip to content

Instantly share code, notes, and snippets.

@knt
Created January 15, 2014 23:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save knt/8446728 to your computer and use it in GitHub Desktop.
Save knt/8446728 to your computer and use it in GitHub Desktop.
< if content =~ /([^-_.!~*'()a-zA-Z\d;\/?:@&=+$,\[\]]%)/ then
< CGI.unescape(content).gsub(/(<!\[CDATA\[|\]\]>)/,'').strip
< else
< content.gsub(/(<!\[CDATA\[|\]\]>)/,'').strip
< end
---
> if content.respond_to?(:force_encoding) && content.force_encoding("binary") =~ /([^-_.!~*'()a-zA-Z\d;\/?:@&=+$,\[\]]%)/n then
> CGI.unescape(content).gsub(/(<!\[CDATA\[|\]\]>)/,'').strip
> else
> content.gsub(/(<!\[CDATA\[|\]\]>)/,'').strip
> end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment