How to properly escape user-controlled input when it's inserted as a value in JSON object?
<script>
$(document).ready(function() {
new MyObject({
key1: "user_input",
key2: ["user_input1", "user_input2"]
});
});
</script>
How to properly escape user-controlled input when it's inserted as a value in JSON object?
|
|||||
|
http://code.google.com/p/json-sanitizer/ takes JSON-like content and converts it to JSON that is safe to evaluate as JavaScript source code and which can be embedded in HTML For example, given
It preserves several properties:
It can be a good idea to |
|||||||||||||
|