Advertisement
ulfben

XSS prevention, attempt 1

Sep 20th, 2013
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.22 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement