Skip to content

Instantly share code, notes, and snippets.

@benmmurphy
Created February 1, 2013 15:09
Show Gist options
  • Save benmmurphy/4691852 to your computer and use it in GitHub Desktop.
Save benmmurphy/4691852 to your computer and use it in GitHub Desktop.
escape_js
module ApplicationHelper
def escape_js(str)
str.gsub('<', '\u003C').gsub('>', '\u003E').gsub('&', '\u0026').gsub("\u2028", '\u2028').gsub("\u2029", '\u2029').html_safe
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment