Skip to content

Instantly share code, notes, and snippets.

@forced-request
Created July 27, 2015 23:37
Show Gist options
  • Save forced-request/00275c928a59c0632315 to your computer and use it in GitHub Desktop.
Save forced-request/00275c928a59c0632315 to your computer and use it in GitHub Desktop.
Using json_encode to prevent JS context XSS
<html>
<body>
<script>
var a = “prefix” + <?= json_encode($_GET['p']); ?> + “suffix”;
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment