This week we're recreating a PHP function that is extremely important for sanitizing user input. All HTML/ASP/PHP tags are stripped outright; there is no support for a whitelist of allowed tags. A whitelist can be very dangerous without much more rigorous testing to check for script-related exploits. A safer solution would be to force the user to use something like UBB code or Markdown and convert to HTML on the backend.
ASP
function strip_tags(unsafeString)dim regExset regEx = new RegExpwith regEx.Global = true.IgnoreCase = true.Pattern = "(\<(/?[^\>]+)\>)"end withstrip_tags = regEx.Replace(unsafeString, "")set regEx = nothingend function

No comments:
Post a Comment