WebCore:
authorandersca <andersca@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 Jun 2006 17:46:25 +0000 (17:46 +0000)
committerandersca <andersca@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 Jun 2006 17:46:25 +0000 (17:46 +0000)
2006-06-22  Anders Carlsson  <acarlsson@apple.com>

        Reviewed by Maciej.

        <rdar://problem/4524840> Entities contained in DOCTYPE referenced DTD in XSLT source document are unknown

        * dom/xml_tokenizer.cpp:
        (WebCore::shouldAllowExternalLoad):
        Use correct path for the catalog.

        (WebCore::errorFunc):
        Add error function to keep parser errors from going to the console.

        (WebCore::XMLTokenizer::write):
        Remove if (0 &&)

        (WebCore::XMLTokenizer::end):
        Pass DocLoader to xmlDocPtrForString.

        (WebCore::xmlDocPtrForString):
        * dom/xml_tokenizer.h:
        Add DocLoader argument to xmlDocPtrForString so external DTDs and entities can be loaded.

        * xml/XSLTProcessor.cpp:
        (WebCore::xmlDocPtrFromNode):
        Pass DocLoader to xmlDocPtrForString

LayoutTests:

2006-06-22  Anders Carlsson  <acarlsson@apple.com>

        Reviewed by Maciej.

        <rdar://problem/4524840> Entities contained in DOCTYPE referenced DTD in XSLT source document are unknown

        * fast/xsl/dtd-in-source-document-expected.txt: Added.
        * fast/xsl/dtd-in-source-document.xml: Added.
        * fast/xsl/resources/dtd-in-source-document.dtd: Added.
        * fast/xsl/resources/dtd-in-source-document.xsl: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@14973 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/xsl/dtd-in-source-document-expected.txt [new file with mode: 0644]
LayoutTests/fast/xsl/dtd-in-source-document.xml [new file with mode: 0644]
LayoutTests/fast/xsl/resources/dtd-in-source-document.dtd [new file with mode: 0644]
LayoutTests/fast/xsl/resources/dtd-in-source-document.xsl [new file with mode: 0644]
WebCore/ChangeLog
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/dom/xml_tokenizer.cpp
WebCore/dom/xml_tokenizer.h
WebCore/xml/XSLTProcessor.cpp

index 86767f6bcc766b3b7fe8fcf57406a59beec2d933..1f121061b4c9fac75ca96b0305fe6f975bb669ae 100644 (file)
@@ -1,3 +1,14 @@
+2006-06-22  Anders Carlsson  <acarlsson@apple.com>
+
+        Reviewed by Maciej.
+
+        <rdar://problem/4524840> Entities contained in DOCTYPE referenced DTD in XSLT source document are unknown
+
+        * fast/xsl/dtd-in-source-document-expected.txt: Added.
+        * fast/xsl/dtd-in-source-document.xml: Added.
+        * fast/xsl/resources/dtd-in-source-document.dtd: Added.
+        * fast/xsl/resources/dtd-in-source-document.xsl: Added.
+
 2006-06-21  Justin Garcia  <justin.garcia@apple.com>
 
         Reviewed by levi
