Closed Bug 55508 Opened 25 years ago Closed 25 years ago

XMLExtras: nsIDOMParser::ParseFromStream interface does not work properly without a JavaScript environment

Categories

(Core :: XML, defect, P3)

defect

Tracking

()

VERIFIED FIXED

People

(Reporter: toml, Assigned: vidur)

Details

Attachments

(7 files)

From Bugzilla Helper: User-Agent: Mozilla/4.72 [en] (WinNT; U) BuildID: 2000091312 Using the XMLExtras component nsIDOMParser::ParseFromStream interface from C++ code fails. The reason is that a "baseURI" is required and this is obtained by obtaining a the script environment. The script environment is not present when invoked from C++ and so "baseURI" is not set and the function fails. Reproducible: Always Steps to Reproduce: Actual Results: An exception is generated in the XMLExtras DLL as a result of "baseURI" not being set. Expected Results: The XML document should be parsed successfully. I have provided a testcase and patches to Heikki, Nisheeth and Vidur for a fix to this problem.
Reassigning to vidur & cc myself.
Assignee: nisheeth → vidur
OS: Windows NT → All
Hardware: PC → All
There is a small grammatical error in the comment in nsIDOMParser.idl. You should probably also add your information to the MPL in the beginning of the files you modified, like: * Contributor(s): * Thomas Lendacky <toml@us.ibm.com> Now, that still does not fix ParseFromString when it is not called from JS. Should we worry about that now? If not, r=heikki with the above changes.
Uh, I botched the diff. Delete the part about nsIXMLHttpRequest, that belongs into bug 55599.
The updated patch is more work from Tom (and some corrections from me). The intention is to check in a command line test application as well into the tests directory. I will attach those files as well for complete review/approval. Also, because a new directory needs to be added a change is needed in allmakefiles.sh: Index: allmakefiles.sh =================================================================== RCS file: /cvsroot/mozilla/allmakefiles.sh,v retrieving revision 1.251 diff -u -r1.251 allmakefiles.sh --- allmakefiles.sh 2000/09/27 23:43:54 1.251 +++ allmakefiles.sh 2000/10/20 20:52:44 @@ -902,6 +902,7 @@ extensions/xmlextras/build/Makefile extensions/xmlextras/build/src/Makefile extensions/xmlextras/soap/public/Makefile + extensions/xmlextras/tests/Makefile " ;; xmlterm ) MAKEFILES_extensions="$MAKEFILES_extensions I don't know if we should worry about Mac...
Vidur, I have now added baseURi attribute to the nsIDOMParser interface. If that is available, we use it instead of about:blank. Was this what you had in mind? I also updated the test program to use this. NOTE: The test program crashes on Linux but not on NT with this change. If I take out the call to SetBaseURI() it works fine. #0 0x404a2b7f in nsFileChannel::AsyncRead (this=0x812e830, listener=0x812e7ec, ctxt=0x0) at nsFileChannel.cpp:346 #1 0x404cb86b in NS_OpenURI (aConsumer=0x812e7ec, context=0x0, uri=0x812e6f8, ioService=0x0, loadGroup=0x0, notificationCallbacks=0x0, loadAttributes=0, bufferSegmentSize=0, bufferMaxSize=0) at ../../../dist/include/nsNetUtil.h:185 #2 0x40441846 in nsStreamLoader::Init (this=0x812e7e8, aURL=0x812e6f8, observer=0x812e678, context=0x0, aGroup=0x0, notificationCallbacks=0x0, loadAttributes=0, bufferSegmentSize=0, bufferMaxSize=0) at nsStreamLoader.cpp:47 #3 0x40da8c0d in NS_NewStreamLoader (result=0xbfffea0c, uri=0x812e6f8, observer=0x812e678, context=0x0, loadGroup=0x0, notificationCallbacks=0x0, loadAttributes=0, bufferSegmentSize=0, bufferMaxSize=0) at ../../../../dist/include/nsNetUtil.h:364 #4 0x40b9ce90 in CSSLoaderImpl::LoadSheet (this=0x81097e8, aKey=@0xbfffead0, aData=0x812e678) at nsCSSLoader.cpp:1232 #5 0x40b9d7f4 in CSSLoaderImpl::LoadStyleLink (this=0x81097e8, aElement=0x8120d9c, aURL=0x812dd60, aTitle=@0xbfffeedc, aMedia=@0xbfffee44, aDefaultNameSpaceID=-1, aDocIndex=0, aParserToUnblock=0x80f3e40, aCompleted=@0xbfffeb38, aObserver=0x0) at nsCSSLoader.cpp:1399 #6 0x40c273fa in nsXMLContentSink::ProcessCSSStyleLink (this=0x81096d8, aElement=0x8120d9c, aHref=@0xbfffef74, aAlternate=0, aTitle=@0xbfffeedc, aType=@0xbffff00c, aMedia=@0xbfffee44) at nsXMLContentSink.cpp:1111 #7 0x40c27121 in nsXMLContentSink::ProcessStyleLink (this=0x81096d8, aElement=0x8120d9c, aHref=@0xbfffef74, aAlternate=0, aTitle=@0xbfffeedc, aType=@0xbffff00c, aMedia=@0xbfffee44) at nsXMLContentSink.cpp:1043 #8 0x40c27a30 in nsXMLContentSink::AddProcessingInstruction (this=0x81096d8, aNode=@0xbffff2a8) at nsXMLContentSink.cpp:1162 #9 0x4122dfe6 in CWellFormedDTD::HandleProcessingInstructionToken ( this=0x811f0e0, aToken=0x80f4770) at nsWellFormedDTD.cpp:600 #10 0x4122dd0d in CWellFormedDTD::HandleToken (this=0x811f0e0, aToken=0x80f4770, aParser=0x80f3e40) at nsWellFormedDTD.cpp:518 #11 0x4122d797 in CWellFormedDTD::BuildModel (this=0x811f0e0, aParser=0x80f3e40, aTokenizer=0x811f1a0, anObserver=0x0, aSink=0x81096d8) at nsWellFormedDTD.cpp:258 #12 0x4121cfd2 in nsParser::BuildModel (this=0x80f3e40) at nsParser.cpp:2009 #13 0x4121cd44 in nsParser::ResumeParse (this=0x80f3e40, allowIteration=1, aIsFinalChunk=0) at nsParser.cpp:1890 #14 0x4121db9d in nsParser::OnDataAvailable (this=0x80f3e40, channel=0x80e8690, aContext=0x0, pIStream=0x809d020, sourceOffset=0, aLength=14277) at nsParser.cpp:2342 #15 0x405763ff in nsDOMParser::ParseFromStream (this=0x809d598, stream=0x809d020, charset=0x80543bb "UTF-8", contentLength=14277, contentType=0x80542e3 "text/xml", _retval=0xbffff8cc) at nsDOMParser.cpp:529 #16 0x804c7c9 in main (argc=3, argv=0xbffff934) at TestXMLExtras.cpp:112 #17 0x402d09cb in __libc_start_main (main=0x804c264 <main>, argc=3, argv=0xbffff934, init=0x804b7e8 <_init>, fini=0x8053bc8 <_fini>, rtld_fini=0x4000ae60 <_dl_fini>, stack_end=0xbffff92c) at ../sysdeps/generic/libc-start.c:92
Aw, forget the crash. It does not happen in all cases. I got it trying to open the rights.xml file in the xml tests. I did not see crash with a simple case.
a=vidur on the last set of patches
Checked in on trunk, won't go into branch. Marking fixed.
Status: NEW → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
Marking verified per last comments.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: