From 24b2d56b7ecb020a2bae85d512162dd1e91c2ff7 Mon Sep 17 00:00:00 2001 From: "loadrunner%betak.net" Date: Tue, 9 Oct 2001 10:15:06 +0000 Subject: [PATCH] bug 88155, Trunk & M094 crash [@ MSVCRT.DLL - ns4xPluginStreamListener::OnDataAvailable, nsPluginStreamListenerPeer::OnDataAvailable] - seg faults loading http://www.planetjulie.com/, r=av, peterl, sr=waterson git-svn-id: svn://10.0.0.236/trunk@104907 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/generic/nsObjectFrame.cpp | 39 ++++++++++++++----- mozilla/layout/generic/nsObjectFrame.h | 4 ++ .../layout/html/base/src/nsObjectFrame.cpp | 39 ++++++++++++++----- mozilla/layout/html/base/src/nsObjectFrame.h | 4 ++ 4 files changed, 66 insertions(+), 20 deletions(-) diff --git a/mozilla/layout/generic/nsObjectFrame.cpp b/mozilla/layout/generic/nsObjectFrame.cpp index b14d1e188e9..fab6eff72e6 100644 --- a/mozilla/layout/generic/nsObjectFrame.cpp +++ b/mozilla/layout/generic/nsObjectFrame.cpp @@ -92,6 +92,7 @@ #include "npapi.h" #include "nsIPrintOptions.h" #include "nsGfxCIID.h" +#include "nsHTMLUtils.h" static NS_DEFINE_CID(kPrintOptionsCID, NS_PRINTOPTIONS_CID); // headers for plugin scriptability @@ -852,6 +853,27 @@ nsObjectFrame::GetDesiredSize(nsIPresContext* aPresContext, } } +nsresult +nsObjectFrame::MakeAbsoluteURL(nsIURI* *aFullURI, + nsString aSrc, + nsIURI* aBaseURI) +{ + nsresult rv; + nsCOMPtr document; + rv = mInstanceOwner->GetDocument(getter_AddRefs(document)); + + //trim leading and trailing whitespace + aSrc.Trim("\b\t\r\n ", PR_TRUE, PR_TRUE, PR_FALSE); + + //create properly encoded absolute URI using the document charset + nsXPIDLCString encodedURI; + rv = NS_MakeAbsoluteURIWithCharset(getter_Copies(encodedURI), + aSrc, document, aBaseURI, + nsHTMLUtils::IOService, + nsHTMLUtils::CharsetMgr); + rv = NS_NewURI(aFullURI, encodedURI, aBaseURI); + return rv; +} #define JAVA_CLASS_ID "8AD9C840-044E-11D1-B3E9-00805F499D93" @@ -921,7 +943,7 @@ nsObjectFrame::Reflow(nsIPresContext* aPresContext, mContent->GetAttr(kNameSpaceID_HTML, nsHTMLAtoms::codebase, codeBase)) && !bJavaPluginClsid) { nsCOMPtr codeBaseURL; - rv = NS_NewURI(getter_AddRefs(codeBaseURL), codeBase, baseURL); + rv = MakeAbsoluteURL(getter_AddRefs(codeBaseURL), codeBase, baseURL); if (NS_SUCCEEDED(rv)) { baseURL = codeBaseURL; } @@ -929,7 +951,7 @@ nsObjectFrame::Reflow(nsIPresContext* aPresContext, // Create an absolute URL if(bJavaPluginClsid) { - rv = NS_NewURI(getter_AddRefs(fullURL), classid, baseURL); + rv = MakeAbsoluteURL(getter_AddRefs(fullURL), classid, baseURL); } else fullURL = baseURL; @@ -958,7 +980,7 @@ nsObjectFrame::Reflow(nsIPresContext* aPresContext, nsAutoString codeBase; if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttr(kNameSpaceID_HTML, nsHTMLAtoms::codebase, codeBase)) { nsCOMPtr codeBaseURL; - rv = NS_NewURI(getter_AddRefs(fullURL), codeBase, baseURL); + rv = MakeAbsoluteURL(getter_AddRefs(fullURL), codeBase, baseURL); if (NS_SUCCEEDED(rv)) { baseURL = codeBaseURL; } @@ -1005,14 +1027,13 @@ nsObjectFrame::Reflow(nsIPresContext* aPresContext, nsAutoString codeBase; if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttr(kNameSpaceID_HTML, nsHTMLAtoms::codebase, codeBase)) { nsCOMPtr codeBaseURL; - rv = NS_NewURI(getter_AddRefs(codeBaseURL), codeBase, baseURL); + rv = MakeAbsoluteURL(getter_AddRefs(codeBaseURL), codeBase, baseURL); if(rv == NS_OK) { baseURL = codeBaseURL; } } - // Create an absolute URL - rv = NS_NewURI(getter_AddRefs(fullURL), src, baseURL); + rv = MakeAbsoluteURL(getter_AddRefs(fullURL), src, baseURL); } else fullURL = baseURL; @@ -1030,9 +1051,8 @@ nsObjectFrame::Reflow(nsIPresContext* aPresContext, //stream in the object source if there is one... if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttr(kNameSpaceID_HTML, nsHTMLAtoms::src, src)) { - src.Trim("\b\t\r\n ", PR_TRUE, PR_TRUE, PR_FALSE); // trim leading and trailing whitespace // Create an absolute URL - rv = NS_NewURI(getter_AddRefs(fullURL), src, baseURL); + rv = MakeAbsoluteURL(getter_AddRefs(fullURL), src, baseURL); if (NS_FAILED(rv)) { // Failed to create URI, maybe because we didn't // reconize the protocol handler ==> treat like @@ -1042,9 +1062,8 @@ nsObjectFrame::Reflow(nsIPresContext* aPresContext, } else if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttr(kNameSpaceID_HTML, nsHTMLAtoms::data, src)) { - src.Trim("\b\t\r\n ", PR_TRUE, PR_TRUE, PR_FALSE); // trim leading and trailing whitespace // Create an absolute URL - rv = NS_NewURI(getter_AddRefs(fullURL), src, baseURL); + rv = MakeAbsoluteURL(getter_AddRefs(fullURL), src, baseURL); if (NS_FAILED(rv)) { // Failed to create URI, maybe because we didn't // reconize the protocol handler ==> treat like diff --git a/mozilla/layout/generic/nsObjectFrame.h b/mozilla/layout/generic/nsObjectFrame.h index 15386ae87fd..93407acd9a2 100644 --- a/mozilla/layout/generic/nsObjectFrame.h +++ b/mozilla/layout/generic/nsObjectFrame.h @@ -91,6 +91,10 @@ public: nsISupports* aSubContent); NS_IMETHOD GetPluginInstance(nsIPluginInstance*& aPluginInstance); + //i18n helper + nsresult MakeAbsoluteURL(nsIURI* *aFullURI, + nsString aSrc, + nsIURI* aBaseURI); //local methods nsresult CreateWidget(nsIPresContext* aPresContext, nscoord aWidth, diff --git a/mozilla/layout/html/base/src/nsObjectFrame.cpp b/mozilla/layout/html/base/src/nsObjectFrame.cpp index b14d1e188e9..fab6eff72e6 100644 --- a/mozilla/layout/html/base/src/nsObjectFrame.cpp +++ b/mozilla/layout/html/base/src/nsObjectFrame.cpp @@ -92,6 +92,7 @@ #include "npapi.h" #include "nsIPrintOptions.h" #include "nsGfxCIID.h" +#include "nsHTMLUtils.h" static NS_DEFINE_CID(kPrintOptionsCID, NS_PRINTOPTIONS_CID); // headers for plugin scriptability @@ -852,6 +853,27 @@ nsObjectFrame::GetDesiredSize(nsIPresContext* aPresContext, } } +nsresult +nsObjectFrame::MakeAbsoluteURL(nsIURI* *aFullURI, + nsString aSrc, + nsIURI* aBaseURI) +{ + nsresult rv; + nsCOMPtr document; + rv = mInstanceOwner->GetDocument(getter_AddRefs(document)); + + //trim leading and trailing whitespace + aSrc.Trim("\b\t\r\n ", PR_TRUE, PR_TRUE, PR_FALSE); + + //create properly encoded absolute URI using the document charset + nsXPIDLCString encodedURI; + rv = NS_MakeAbsoluteURIWithCharset(getter_Copies(encodedURI), + aSrc, document, aBaseURI, + nsHTMLUtils::IOService, + nsHTMLUtils::CharsetMgr); + rv = NS_NewURI(aFullURI, encodedURI, aBaseURI); + return rv; +} #define JAVA_CLASS_ID "8AD9C840-044E-11D1-B3E9-00805F499D93" @@ -921,7 +943,7 @@ nsObjectFrame::Reflow(nsIPresContext* aPresContext, mContent->GetAttr(kNameSpaceID_HTML, nsHTMLAtoms::codebase, codeBase)) && !bJavaPluginClsid) { nsCOMPtr codeBaseURL; - rv = NS_NewURI(getter_AddRefs(codeBaseURL), codeBase, baseURL); + rv = MakeAbsoluteURL(getter_AddRefs(codeBaseURL), codeBase, baseURL); if (NS_SUCCEEDED(rv)) { baseURL = codeBaseURL; } @@ -929,7 +951,7 @@ nsObjectFrame::Reflow(nsIPresContext* aPresContext, // Create an absolute URL if(bJavaPluginClsid) { - rv = NS_NewURI(getter_AddRefs(fullURL), classid, baseURL); + rv = MakeAbsoluteURL(getter_AddRefs(fullURL), classid, baseURL); } else fullURL = baseURL; @@ -958,7 +980,7 @@ nsObjectFrame::Reflow(nsIPresContext* aPresContext, nsAutoString codeBase; if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttr(kNameSpaceID_HTML, nsHTMLAtoms::codebase, codeBase)) { nsCOMPtr codeBaseURL; - rv = NS_NewURI(getter_AddRefs(fullURL), codeBase, baseURL); + rv = MakeAbsoluteURL(getter_AddRefs(fullURL), codeBase, baseURL); if (NS_SUCCEEDED(rv)) { baseURL = codeBaseURL; } @@ -1005,14 +1027,13 @@ nsObjectFrame::Reflow(nsIPresContext* aPresContext, nsAutoString codeBase; if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttr(kNameSpaceID_HTML, nsHTMLAtoms::codebase, codeBase)) { nsCOMPtr codeBaseURL; - rv = NS_NewURI(getter_AddRefs(codeBaseURL), codeBase, baseURL); + rv = MakeAbsoluteURL(getter_AddRefs(codeBaseURL), codeBase, baseURL); if(rv == NS_OK) { baseURL = codeBaseURL; } } - // Create an absolute URL - rv = NS_NewURI(getter_AddRefs(fullURL), src, baseURL); + rv = MakeAbsoluteURL(getter_AddRefs(fullURL), src, baseURL); } else fullURL = baseURL; @@ -1030,9 +1051,8 @@ nsObjectFrame::Reflow(nsIPresContext* aPresContext, //stream in the object source if there is one... if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttr(kNameSpaceID_HTML, nsHTMLAtoms::src, src)) { - src.Trim("\b\t\r\n ", PR_TRUE, PR_TRUE, PR_FALSE); // trim leading and trailing whitespace // Create an absolute URL - rv = NS_NewURI(getter_AddRefs(fullURL), src, baseURL); + rv = MakeAbsoluteURL(getter_AddRefs(fullURL), src, baseURL); if (NS_FAILED(rv)) { // Failed to create URI, maybe because we didn't // reconize the protocol handler ==> treat like @@ -1042,9 +1062,8 @@ nsObjectFrame::Reflow(nsIPresContext* aPresContext, } else if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttr(kNameSpaceID_HTML, nsHTMLAtoms::data, src)) { - src.Trim("\b\t\r\n ", PR_TRUE, PR_TRUE, PR_FALSE); // trim leading and trailing whitespace // Create an absolute URL - rv = NS_NewURI(getter_AddRefs(fullURL), src, baseURL); + rv = MakeAbsoluteURL(getter_AddRefs(fullURL), src, baseURL); if (NS_FAILED(rv)) { // Failed to create URI, maybe because we didn't // reconize the protocol handler ==> treat like diff --git a/mozilla/layout/html/base/src/nsObjectFrame.h b/mozilla/layout/html/base/src/nsObjectFrame.h index 15386ae87fd..93407acd9a2 100644 --- a/mozilla/layout/html/base/src/nsObjectFrame.h +++ b/mozilla/layout/html/base/src/nsObjectFrame.h @@ -91,6 +91,10 @@ public: nsISupports* aSubContent); NS_IMETHOD GetPluginInstance(nsIPluginInstance*& aPluginInstance); + //i18n helper + nsresult MakeAbsoluteURL(nsIURI* *aFullURI, + nsString aSrc, + nsIURI* aBaseURI); //local methods nsresult CreateWidget(nsIPresContext* aPresContext, nscoord aWidth,