diff --git a/LayoutTests/fast/xsl/dtd-in-source-document-expected.txt b/LayoutTests/fast/xsl/dtd-in-source-document-expected.txt
new file mode 100644 (file)
index 0000000..0b05770
--- /dev/null
@@ -0,0 +1,3 @@
+This tests that entities defined in an external DTD referenced to from the source document are replaced correctly. If this test is successful, the text SUCCESS should be shown below.
+SUCCESS
+
diff --git a/LayoutTests/fast/xsl/dtd-in-source-document.xml b/LayoutTests/fast/xsl/dtd-in-source-document.xml
new file mode 100644 (file)
index 0000000..6cd5e43
--- /dev/null
@@ -0,0 +1,4 @@
+<?xml version="1.0"?>
+<!DOCTYPE xml SYSTEM "resources/dtd-in-source-document.dtd">
+<?xml-stylesheet type="text/xsl" href="resources/dtd-in-source-document.xsl"?>
+<TEST>&Result;</TEST>
diff --git a/LayoutTests/fast/xsl/resources/dtd-in-source-document.dtd b/LayoutTests/fast/xsl/resources/dtd-in-source-document.dtd
new file mode 100644 (file)
index 0000000..2765541
--- /dev/null
@@ -0,0 +1 @@
+<!ENTITY Result "SUCCESS">
diff --git a/LayoutTests/fast/xsl/resources/dtd-in-source-document.xsl b/LayoutTests/fast/xsl/resources/dtd-in-source-document.xsl
new file mode 100644 (file)
index 0000000..cf7df9c
--- /dev/null
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+        <xsl:output method="html" encoding="UTF-8" />
+        <xsl:template match="/TEST">
+            
+<html>
+<head>
+    <script>
+        if (window.layoutTestController)
+            layoutTestController.dumpAsText();
+    </script>
+</head>
+<body>
+<div>This tests that entities defined in an external DTD referenced to from the source document are replaced correctly. 
+If this test is successful, the text SUCCESS should be shown below.</div>
+<div><xsl:value-of select="."/></div>
+</body>
+</html>
+</xsl:template>
+</xsl:stylesheet>
index 5589e51d4ff677f27375f181bd3c5af0affc939a..7cbc85f2410e41864b7d53f82d6d470850946841 100644 (file)
@@ -1,3 +1,30 @@
+2006-06-22  Anders Carlsson  <acarlsson@apple.com>
+
+        Reviewed by Maciej.
+
+        <rdar://problem/4524840> Entities contained in DOCTYPE referenced DTD in XSLT source document are unknown
+        
+        * dom/xml_tokenizer.cpp:
+        (WebCore::shouldAllowExternalLoad):
+        Use correct path for the catalog.
+        
+        (WebCore::errorFunc):
+        Add error function to keep parser errors from going to the console.
+        
+        (WebCore::XMLTokenizer::write):
+        Remove if (0 &&)
+        
+        (WebCore::XMLTokenizer::end):
+        Pass DocLoader to xmlDocPtrForString.
+        
+        (WebCore::xmlDocPtrForString):        
+        * dom/xml_tokenizer.h:
+        Add DocLoader argument to xmlDocPtrForString so external DTDs and entities can be loaded.
+        
+        * xml/XSLTProcessor.cpp:
+        (WebCore::xmlDocPtrFromNode):
+        Pass DocLoader to xmlDocPtrForString
+        
 2006-06-21  David Hyatt  <hyatt@apple.com>
 
         Back out -webkit-overlay and just rename it back to overlay.
index 643a6a89ddbb926ad8f9adf1e0c5faf80997bfbd..9118da4a433dd4831fe72acf9606053eb2c276b6 100644 (file)
                FAE04190097596C9000540BE /* SVGImageLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = FAE0418E097596C9000540BE /* SVGImageLoader.h */; };
 /* End PBXBuildFile section */
 
