src code

instance method String#stripScripts

String#stripScripts() → String

Strips a string of things that look like an HTML script blocks.

Example

"<p>This is a test.<script>alert("Look, a test!");</script>End of test</p>".stripScripts();
// => "<p>This is a test.End of test</p>"

Caveat User

Note that the processing stripScripts does is good enough for most purposes, but you cannot rely on it for security purposes. If you're processing end-user-supplied content, stripScripts is probably not sufficiently robust to prevent hack attacks.