I'm using backbone, and the general way for passing the collections when the page load is
window.router = new Routers.ManageRouter({store: #{@store.to_json});
which is fine and works well, until someone decides to add the text "<script>alert("owned")</script>
" to one of the store fields. the last </script>
obviously closes the javascript. How can this be circumvented?
:javascript
$(function() {
window.router = new Dotz.Routers.ManageRouter({store: #{@store.to_json}});
Backbone.history.start();
});
The above outputs:
<script>
//<![CDATA[
$(function() {
window.router = new Dotz.Routers.ManageRouter({store: '{"_id":"4f3300e19c2ee41d9a00001c", "points_text":"<script>alert(\"hey\");</script>"'});
Backbone.history.start();
});
//]]>
</script>