Open Bug 86012 Opened 23 years ago Updated 2 years ago

XMLSerializer serializes text/plain documents as HTML; should throw error

Categories

(Core :: XML, defect, P3)

x86
All
defect

Tracking

()

Future

People

(Reporter: myk, Unassigned)

References

Details

Attachments

(3 files)

If I load a document of type "text/plain" into an iframe I can serialize its content using someXMLSerializer.serializeToString(theIFrame.contentDocument), but the strings "<html><head\/><body><pre>" and "</pre></body></html>" are prepended and appended to the document, respectively, and characters with special meaning in HTML like "<", ">", and "&" are replaced by their entities. Steps to Reproduce: 1. Create a web page with an iframe that loads a text/plain document, serializes it, and displays it. 2. Load the web page. Expected Results: document is displayed just as it appears in the iframe. Actual Results: document is displayed with HTML tags around it and HTML entities replacing occurrences of "<", ">", "&".
Priority: -- → P3
Target Milestone: --- → mozilla1.0
Target Milestone: mozilla1.0 → mozilla0.9.9
Hmm... You are really asking for trouble if you serialize non-XML document with XMLSerializer. The text/plain document really is made into an HTML document with those extra elements. You then serialize that. I am inclined to WONTFIX/INVALID this. Best would be if we could find an alternative, better way to do this. You should use the correct serializer for each mime type, or then we'd better make an uber-serializer that can automatically select the correct serializer. I am also inclined to make it so that XMLSerializer would throw and error if it was not an XML document, but I realize I can't do that until there are alternatives.
I will fix this by making the serializer throw error if tried with non-XML document.
Status: NEW → ASSIGNED
No longer depends on: 122301
Summary: XMLSerializer serializes text/plain documents as HTML → XMLSerializer serializes text/plain documents as HTML; should throw error
Attached patch WIP for fix (deleted) — Splinter Review
This patch needs still work. For example, if you create an XML document with script, it will not get a mime type, so this code would incorrectly report and error.
Keywords: mozilla1.0
Target Milestone: mozilla0.9.9 → mozilla1.0
Moving Netscape owned 0.9.9 and 1.0 bugs that don't have an nsbeta1, nsbeta1+, topembed, topembed+, Mozilla0.9.9+ or Mozilla1.0+ keyword. Please send any questions or feedback about this to adt@netscape.com. You can search for "Moving bugs not scheduled for a project" to quickly delete this bugmail.
Target Milestone: mozilla1.0 → mozilla1.2
*** Bug 158616 has been marked as a duplicate of this bug. ***
Depends on: 122301
Target Milestone: mozilla1.2alpha → Future
QA Contact: petersen → rakeshmishra
QA Contact: rakeshmishra → ashishbhatt
(In reply to comment #0) > If I load a document of type "text/plain" into an iframe I can serialize its > content using someXMLSerializer.serializeToString(theIFrame.contentDocument), > but the strings "<html><head\/><body><pre>" and "</pre></body></html>" are > prepended and appended to the document, respectively, and characters with > special meaning in HTML like "<", ">", and "&" are replaced by their entities. > > Steps to Reproduce: > > 1. Create a web page with an iframe that loads a text/plain document, serializes > it, and displays it. > 2. Load the web page. > > Expected Results: document is displayed just as it appears in the iframe. > Actual Results: document is displayed with HTML tags around it and HTML entities > replacing occurrences of "<", ">", "&". This bug is in Firefox 1.5.0.6
QA Contact: ashshbhatt → xml
Could we have a testcase, to see if this is still the case in the current trunk (3.7 Alpha 1)
No longer depends on: 122301
Assignee: hjtoi-bugzilla → nobody
Status: ASSIGNED → NEW
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: