Closed Bug 332239 Opened 19 years ago Closed 19 years ago

Saved xml content gives xml parsing error in this case

Categories

(Core :: XML, defect, P1)

x86
Windows XP
defect

Tracking

()

RESOLVED FIXED
mozilla1.9alpha1

People

(Reporter: martijn.martijn, Assigned: peterv)

References

Details

(Keywords: regression, testcase)

Attachments

(2 files, 1 obsolete file)

See upcoming testcase. To reproduce: - Open testcase - Save the testcase, with "Save Page As" - Open the saved page Expected result: The saved page should not give an xml parsing error. Actual result: XML parsing error. This regressed between 2005-11-29 and 2005-11-30: http://bonsai.mozilla.org/cvsquery.cgi?treeid=default&module=all&branch=HEAD&branchtype=match&dir=&file=&filetype=match&who=&whotype=match&sortby=Date&hours=2&date=explicit&mindate=2005-11-29+06&maxdate=2005-11-30+07&cvsroot=%2Fcvsroot I guess a regression from bug 301260?
Attached file testcase (deleted) —
The problem is that nsDocumentEncoder::SerializeNodeStart ends up calling nsEncoderNodeFixup::FixupNode, which clones the node. That node gets passed to nsXMLContentSerializer::AppendElementStart but the original node gets passed to nsXMLContentSerializer::AppendElementEnd and so we fail to detect that we need to pop namespaces.
Assignee: xml → peterv
Priority: -- → P1
Target Milestone: --- → mozilla1.9alpha
Hmm... Is that a regression? Or did we do that all along?
Attached patch v1 (obsolete) (deleted) — Splinter Review
This fixes all the problems. The first issue was that AppendElementStart gets the fixed up element, but AppendElementEnd gets the original element and so we fail to pop the namespaces in AppendElementEnd because we look for the wrong owner in the namespace stack. I tried passing the fixed up element into AppendElementEnd instead, but that gets very complicated because AppendElementEnd needs to know if the original element has children to omit the end tag. So I've opted for passing in both original element and fixed up element to AppendElementStart, we can then store the namespaces with the original element. The second issue with the testcase was that it uses XBL and the XBL code copied the xmlns attributes without using the prefix, we ended up with two non-prefixed attributes on the div |xbl="http://www.mozilla.org/xbl"|. There might be other places where we don't use the prefix when setting the attribute.
Attachment #217182 - Flags: superreview?(bzbarsky)
Attachment #217182 - Flags: review?(bzbarsky)
Comment on attachment 217182 [details] [diff] [review] v1 >Index: content/base/public/nsIContentSerializer.h > NS_IMETHOD AppendElementStart(nsIDOMElement *aElement, >- PRBool aHasChildren, >+ nsIDOMElement *aFixedupElement, IID rev? That said, I think I would be happier if we left aElement as the fixed up element and passed in aOriginalElement. That would mean we could avoid changes to most serializer impls, avoid subtly bitrotting any in-flight patches, etc. It would also make the changes much easier to review; right now the fix for this bug is in the part of the code _not_ appearing in this diff... :( >Index: content/xbl/src/nsXBLBinding.cpp >- mBoundElement->SetAttr(namespaceID, name, value2, PR_FALSE); >+ mBoundElement->SetAttr(namespaceID, name, attrName->GetPrefix(), >+ value2, PR_FALSE); So is this needed to fix this bug, or just a nice-to-have? If the former, why?
Attached patch v1.1 (deleted) — Splinter Review
Attachment #217182 - Attachment is obsolete: true
Attachment #217254 - Flags: superreview?(bzbarsky)
Attachment #217254 - Flags: review?(bzbarsky)
Attachment #217182 - Flags: superreview?(bzbarsky)
Attachment #217182 - Flags: review?(bzbarsky)
Comment on attachment 217254 [details] [diff] [review] v1.1 r+sr=bzbarsky; please file a followup to sort out the prefix thing for attribute sets, and another followup to add a regression test for this bug once the document encoder is fully scriptable (that will be fixed in bug 330517).
Attachment #217254 - Flags: superreview?(bzbarsky)
Attachment #217254 - Flags: superreview+
Attachment #217254 - Flags: review?(bzbarsky)
Attachment #217254 - Flags: review+
Status: NEW → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Regression tests bug is bug 333060. The bug for adding assertions about xmlns prefix mapping is bug 333059.
Depends on: 334034
This bug appears to have caused Bug 333229 although I'm not sure how yet :). Backing it out fixes Bug 333229 for me.
Depends on: 333229
No longer depends on: 333229
No longer depends on: 448445
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: