ulfben

XSS prevention, attempt 1

Sep 20th, 2013
75
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function wpdt_escape_js($unsafe){
  2.     if(function_exists('json_encode')){ //php 4.
  3.         return json_encode($unsafe);
  4.     }  
  5.     return str_replace('/', '&#x2F;', htmlspecialchars($unsafe, ENT_QUOTES, 'UTF-8')); //escape &<>"' and /
  6. }
RAW Paste Data