Inconsistency with settings values for input field directly in HTML and via JavaScript.
Here is the example:
<!DOCTYPE html>
<html>
<body>
<input type="text" id="f1" ><br>
<input type="text" id="f2" value="123'134"><br>
<input type="text" id="f3" ><br>
<input type="text" id="f4" value="123\'134"><br>
</body>
</html>
document.getElementById('f1').value = "123'134";
document.getElementById('f3').value = "123\'134";
Run it here
When I set attribute value in HTML, HTML entities are fine, escaped characters are not,
when setting via JavaScript, it is all backwards….
How to handle this?
HTML is parsed as HTML, which has particular rules for escaping, such as the string
'should be interpreted as an apostrophe'character.Likewise, javascript has it’s own (and different) escaping rules, such as the string
\'should be interpreted as an apostrophe'character.