Is php htmlspecialchars safety for JS?
var jsVar = "<?php echo(str_replace(array("\r\n", "\n","\r"), "\\n",htmlspecialchars($_GET['p'], ENT_QUOTES))); ?>";
How about for multi byte chars?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No. For that you’d use
json_encode(JSON = Javascript notation).htmlspecialcharsescapes characters that have a special meaning in HTML. Javascript literals have other special characters you need to take care of, so HTML escaping doesn’t make sense.