Might be a naive question, but I am wondering if I have data that will be sent to the browser - specifically in the value of an input (type="text") (and I can guarantee the value will be double-quoted), is it safe to consider the data sanitized if I merely replace " with \"
I guess it's easier to see code (sorry, PHP). Is this safe given untrusted data?
$name = str_replace('"', '\\"', $name);
echo '<input type="text" name="name" value="' . $name .'" />';
Could multibyte data ruin the party? Does that depend on the page's charset? Anything I'm overlooking?
TIA!