Skip to content

script.escape

This function is commonly used to sanitize input from users which is then going to form part of a SQL query.

js
script.escape(inputStr)

Parameters

  • inputStr - the string which needs to be escaped/sanitized.

Example

js
let valueForSQL = script.escape("It's usually not ok to have a single quote in a SQL statement.");

The result in valueForSQL will be It\'s usually not ok to have a single quote in a SQL statement. which will no longer break a SQL statement.