Closed
Bug 361933
Opened 18 years ago
Closed 18 years ago
[FIX]XML serializer should match "encoding" to actual encoding
Categories
(Core :: DOM: Serializers, defect, P1)
Tracking
()
RESOLVED
FIXED
mozilla1.9alpha1
People
(Reporter: bzbarsky, Assigned: bzbarsky)
References
Details
Attachments
(2 files, 2 obsolete files)
9.16 KB,
patch
|
Details | Diff | Splinter Review | |
2.92 KB,
patch
|
Details | Diff | Splinter Review |
Right now if I take an XML document that started out as ISO-8859-1 and serialize it as UTF8, we'll happily serialize encoding="ISO-8859-1" in the XML decl. This seems pretty suboptimal, and in particular causes issues with XMLHttpRequest. See the thread at http://lists.w3.org/Archives/Public/public-webapi/2006Nov/0040.html
I'll aim to fix the underlying bug here and the XMLHttpRequest issue in a separate bug.
Assignee | ||
Updated•18 years ago
|
Priority: -- → P1
Summary: XML serializer should match "encoding" to actual encoding → [FIX]XML serializer should match "encoding" to actual encoding
Target Milestone: --- → mozilla1.9alpha
Assignee | ||
Comment 1•18 years ago
|
||
Attachment #246649 -
Flags: superreview?(bugmail)
Attachment #246649 -
Flags: review?(bugmail)
Comment 3•18 years ago
|
||
Comment on attachment 246649 [details] [diff] [review]
Fix
+ * to a byte stream. If this string is empty and root is
+ * a document, the document's character set will be used.
what happens if I pass an empty string and a non-document root?
Assignee | ||
Comment 4•18 years ago
|
||
We throw. I can document that if desired.
Comment on attachment 246649 [details] [diff] [review]
Fix
>@@ -997,17 +998,23 @@ nsXMLContentSerializer::AppendDocumentSt
>
> if (version.IsEmpty())
> return NS_OK; // A declaration must have version, or there is no decl
>
> NS_NAMED_LITERAL_STRING(endQuote, "\"");
>
> aStr += NS_LITERAL_STRING("<?xml version=\"") + version + endQuote;
>
>- if (!encoding.IsEmpty()) {
>+ if (!mCharset.IsEmpty()) {
>+ aStr += NS_LITERAL_STRING(" encoding=\"") +
>+ NS_ConvertASCIItoUTF16(mCharset) + endQuote;
>+ }
>+ // Otherwise fall back on the document's encoding, I guess...
>+ // Though we don't really expect this to happen.
>+ else if (!encoding.IsEmpty()) {
> aStr += NS_LITERAL_STRING(" encoding=\"") + encoding + endQuote;
> }
Is this fallback ever really right (other than by just pure chance). Would it be better to not put an encoding attribute there at all rather one that's likely wrong?
r/sr=me either way
Attachment #246649 -
Flags: superreview?(bugmail)
Attachment #246649 -
Flags: superreview+
Attachment #246649 -
Flags: review?(bugmail)
Attachment #246649 -
Flags: review+
Assignee | ||
Comment 6•18 years ago
|
||
> Is this fallback ever really right (other than by just pure chance)
Not really. In fact, we shouldn't even end up in this code if that member is empty...
I can just not put the attr there, sure.
Assignee | ||
Comment 7•18 years ago
|
||
Attachment #246649 -
Attachment is obsolete: true
Assignee | ||
Comment 8•18 years ago
|
||
Fixed. I'll try to come up with a unit test for this.
Status: NEW → RESOLVED
Closed: 18 years ago
Flags: in-testsuite?
Resolution: --- → FIXED
Assignee | ||
Comment 9•18 years ago
|
||
This isn't checking that we actually used the specified encoding... I can't quite work out enough about getting non-ASCII data from JS into Gecko in a specified non-UTF8 encoding to do that right this second.
Assignee | ||
Comment 10•18 years ago
|
||
Attachment #247043 -
Attachment is obsolete: true
You need to log in
before you can comment on or make changes to this bug.
Description
•