fix bug #125265 about entities breaking exsl:tokenize and exsl:split
authorDaniel Veillard <veillard@src.gnome.org>
Sat, 1 Nov 2003 06:45:21 +0000 (06:45 +0000)
committerDaniel Veillard <veillard@src.gnome.org>
Sat, 1 Nov 2003 06:45:21 +0000 (06:45 +0000)
* libexslt/strings.c: fix bug #125265 about entities breaking
  exsl:tokenize and exsl:split
* tests/exslt/strings/split.1.* tests/exslt/strings/tokenize.1.*:
  augmented the reression tests with the example from the bug report.
Daniel

ChangeLog
libexslt/strings.c
tests/exslt/strings/split.1.out
tests/exslt/strings/split.1.xsl
tests/exslt/strings/tokenize.1.out
tests/exslt/strings/tokenize.1.xsl

index 5944dab..1367469 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Sat Nov  1 07:41:06 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+       * libexslt/strings.c: fix bug #125265 about entities breaking
+         exsl:tokenize and exsl:split
+       * tests/exslt/strings/split.1.* tests/exslt/strings/tokenize.1.*:
+         augmented the reression tests with the example from the bug report.
+
 Fri Oct 31 20:26:04 CET 2003 Daniel Veillard <daniel@veillard.com>
 
        * libxslt/preproc.c: fix bug #120828 make sure that xsl:sort is
index c092819..9acfee9 100644 (file)
@@ -83,9 +83,9 @@ exsltStrTokenizeFunction(xmlXPathParserContextPtr ctxt, int nargs)
                             break;
                         }
                         *cur = 0;
-                        node = xmlNewChild((xmlNodePtr) container, NULL,
-                                           (const xmlChar *) "token",
-                                           token);
+                        node = xmlNewDocRawNode(container, NULL,
+                                           (const xmlChar *) "token", token);
+                       xmlAddChild((xmlNodePtr) container, node);
                        xmlXPathNodeSetAddUnique(ret->nodesetval, node);
                         *cur = *delimiter;
                         token = cur + 1;
@@ -172,9 +172,9 @@ exsltStrSplitFunction(xmlXPathParserContextPtr ctxt, int nargs) {
                    if (cur != token) {
                        xmlChar tmp = *cur;
                        *cur = 0;
-                       node = xmlNewChild((xmlNodePtr) container, NULL,
-                                          (const xmlChar *) "token",
-                                          token);
+                        node = xmlNewDocRawNode(container, NULL,
+                                           (const xmlChar *) "token", token);
+                       xmlAddChild((xmlNodePtr) container, node);
                        xmlXPathNodeSetAddUnique(ret->nodesetval, node);
                        *cur = tmp;
                        token++;
@@ -188,9 +188,9 @@ exsltStrSplitFunction(xmlXPathParserContextPtr ctxt, int nargs) {
                        continue;
                    }
                    *cur = 0;
-                   node = xmlNewChild((xmlNodePtr) container, NULL,
-                                      (const xmlChar *) "token",
-                                      token);
+                   node = xmlNewDocRawNode(container, NULL,
+                                      (const xmlChar *) "token", token);
+                   xmlAddChild((xmlNodePtr) container, node);
                    xmlXPathNodeSetAddUnique(ret->nodesetval, node);
                    *cur = *delimiter;
                    cur = cur + delimiterLength - 1;
@@ -198,9 +198,9 @@ exsltStrSplitFunction(xmlXPathParserContextPtr ctxt, int nargs) {
                 }
             }
            if (token != cur) {
-               node =
-                   xmlNewChild((xmlNodePtr) container, NULL,
-                               (const xmlChar *) "token", token);
+               node = xmlNewDocRawNode(container, NULL,
+                                  (const xmlChar *) "token", token);
+               xmlAddChild((xmlNodePtr) container, node);
                xmlXPathNodeSetAddUnique(ret->nodesetval, node);
            }
         }
index 9166a2c..1fbb470 100644 (file)
@@ -10,4 +10,7 @@
        <token>f</token><token>o</token><token>o</token><token>b</token><token>a</token><token>r</token>
 
        str:split('-*- hello - world -*-', '-')
-       <token>*</token><token> hello </token><token> world </token><token>*</token></out>
+       <token>*</token><token> hello </token><token> world </token><token>*</token>
+
+       str:split('data &amp;math str;')
+       <token>data</token><token>&amp;math</token><token>str;</token></out>
index 42d88d5..7958bd1 100644 (file)
 
        str:split('-*- hello - world -*-', '-')
        <xsl:copy-of select="str:split('-*- hello - world -*-', '-')"/>
+
+       str:split('data &amp;math str;')
+       <xsl:copy-of select="str:split('data &amp;math str;')"/>
 </out>
 </xsl:template>
 
-</xsl:stylesheet>
\ No newline at end of file
+</xsl:stylesheet>
index a521f4b..debb251 100644 (file)
@@ -5,4 +5,13 @@
 
   str:tokenize('date math str')
   <token>date</token><token>math</token><token>str</token>;
+
+  str:tokenize('This is &amp; strange behavior', ' ')
+  <token>This</token><token>is</token><token>&amp;</token><token>strange</token><token>behavior</token>;
+
+  str:tokenize('This is &amp; strange; behavior', ' ')
+  <token>This</token><token>is</token><token>&amp;</token><token>strange;</token><token>behavior</token>;
+
+  str:tokenize('This is &amp;strange; behavior', ' ')
+  <token>This</token><token>is</token><token>&amp;strange;</token><token>behavior</token>;
 </out>
index 81de97f..0e801d0 100644 (file)
 
   str:tokenize('date math str')
   <xsl:copy-of select="str:tokenize('date math str')"/>;
+
+  str:tokenize('This is &amp; strange behavior', ' ')
+  <xsl:copy-of select="str:tokenize('This is &amp; strange behavior', ' ')"/>;
+
+  str:tokenize('This is &amp; strange; behavior', ' ')
+  <xsl:copy-of select="str:tokenize('This is &amp; strange; behavior', ' ')"/>;
+
+  str:tokenize('This is &amp;strange; behavior', ' ')
+  <xsl:copy-of select="str:tokenize('This is &amp;strange; behavior', ' ')"/>;
 </out>
 </xsl:template>
 
-</xsl:stylesheet>
\ No newline at end of file
+</xsl:stylesheet>