Imagine a user inputs the following into a form:
I'd like to "eat" something.
The phrase contains both a single '
and two "
's. If I were to write this direcly as a JS string I'd have to escape the '
to prevent my string from terminating early:
var phrase = 'I\'d like to "eat" something'
What is the behavior of the browser when a user (or potentially malicious actor) inputs a '
or "
into a form and saves it to a var? Will the characters be automatically escaped?
EDIT 16/04/14: Reworded the question.