-/* Begin PBXBuildStyle section */
-               4EE83C610A4A0E2600C3AAA3 /* Development */ = {
-                       isa = PBXBuildStyle;
-                       buildSettings = {
-                               COPY_PHASE_STRIP = NO;
-                       };
-                       name = Development;
-               };
-               4EE83C620A4A0E2600C3AAA3 /* Deployment */ = {
-                       isa = PBXBuildStyle;
-                       buildSettings = {
-                               COPY_PHASE_STRIP = YES;
-                       };
-                       name = Deployment;
-               };
-/* End PBXBuildStyle section */
-
 /* Begin PBXContainerItemProxy section */
                DD041FF009D9E3250010AF2A /* PBXContainerItemProxy */ = {
                        isa = PBXContainerItemProxy;
                0867D690FE84028FC02AAC07 /* Project object */ = {
                        isa = PBXProject;
                        buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */;
-                       buildSettings = {
-                       };
-                       buildStyles = (
-                               4EE83C610A4A0E2600C3AAA3 /* Development */,
-                               4EE83C620A4A0E2600C3AAA3 /* Deployment */,
-                       );
                        hasScannedForEncodings = 1;
                        knownRegions = (
                                English,
index 6a7825f236d76ebae850357776122a8711a3aec8..3c7ee4ba4844d4b059f51693ead9f8bfad68e8dc 100644 (file)
 #include <libxml/parserInternals.h>
 #include <wtf/Vector.h>
 
+#ifdef KHTML_XSLT
+#include <libxslt/xslt.h>
+#endif
+
 #if SVG_SUPPORT
 #include "SVGNames.h"
 #include "XLinkNames.h"
@@ -440,7 +444,8 @@ private:
 static bool shouldAllowExternalLoad(const char* inURI)
 {
     DeprecatedString url(inURI);
-    if (url.contains("/etc/catalog")
+
+    if (url.contains("/etc/xml/catalog")
         || url.startsWith("http://www.w3.org/Graphics/SVG")
         || url.startsWith("http://www.w3.org/TR/xhtml"))
         return false;
@@ -485,6 +490,11 @@ static int closeFunc(void * context)
     return 0;
 }
 
+static void errorFunc(void*, const char*, ...)
+{
+    // FIXME: It would be nice to display error messages somewhere.
+}
+
 void setLoaderForLibXMLCallbacks(DocLoader *docLoader)
 {
     globalDocLoader = docLoader;
@@ -612,7 +622,7 @@ bool XMLTokenizer::write(const SegmentedString &s, bool /*appendData*/ )
     if (m_parserStopped || m_sawXSLTransform)
         return false;
     
-    if (0 && m_parserPaused) {
+    if (m_parserPaused) {
         m_pendingSrc.append(s);
         return false;
     }
@@ -1180,7 +1190,7 @@ void XMLTokenizer::initializeParserContext()
 void XMLTokenizer::end()
 {
     if (m_sawXSLTransform) {
-        m_doc->setTransformSource(xmlDocPtrForString(m_originalSourceForTransform, m_doc->URL()));
+        m_doc->setTransformSource(xmlDocPtrForString(m_doc->docLoader(), m_originalSourceForTransform, m_doc->URL()));
         
         m_doc->setParsing(false); // Make the doc think it's done, so it will apply xsl sheets.
         m_doc->updateStyleSelector();
@@ -1316,7 +1326,7 @@ bool XMLTokenizer::isWaitingForScripts() const
 }
 
 #ifdef KHTML_XSLT
-void *xmlDocPtrForString(const DeprecatedString &source, const DeprecatedString &url)
+void *xmlDocPtrForString(DocLoader* docLoader, const DeprecatedString &source, const DeprecatedString &url)
 {
     if (source.isEmpty())
             return 0;
@@ -1325,11 +1335,22 @@ void *xmlDocPtrForString(const DeprecatedString &source, const DeprecatedString
     // good error messages.
     const QChar BOM(0xFEFF);
     const unsigned char BOMHighByte = *reinterpret_cast<const unsigned char *>(&BOM);
+
+    xmlGenericErrorFunc oldErrorFunc = xmlGenericError;
+    void* oldErrorContext = xmlGenericErrorContext;
+    
+    setLoaderForLibXMLCallbacks(docLoader);        
+    xmlSetGenericErrorFunc(0, errorFunc);
+    
     xmlDocPtr sourceDoc = xmlReadMemory(reinterpret_cast<const char *>(source.unicode()),
                                         source.length() * sizeof(QChar),
                                         url.ascii(),
                                         BOMHighByte == 0xFF ? "UTF-16LE" : "UTF-16BE", 
-                                        XML_PARSE_NOCDATA|XML_PARSE_DTDATTR|XML_PARSE_NOENT);
+                                        XSLT_PARSE_OPTIONS);
+    
+    setLoaderForLibXMLCallbacks(0);
+    xmlSetGenericErrorFunc(oldErrorContext, oldErrorFunc);
+    
     return sourceDoc;
 }
 #endif
index 8454a1d63ea394b91d31170c692814aa46e5bb45..80283c7d02fab1deb441d205f7c28be102122984 100644 (file)
@@ -65,7 +65,7 @@ protected:
 
 Tokenizer* newXMLTokenizer(Document*, FrameView* = 0);
 #if KHTML_XSLT
-void* xmlDocPtrForString(const DeprecatedString& source, const DeprecatedString& URL);
+void* xmlDocPtrForString(DocLoader*, const DeprecatedString& source, const DeprecatedString& URL);
 void setLoaderForLibXMLCallbacks(DocLoader*);
 #endif
 HashMap<String, String> parseAttributes(const String&, bool& attrsOK);
index 20b2763bd1a1356f578e5e83c0208c85b3798380..b106df5bbdca47bafcc599e7f357f92fb36f423d 100644 (file)
@@ -264,7 +264,7 @@ static inline xmlDocPtr xmlDocPtrFromNode(Node *sourceNode, bool &shouldDelete)
     if (sourceIsDocument)
         sourceDoc = (xmlDocPtr)ownerDocument->transformSource();
     if (!sourceDoc) {
-        sourceDoc = (xmlDocPtr)xmlDocPtrForString(createMarkup(sourceNode), sourceIsDocument ? ownerDocument->URL() : DeprecatedString());
+        sourceDoc = (xmlDocPtr)xmlDocPtrForString(ownerDocument->docLoader(), createMarkup(sourceNode), sourceIsDocument ? ownerDocument->URL() : DeprecatedString());
         shouldDelete = (sourceDoc != 0);
     }
     return sourceDoc;