Fix for bug 355068 (XSLTProcessor.transformToFragment seems to use only output method "text"). r/sr=sicking, a=beltzner.
authorpeterv@propagandism.org
Sat, 23 Feb 2008 08:03:29 -0800
changeset 12156 c919c136540da35e4338954a272d1e92d36e6c10
parent 12155 c007ea66c20e6e7eceb1db048bb475e74e4d6e8b
child 12157 6cfab85a0cf214f504b6191466f641006a6fc943
push idunknown
push userunknown
push dateunknown
reviewersbeltzner
bugs355068
milestone1.9b4pre
Fix for bug 355068 (XSLTProcessor.transformToFragment seems to use only output method "text"). r/sr=sicking, a=beltzner.
content/xslt/src/xslt/txMozillaStylesheetCompiler.cpp
--- a/content/xslt/src/xslt/txMozillaStylesheetCompiler.cpp
+++ b/content/xslt/src/xslt/txMozillaStylesheetCompiler.cpp
@@ -64,16 +64,17 @@
 #include "nsParserCIID.h"
 #include "txAtoms.h"
 #include "txLog.h"
 #include "txMozillaXSLTProcessor.h"
 #include "txStylesheetCompiler.h"
 #include "txXMLUtils.h"
 #include "nsAttrName.h"
 #include "nsIScriptError.h"
+#include "nsIURL.h"
 
 static NS_DEFINE_CID(kCParserCID, NS_PARSER_CID);
 
 static void
 getSpec(nsIChannel* aChannel, nsAString& aSpec)
 {
     if (!aChannel) {
         return;
@@ -766,19 +767,29 @@ TX_CompileStylesheet(nsINode* aNode, txM
       uri = static_cast<nsIDocument*>(aNode)->GetBaseURI();
     }
     NS_ENSURE_TRUE(uri, NS_ERROR_FAILURE);
     
     nsCAutoString spec;
     uri->GetSpec(spec);
     NS_ConvertUTF8toUTF16 baseURI(spec);
 
-    uri = doc->GetDocumentURI();
+    nsIURI* docUri = doc->GetDocumentURI();
+    NS_ENSURE_TRUE(docUri, NS_ERROR_FAILURE);
+
+    docUri->Clone(getter_AddRefs(uri));
     NS_ENSURE_TRUE(uri, NS_ERROR_FAILURE);
 
+    // We need to remove the ref, a URL with a ref would mean that we have an
+    // embedded stylesheet.
+    nsCOMPtr<nsIURL> url = do_QueryInterface(uri);
+    if (url) {
+        url->SetRef(EmptyCString());
+    }
+
     uri->GetSpec(spec);
     NS_ConvertUTF8toUTF16 stylesheetURI(spec);
 
     nsRefPtr<txSyncCompileObserver> obs =
         new txSyncCompileObserver(aProcessor);
     NS_ENSURE_TRUE(obs, NS_ERROR_OUT_OF_MEMORY);
 
     nsRefPtr<txStylesheetCompiler> compiler =