I have a contentEditable div within which I must allow the user to edit the HTML.
Do I need to sanitize the HTML that the user writes inside this div?
I mean, when I extract HTML from this div, it is already being sanitized. For example, if I wrote something like <> inside a div and then restored it, I would get <> .
Test it here: http://jsfiddle.net/mByWT/
My other question is: is this standard behavior and can I rely on it in all browsers?
EDIT
Now I can conclude that this is a common template:
element.innerHTML returns HTML escape code - it skips < , > amd & , but not quoteselement.innerText and element.textContent returns an HTML literal without escaping
See this: http://jsfiddle.net/2CmjG/
source share