lib/builder.js
function sanitize(str, len) {
    len = len || 256;
    if (!str || typeof str === 'string' && str.length < 1)
        return str;
    if (typeof str !== 'string' || str.length > len)
        return null;
    return str.replace(/[\0\x08\x09\x1a\n\r"'\\\%]/g, function (char) {
        switch (char) {
            case "\0":
                return "\\0";
            case "\x08":
                return "\\b";
            case "\x09":
                return "\\t";
            case "\x1a":
                return "\\z";
            case "\n":
                return "\\n";
            case "\r":
                return "\\r";
            case "\"":
            case "'":
            case "\\":
            case "%":
                return "\\" + char; // prepends a backslash to backslash, percent,
            // and double/single quotes
        }
    });
}
function sanitize(str, len) {
    len = len || 256;
    if (!str || typeof str === 'string' && str.length < 1)
        return str;
    if (typeof str !== 'string' || str.length > len)
        return null;
    return str.replace(/[\0\x08\x09\x1a\n\r"'\\\%]/g, function (char) {
        switch (char) {
            case "\0":
                return "\\0";
            case "\x08":
                return "\\b";
            case "\x09":
                return "\\t";
            case "\x1a":
                return "\\z";
            case "\n":
                return "\\n";
            case "\r":
                return "\\r";
            case "\"":
            case "'":
            case "\\":
            case "%":
                return "\\" + char; // prepends a backslash to backslash, percent,
            // and double/single quotes
        }
    });
}
function sanitize ( str , len ) { len = len || 256 ; if ( ! str || typeof str === 'string' && str . length < 1 ) return str ; if ( typeof str !== 'string' || str . length > len ) return null ; return str . replace ( / [\0\x08\x09\x1a\n\r"'\\\%] / g , function ( char ) { switch ( char ) { case "\0" : return "\\0" ; case "\x08" : return "\\b" ; case "\x09" : return "\\t" ; case "\x1a" : return "\\z" ; case "\n" : return "\\n" ; case "\r" : return "\\r" ; case "\"" : case "'" : case "\\" : case "%" : return "\\" + char ; // prepends a backslash to backslash, percent, // and double/single quotes } } ) ; }
Sanitize to prevent SQL injections.
@param str
@return {*}
Sanitize to prevent SQL injections .