Closed Bug 594767 Opened 15 years ago Closed 15 years ago

importNode fails when using a document created with createHTMLDocument

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
Tracking Status
blocking2.0 --- final+

People

(Reporter: sheppy, Assigned: smaug)

References

Details

(Keywords: dev-doc-complete)

Attachments

(4 files)

Attached file Test case
Attempting to import nodes from a document created using createHTMLDocument is failing with NS_ERROR_DOM_PROP_ACCESS_DENIED, code 1010. Attached is a test case.
Seems like there are also other problems with CreateHTMLDocument. Well, at least one. It doesn't seem to mark the created document as data document, if I read the code correctly.
Where is the principal set the the created document?
And seems like .innerHTML doesn't work with created document either.
blocking2.0: --- → ?
So, the create html document doesn't have right principal and documentURI, and it is not marked as datadocument.
Assignee: nobody → Olli.Pettay
Doh! Sorry guys, should have caught this during review.
blocking2.0: ? → final+
The tricky thing is that documentURI should return null, but content sink assumes that it is non null. I could add a hack that nsDocument::GetDocumentURI would return null also when some specific flag is set to document. bool mNullDocument; mDocumentURI could point to about:blank, I think. Ugly and hackish, but what else could be done easily?
Or perhaps I just fix ContentSink. It doesn't seem to use its mDocumentURI in too many places.
What do we do for XML documents created using DOMImplementation? Or HTML documents created using XSLTProcessor?
Comment on attachment 475060 [details] [diff] [review] use the normal way to create data documents Um, this seems to regress something in the testcase test_bug396843.html
Attachment #475060 - Flags: review?(jonas)
Actually, the patch reveals another (small) bug in nsDOMClassInfo.cpp. Since that is trivial to fix, I'll
...fix it in this bug.
Attached patch patchSplinter Review
Fix the testcase. This makes implementation.create*Document().documentURI to work per DOM 3 Core.
Attachment #475184 - Flags: review?(jonas)
And based on testing webkit and opera return null too for documentURI.
Keywords: dev-doc-needed
Are you sure we're not doing any security checks based on the document URI which will behave poorly, i.e. crash or allow things it shouldn't? Haven't we previously made DOM created documents have the URI of creating document?
(In reply to comment #15) > Are you sure we're not doing any security checks based on the document URI > which will behave poorly, i.e. crash or allow things it shouldn't? nsIDocument::GetDocumentURI() clearly says that document uri can be nsnull. And I'd be surprised if any did security checks based on document uri. But I'll check. > Haven't we previously made DOM created documents have the URI of creating > document? DOMParser does that. implementation.createDocument creates about:blank documents.
Attached patch saferSplinter Review
Attachment #476199 - Flags: review?(jonas)
Attachment #475184 - Flags: review?(jonas)
Comment on attachment 476199 [details] [diff] [review] safer >diff --git a/content/xml/document/src/nsXMLDocument.cpp b/content/xml/document/src/nsXMLDocument.cpp >--- a/content/xml/document/src/nsXMLDocument.cpp >+++ b/content/xml/document/src/nsXMLDocument.cpp >@@ -116,19 +116,23 @@ NS_NewDOMDocument(nsIDOMDocument** aInst > nsresult rv; > > *aInstancePtrResult = nsnull; > > nsCOMPtr<nsIDocument> d; > PRBool isHTML = PR_FALSE; > PRBool isXHTML = PR_FALSE; > if (aDoctype) { >- nsAutoString publicId; >+ nsAutoString publicId, name; > aDoctype->GetPublicId(publicId); >- if (publicId.EqualsLiteral("-//W3C//DTD HTML 4.01//EN") || >+ if (publicId.IsEmpty()) { >+ aDoctype->GetName(name); >+ } >+ if (name.EqualsLiteral("html") || >+ publicId.EqualsLiteral("-//W3C//DTD HTML 4.01//EN") || > publicId.EqualsLiteral("-//W3C//DTD HTML 4.01 Frameset//EN") || > publicId.EqualsLiteral("-//W3C//DTD HTML 4.01 Transitional//EN") || > publicId.EqualsLiteral("-//W3C//DTD HTML 4.0//EN") || > publicId.EqualsLiteral("-//W3C//DTD HTML 4.0 Frameset//EN") || > publicId.EqualsLiteral("-//W3C//DTD HTML 4.0 Transitional//EN")) { > rv = NS_NewHTMLDocument(getter_AddRefs(d)); > isHTML = PR_TRUE; > } else if (publicId.EqualsLiteral("-//W3C//DTD XHTML 1.0 Strict//EN") || I don't understand these changes. Are they really related to this bug? Can you point to spec? Looks good otherwise though.
HTML5 requires a specific kind of doctype for createHTMLDocument. That is a part I don't change in ::CreateHTMLDocument, but I just make NS_NewDOMDocument to recognize that doctype.
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
This is now fully documented: https://developer.mozilla.org/En/DOM/DOMImplementation.createHTMLDocument With a working sample and linked to from the appropriate places.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: