Escape HTML using jQuery [duplicate]

That’s a pretty standard way of doing it, my version used a <div> though: return $(‘<div/>’).text(t).html(); This isn’t technically 100% safe though as Mike Samuel notes but it is probably pretty safe in practice. The current Prototype.js does this: function escapeHTML() { return this.replace(/&/g,’&amp;’).replace(/</g,’&lt;’).replace(/>/g,’&gt;’); } But it used to use the “put text in a … Read more

Best way to escape and unescape strings in Ruby?

Ruby 2.5 added String#undump as a complement to String#dump: $ irb irb(main):001:0> dumped_newline = “\n”.dump => “\”\\n\”” irb(main):002:0> undumped_newline = dumped_newline.undump => “\n” With it: def escape(s) s.dump[1..-2] end def unescape(s) “\”#{s}\””.undump end $irb irb(main):001:0> escape(“\n \” \\”) => “\\n \\\” \\\\” irb(main):002:0> unescape(“\\n \\\” \\\\”) => “\n \” \\”

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)