Closed
Bug 292839
Opened 20 years ago
Closed 20 years ago
textarea innerHTML doesn't handle entity references well
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
RESOLVED
FIXED
People
(Reporter: stryker330, Unassigned)
References
Details
(Keywords: testcase)
Attachments
(1 file)
(deleted),
text/html
|
Details |
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8b2) Gecko/20050502 Firefox/1.0+
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8b2) Gecko/20050502 Firefox/1.0+
Suppose a text node with value containing non-text PCDATA (e.g. 'some<br
/>markup') is appended to a textarea element. Then, the text node's contents
are added unescaped/unencoded/unserialized (whatever it's called - the process
of converting '<' to '<', etc.).
Also, the textarea element displays these contents "correctly" unescaped. This
is probably the fallback behavior for invalid textarea contents.
Possible culprits:
- the act of appending the text node to the textarea
- textarea.innerHTML is incorrect (this seems unlikely)
Reproducible: Always
Steps to Reproduce:
1) var textnode = document.createTextNode('some<br />markup');
2) textarea.appendChild(textnode);
3) output textarea.innerHTML
Actual Results:
some<br />markup
Expected Results:
some<br />markup
Reporter | ||
Comment 1•20 years ago
|
||
Comment 2•20 years ago
|
||
The DOM looks correct. Note that the creating/appending a textnode should not
unescape any HTML entities. createTextNode is not an html parser. there's also
no invalid contents involved. (compare the content model created by
data:text/html,<textarea><br/></textarea> )
Sounds to me like innerHTML is broken.
OS: Windows XP → All
Comment 3•20 years ago
|
||
The real problem is in the innerHTML getter and setter for <textarea>... they
try to do the right thing without fully reimplementing the whack parsing that
happens for textareas, but there are corner cases like this it ends up getting
wrong.
I'm pretty sure we have a bug on this already.
Summary: textarea will appendChild text node unescaped/unencoded/unserialized → textarea innerHTML doesn't handle entity references well
Whiteboard: DUPEME
Reporter | ||
Comment 4•20 years ago
|
||
Dupe of bug 215228?
> The DOM looks correct. Note that the creating/appending a textnode should not
> unescape any HTML entities. createTextNode is not an html parser. there's also
> no invalid contents involved. (compare the content model created by
> data:text/html,<textarea><br/></textarea> )
>
> Sounds to me like innerHTML is broken.
Out of curiosity, when exactly are HTML entities supposed to be escaped?
document.createTextNode or node.appendChild or innerHTML(In reply to comment #2)
Comment 5•20 years ago
|
||
> Out of curiosity, when exactly are HTML entities supposed to be escaped?
In general, whenever the data will be parsed by an HTML parser.
Reporter | ||
Comment 6•20 years ago
|
||
I think this got fixed when the fix for bug 152329 was checked in.
You need to log in
before you can comment on or make changes to this bug.
Description
•