/ Published in: ASP
URL: http://reusablecode.blogspot.com/2009/02/add-and-strip-slashes.html
ASP implementation on the PHP functions by the same name, but with support for more problematic characters.
Expand |
Embed | Plain Text
<% ' Copyright (c) 2009, reusablecode.blogspot.com; some rights reserved. ' ' This work is licensed under the Creative Commons Attribution License. To view ' a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or ' send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California ' 94305, USA. ' Despite the identical naming, these functions are more comprehensive than their PHP equivalents. ' They go above and beyond even mysql_real_escape_string(), by including support for backspace and horizontal tab. ' List of characters handled: ' \000 null ' \010 backspace ' \011 horizontal tab ' \012 new line ' \015 carriage return ' \032 substitute ' \042 double quote ' \047 single quote ' \134 backslash ' \140 grave accent ' Returns a string with backslashes before characters that need to be quoted in database queries function addslashes(unsafeString) dim regEx set regEx = new RegExp with regEx .Global = true .IgnoreCase = true .Pattern = "([\000\010\011\012\015\032\042\047\134\140])" end with addslashes = regEx.replace(unsafeString, "\$1") set regEx = nothing end function ' Un-quote string quoted with addslashes() function stripslashes(safeString) dim regEx set regEx = new RegExp with regEx .Global = true .IgnoreCase = true .Pattern = "\\([\000\010\011\012\015\032\042\047\134\140])" end with stripslashes = regEx.replace(safeString, "$1") set regEx = nothing end function %>
You need to login to post a comment.
