]> granicus.if.org Git - php/commitdiff
fix a few tests (segfaults + wrong output)
authorNuno Lopes <nlopess@php.net>
Thu, 8 Feb 2007 16:37:52 +0000 (16:37 +0000)
committerNuno Lopes <nlopess@php.net>
Thu, 8 Feb 2007 16:37:52 +0000 (16:37 +0000)
ext/tidy/tests/004.phpt
ext/tidy/tests/007.phpt
ext/tidy/tests/010.phpt
ext/tidy/tests/011.phpt
ext/tidy/tests/012.phpt
ext/tidy/tests/019.phpt
ext/tidy/tests/024.phpt
ext/tidy/tests/025.phpt
ext/tidy/tests/027.phpt
ext/tidy/tidy.c

index e941de452bbc4201e79e73a2394bf847982bc881..eb4af05da00be614ec1190fd8e0e1159b33c1895 100644 (file)
@@ -9,9 +9,8 @@ tidy_diagnose()
        echo tidy_get_error_buffer($a);
 ?>
 --EXPECT--
-
 line 1 column 1 - Warning: missing <!DOCTYPE> declaration
 line 1 column 7 - Warning: discarding unexpected </html>
 line 1 column 14 - Warning: inserting missing 'title' element
 Info: Document content looks like HTML 3.2
-3 warnings, 0 errors were found!
\ No newline at end of file
+3 warnings, 0 errors were found!
index 27b02c557950cef9002b168eddcc3cca80d93a93..d12d37cd626c422a2e184d422bee6fd961cb0ba8 100644 (file)
@@ -36,5 +36,5 @@ Current Value of 'tab-size': int(8)
 Warning: tidy::getOpt(): Unknown Tidy Configuration Option 'bogus-opt' in %s007.php on line 10
 bool(false)
 
-Warning: tidy_getopt(): Unknown Tidy Configuration Option 'non-ASCII string àáç' in %s007.php on line 11
+Warning: tidy_getopt(): Binary or ASCII-Unicode string expected, non-ASCII-Unicode string received in %s007.php on line 11
 bool(false)
index a03ef3d69cbf3515768bc1b6d45f46119c6de8f0..0a68fc649c4324bd42de5d49d863528c80e48504 100644 (file)
@@ -318,7 +318,7 @@ object(tidyNode)#2 (9) {
 --UEXPECT--
 object(tidyNode)#2 (8) {
   [u"value"]=>
-  string(94) "<html>
+  unicode(94) "<html>
 <head>
 <title></title>
 </head>
@@ -326,7 +326,7 @@ object(tidyNode)#2 (8) {
 </body>
 </html>"
   [u"name"]=>
-  string(0) ""
+  unicode(0) ""
   [u"type"]=>
   int(0)
   [u"line"]=>
@@ -342,7 +342,7 @@ object(tidyNode)#2 (8) {
     [0]=>
     &object(tidyNode)#3 (9) {
       [u"value"]=>
-      string(94) "<html>
+      unicode(94) "<html>
 <head>
 <title></title>
 </head>
@@ -350,7 +350,7 @@ object(tidyNode)#2 (8) {
 </body>
 </html>"
       [u"name"]=>
-      string(4) "html"
+      unicode(4) "html"
       [u"type"]=>
       int(5)
       [u"line"]=>
@@ -368,12 +368,12 @@ object(tidyNode)#2 (8) {
         [0]=>
         &object(tidyNode)#4 (9) {
           [u"value"]=>
-          string(31) "<head>
+          unicode(31) "<head>
 <title></title>
 </head>
 "
           [u"name"]=>
-          string(4) "head"
+          unicode(4) "head"
           [u"type"]=>
           int(5)
           [u"line"]=>
@@ -391,10 +391,10 @@ object(tidyNode)#2 (8) {
             [0]=>
             &object(tidyNode)#5 (9) {
               [u"value"]=>
-              string(16) "<title></title>
+              unicode(16) "<title></title>
 "
               [u"name"]=>
-              string(5) "title"
+              unicode(5) "title"
               [u"type"]=>
               int(5)
               [u"line"]=>
@@ -415,11 +415,11 @@ object(tidyNode)#2 (8) {
         [1]=>
         &object(tidyNode)#6 (9) {
           [u"value"]=>
-          string(49) "<body bgcolor="#FFFFFF" alink="#000000">
+          unicode(49) "<body bgcolor="#FFFFFF" alink="#000000">
 </body>
 "
           [u"name"]=>
-          string(4) "body"
+          unicode(4) "body"
           [u"type"]=>
           int(5)
           [u"line"]=>
@@ -433,9 +433,9 @@ object(tidyNode)#2 (8) {
           [u"attribute"]=>
           array(2) {
             [u"bgcolor"]=>
-            string(7) "#FFFFFF"
+            unicode(7) "#FFFFFF"
             [u"alink"]=>
-            string(7) "#000000"
+            unicode(7) "#000000"
           }
           [u"child"]=>
           NULL
@@ -446,11 +446,11 @@ object(tidyNode)#2 (8) {
 }
 object(tidyNode)#2 (9) {
   [u"value"]=>
-  string(49) "<body bgcolor="#FFFFFF" alink="#000000">
+  unicode(49) "<body bgcolor="#FFFFFF" alink="#000000">
 </body>
 "
   [u"name"]=>
-  string(4) "body"
+  unicode(4) "body"
   [u"type"]=>
   int(5)
   [u"line"]=>
@@ -464,16 +464,16 @@ object(tidyNode)#2 (9) {
   [u"attribute"]=>
   array(2) {
     [u"bgcolor"]=>
-    string(7) "#FFFFFF"
+    unicode(7) "#FFFFFF"
     [u"alink"]=>
-    string(7) "#000000"
+    unicode(7) "#000000"
   }
   [u"child"]=>
   NULL
 }
 object(tidyNode)#2 (9) {
   [u"value"]=>
-  string(94) "<html>
+  unicode(94) "<html>
 <head>
 <title></title>
 </head>
@@ -481,7 +481,7 @@ object(tidyNode)#2 (9) {
 </body>
 </html>"
   [u"name"]=>
-  string(4) "html"
+  unicode(4) "html"
   [u"type"]=>
   int(5)
   [u"line"]=>
@@ -499,12 +499,12 @@ object(tidyNode)#2 (9) {
     [0]=>
     &object(tidyNode)#3 (9) {
       [u"value"]=>
-      string(31) "<head>
+      unicode(31) "<head>
 <title></title>
 </head>
 "
       [u"name"]=>
-      string(4) "head"
+      unicode(4) "head"
       [u"type"]=>
       int(5)
       [u"line"]=>
@@ -522,10 +522,10 @@ object(tidyNode)#2 (9) {
         [0]=>
         &object(tidyNode)#6 (9) {
           [u"value"]=>
-          string(16) "<title></title>
+          unicode(16) "<title></title>
 "
           [u"name"]=>
-          string(5) "title"
+          unicode(5) "title"
           [u"type"]=>
           int(5)
           [u"line"]=>
@@ -546,11 +546,11 @@ object(tidyNode)#2 (9) {
     [1]=>
     &object(tidyNode)#4 (9) {
       [u"value"]=>
-      string(49) "<body bgcolor="#FFFFFF" alink="#000000">
+      unicode(49) "<body bgcolor="#FFFFFF" alink="#000000">
 </body>
 "
       [u"name"]=>
-      string(4) "body"
+      unicode(4) "body"
       [u"type"]=>
       int(5)
       [u"line"]=>
@@ -564,9 +564,9 @@ object(tidyNode)#2 (9) {
       [u"attribute"]=>
       array(2) {
         [u"bgcolor"]=>
-        string(7) "#FFFFFF"
+        unicode(7) "#FFFFFF"
         [u"alink"]=>
-        string(7) "#000000"
+        unicode(7) "#000000"
       }
       [u"child"]=>
       NULL
@@ -575,12 +575,12 @@ object(tidyNode)#2 (9) {
 }
 object(tidyNode)#2 (9) {
   [u"value"]=>
-  string(31) "<head>
+  unicode(31) "<head>
 <title></title>
 </head>
 "
   [u"name"]=>
-  string(4) "head"
+  unicode(4) "head"
   [u"type"]=>
   int(5)
   [u"line"]=>
@@ -598,10 +598,10 @@ object(tidyNode)#2 (9) {
     [0]=>
     &object(tidyNode)#4 (9) {
       [u"value"]=>
-      string(16) "<title></title>
+      unicode(16) "<title></title>
 "
       [u"name"]=>
-      string(5) "title"
+      unicode(5) "title"
       [u"type"]=>
       int(5)
       [u"line"]=>
index 538a77771058328cc21d654b3f9b56a32ed209b7..d576a4764ae2b65dbf4f7a0bd572bf617c64e11b 100644 (file)
@@ -23,9 +23,9 @@ Attrib 'alink': #000000
 --UEXPECT--
 array(2) {
   [u"bgcolor"]=>
-  string(7) "#FFFFFF"
+  unicode(7) "#FFFFFF"
   [u"alink"]=>
-  string(7) "#000000"
+  unicode(7) "#000000"
 }
 Attrib 'bgcolor': #FFFFFF
 Attrib 'alink': #000000
index b2298c62a4334a52ea93aab57a90ef4f61fae210..61e525e8e3d09e5a24b9487b3c8eafbb6ccc5acf 100644 (file)
@@ -475,12 +475,12 @@ object(tidyNode)#11 (8) {
 bool(true)
 object(tidyNode)#3 (9) {
   [u"value"]=>
-  string(31) "<head>
+  unicode(31) "<head>
 <title></title>
 </head>
 "
   [u"name"]=>
-  string(4) "head"
+  unicode(4) "head"
   [u"type"]=>
   int(5)
   [u"line"]=>
@@ -498,10 +498,10 @@ object(tidyNode)#3 (9) {
     [0]=>
     &object(tidyNode)#4 (9) {
       [u"value"]=>
-      string(16) "<title></title>
+      unicode(16) "<title></title>
 "
       [u"name"]=>
-      string(5) "title"
+      unicode(5) "title"
       [u"type"]=>
       int(5)
       [u"line"]=>
@@ -522,10 +522,10 @@ object(tidyNode)#3 (9) {
 bool(true)
 object(tidyNode)#4 (9) {
   [u"value"]=>
-  string(16) "<title></title>
+  unicode(16) "<title></title>
 "
   [u"name"]=>
-  string(5) "title"
+  unicode(5) "title"
   [u"type"]=>
   int(5)
   [u"line"]=>
@@ -543,12 +543,12 @@ object(tidyNode)#4 (9) {
 }
 object(tidyNode)#5 (9) {
   [u"value"]=>
-  string(80) "<body bgcolor="#FFFFFF" alink="#000000">
+  unicode(80) "<body bgcolor="#FFFFFF" alink="#000000">
 <b>Hi</b><i>Bye<u>Test</u></i>
 </body>
 "
   [u"name"]=>
-  string(4) "body"
+  unicode(4) "body"
   [u"type"]=>
   int(5)
   [u"line"]=>
@@ -562,18 +562,18 @@ object(tidyNode)#5 (9) {
   [u"attribute"]=>
   array(2) {
     [u"bgcolor"]=>
-    string(7) "#FFFFFF"
+    unicode(7) "#FFFFFF"
     [u"alink"]=>
-    string(7) "#000000"
+    unicode(7) "#000000"
   }
   [u"child"]=>
   array(2) {
     [0]=>
     &object(tidyNode)#6 (9) {
       [u"value"]=>
-      string(9) "<b>Hi</b>"
+      unicode(9) "<b>Hi</b>"
       [u"name"]=>
-      string(1) "b"
+      unicode(1) "b"
       [u"type"]=>
       int(5)
       [u"line"]=>
@@ -591,9 +591,9 @@ object(tidyNode)#5 (9) {
         [0]=>
         &object(tidyNode)#7 (8) {
           [u"value"]=>
-          string(2) "Hi"
+          unicode(2) "Hi"
           [u"name"]=>
-          string(0) ""
+          unicode(0) ""
           [u"type"]=>
           int(4)
           [u"line"]=>
@@ -612,9 +612,9 @@ object(tidyNode)#5 (9) {
     [1]=>
     &object(tidyNode)#8 (9) {
       [u"value"]=>
-      string(21) "<i>Bye<u>Test</u></i>"
+      unicode(21) "<i>Bye<u>Test</u></i>"
       [u"name"]=>
-      string(1) "i"
+      unicode(1) "i"
       [u"type"]=>
       int(5)
       [u"line"]=>
@@ -632,9 +632,9 @@ object(tidyNode)#5 (9) {
         [0]=>
         &object(tidyNode)#9 (8) {
           [u"value"]=>
-          string(3) "Bye"
+          unicode(3) "Bye"
           [u"name"]=>
-          string(0) ""
+          unicode(0) ""
           [u"type"]=>
           int(4)
           [u"line"]=>
@@ -651,9 +651,9 @@ object(tidyNode)#5 (9) {
         [1]=>
         &object(tidyNode)#10 (9) {
           [u"value"]=>
-          string(11) "<u>Test</u>"
+          unicode(11) "<u>Test</u>"
           [u"name"]=>
-          string(1) "u"
+          unicode(1) "u"
           [u"type"]=>
           int(5)
           [u"line"]=>
@@ -671,9 +671,9 @@ object(tidyNode)#5 (9) {
             [0]=>
             &object(tidyNode)#11 (8) {
               [u"value"]=>
-              string(4) "Test"
+              unicode(4) "Test"
               [u"name"]=>
-              string(0) ""
+              unicode(0) ""
               [u"type"]=>
               int(4)
               [u"line"]=>
@@ -696,9 +696,9 @@ object(tidyNode)#5 (9) {
 bool(true)
 object(tidyNode)#6 (9) {
   [u"value"]=>
-  string(9) "<b>Hi</b>"
+  unicode(9) "<b>Hi</b>"
   [u"name"]=>
-  string(1) "b"
+  unicode(1) "b"
   [u"type"]=>
   int(5)
   [u"line"]=>
@@ -716,9 +716,9 @@ object(tidyNode)#6 (9) {
     [0]=>
     &object(tidyNode)#7 (8) {
       [u"value"]=>
-      string(2) "Hi"
+      unicode(2) "Hi"
       [u"name"]=>
-      string(0) ""
+      unicode(0) ""
       [u"type"]=>
       int(4)
       [u"line"]=>
@@ -737,9 +737,9 @@ object(tidyNode)#6 (9) {
 bool(true)
 object(tidyNode)#7 (8) {
   [u"value"]=>
-  string(2) "Hi"
+  unicode(2) "Hi"
   [u"name"]=>
-  string(0) ""
+  unicode(0) ""
   [u"type"]=>
   int(4)
   [u"line"]=>
@@ -755,9 +755,9 @@ object(tidyNode)#7 (8) {
 }
 object(tidyNode)#8 (9) {
   [u"value"]=>
-  string(21) "<i>Bye<u>Test</u></i>"
+  unicode(21) "<i>Bye<u>Test</u></i>"
   [u"name"]=>
-  string(1) "i"
+  unicode(1) "i"
   [u"type"]=>
   int(5)
   [u"line"]=>
@@ -775,9 +775,9 @@ object(tidyNode)#8 (9) {
     [0]=>
     &object(tidyNode)#9 (8) {
       [u"value"]=>
-      string(3) "Bye"
+      unicode(3) "Bye"
       [u"name"]=>
-      string(0) ""
+      unicode(0) ""
       [u"type"]=>
       int(4)
       [u"line"]=>
@@ -794,9 +794,9 @@ object(tidyNode)#8 (9) {
     [1]=>
     &object(tidyNode)#10 (9) {
       [u"value"]=>
-      string(11) "<u>Test</u>"
+      unicode(11) "<u>Test</u>"
       [u"name"]=>
-      string(1) "u"
+      unicode(1) "u"
       [u"type"]=>
       int(5)
       [u"line"]=>
@@ -814,9 +814,9 @@ object(tidyNode)#8 (9) {
         [0]=>
         &object(tidyNode)#11 (8) {
           [u"value"]=>
-          string(4) "Test"
+          unicode(4) "Test"
           [u"name"]=>
-          string(0) ""
+          unicode(0) ""
           [u"type"]=>
           int(4)
           [u"line"]=>
@@ -837,9 +837,9 @@ object(tidyNode)#8 (9) {
 bool(true)
 object(tidyNode)#9 (8) {
   [u"value"]=>
-  string(3) "Bye"
+  unicode(3) "Bye"
   [u"name"]=>
-  string(0) ""
+  unicode(0) ""
   [u"type"]=>
   int(4)
   [u"line"]=>
@@ -855,9 +855,9 @@ object(tidyNode)#9 (8) {
 }
 object(tidyNode)#10 (9) {
   [u"value"]=>
-  string(11) "<u>Test</u>"
+  unicode(11) "<u>Test</u>"
   [u"name"]=>
-  string(1) "u"
+  unicode(1) "u"
   [u"type"]=>
   int(5)
   [u"line"]=>
@@ -875,9 +875,9 @@ object(tidyNode)#10 (9) {
     [0]=>
     &object(tidyNode)#11 (8) {
       [u"value"]=>
-      string(4) "Test"
+      unicode(4) "Test"
       [u"name"]=>
-      string(0) ""
+      unicode(0) ""
       [u"type"]=>
       int(4)
       [u"line"]=>
@@ -896,9 +896,9 @@ object(tidyNode)#10 (9) {
 bool(true)
 object(tidyNode)#11 (8) {
   [u"value"]=>
-  string(4) "Test"
+  unicode(4) "Test"
   [u"name"]=>
-  string(0) ""
+  unicode(0) ""
   [u"type"]=>
   int(4)
   [u"line"]=>
index a54dac51825b76f0ff58394a3f465aa296b63bde..2b2496081a1013d1bb2b7795bf3bf21e79e30e11 100644 (file)
@@ -11,3 +11,6 @@ var_dump($x->body()->child[0]->getParent()->name);
 --EXPECT--
 string(3) "div"
 string(4) "body"
+--UEXPECT--
+unicode(3) "div"
+unicode(4) "body"
index c3d08cd6ea315919213b90def86d15beebe07fe7..43f04bd9432d4be2b0e13ea132dcb8d31b827056 100644 (file)
@@ -39,3 +39,15 @@ string(117) "<html>
 </wps:block>
 </body>
 </html>"
+--UEXPECT--
+unicode(117) "<html>
+<head>
+<title></title>
+</head>
+<body>
+<wps:block>
+<wps:var>
+<wps:value></wps:var>
+</wps:block>
+</body>
+</html>"
index a7bd544d6736e264d78f771f421e23ffb5dce1b1..335aeef4ff70980bdb5b2fdacb3ea4af18fbf97d 100644 (file)
@@ -48,3 +48,18 @@ bool(true)
 float(0)
 int(0)
 bool(true)
+--UEXPECT--
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+unicode(0) ""
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+unicode(16) "<!-- comment -->"
+bool(true)
+float(0)
+int(0)
+bool(true)
index 8d9f66eaf714d4a006d062af15f3b35bd135c119..8fef13720f88814e1b0844778621797c0c91b1d2 100644 (file)
@@ -57,3 +57,5 @@ $instance->run();
 ?>
 --EXPECT--
 string(0) ""
+--UEXPECT--
+unicode(0) ""
index 9b6b8e519f304e3612cf740e40bb0442cc411f8d..f79990982a231d24d893d8577cc11447b87de161 100644 (file)
@@ -420,7 +420,7 @@ static int _php_tidy_set_tidy_opt(TidyDoc doc, char *optname, zval *value TSRMLS
                case TidyString:
                        if (Z_TYPE(conv) != IS_STRING) {
                                zval_copy_ctor(&conv);
-                               convert_to_string(&conv);
+                               convert_to_string_with_converter(&conv, UG(ascii_conv));
                        }
                        if (tidyOptSetValue(doc, tidyOptGetId(opt), Z_STRVAL(conv))) {
                                if (Z_TYPE(conv) != Z_TYPE_P(value)) {
@@ -696,6 +696,7 @@ static int tidy_doc_cast_handler(zval *in, zval *out, int type, void *extra TSRM
 
                case IS_UNICODE:
                        obj = (PHPTidyObj *)zend_object_store_get_object(in TSRMLS_CC);
+                       tidyBufInit(&output);
                        tidySaveBuffer (obj->ptdoc->doc, &output);
                        ZVAL_U_STRINGL(obj->converter->conv, out, (char *) output.bp, output.size ? output.size-1 : 0, 1);
                        tidyBufFree(&output);
@@ -731,20 +732,23 @@ static int tidy_node_cast_handler(zval *in, zval *out, int type, void *extra TSR
                        tidyBufInit(&buf);
                        if (obj->ptdoc) {
                                tidyNodeGetText(obj->ptdoc->doc, obj->node, &buf);
-                               ZVAL_STRINGL(out, (char *) buf.bp, buf.size-1, 0);
+                               ZVAL_STRINGL(out, (char *) buf.bp, buf.size-1, 1);
                        } else {
                                ZVAL_EMPTY_STRING(out);
                        }
+                       tidyBufFree(&buf);
                        break;
 
                case IS_UNICODE:
                        obj = (PHPTidyObj *)zend_object_store_get_object(in TSRMLS_CC);
+                       tidyBufInit(&buf);
                        if (obj->ptdoc) {
                                tidyNodeGetText(obj->ptdoc->doc, obj->node, &buf);
-                               ZVAL_U_STRINGL(obj->converter->conv, out, (char *) buf.bp, buf.size-1, 0);
+                               ZVAL_U_STRINGL(obj->converter->conv, out, (char *) buf.bp, buf.size ? buf.size-1 : 0, 1);
                        } else {
                                ZVAL_EMPTY_UNICODE(out);
                        }
+                       tidyBufFree(&buf);
                        break;
 
                default:
@@ -795,7 +799,7 @@ static void tidy_add_default_properties(PHPTidyObj *obj, tidy_obj_type type TSRM
                case is_node:
                        tidyBufInit(&buf);
                        tidyNodeGetText(obj->ptdoc->doc, obj->node, &buf);
-                       ADD_PROPERTY_STRINGL(obj->converter->conv, obj->std.properties, value, buf.bp, buf.size-1);
+                       ADD_PROPERTY_STRINGL(obj->converter->conv, obj->std.properties, value, buf.bp, buf.size ? buf.size-1 : 0);
                        tidyBufFree(&buf);
 
                        ADD_PROPERTY_ASCII_STRING(obj->std.properties, name, tidyNodeGetName(obj->node));
@@ -847,6 +851,8 @@ static void tidy_add_default_properties(PHPTidyObj *obj, tidy_obj_type type TSRM
                                        newobj->type = is_node;
                                        newobj->ptdoc = obj->ptdoc;
                                        newobj->ptdoc->ref_count++;
+                                       newobj->converter = obj->converter;
+                                       if (obj->converter) obj->converter->ref_count++;
 
                                        tidy_add_default_properties(newobj, is_node TSRMLS_CC);
                                        add_next_index_zval(children, temp);
@@ -906,6 +912,8 @@ static void php_tidy_create_node(INTERNAL_FUNCTION_PARAMETERS, tidy_base_nodetyp
        newobj->type = is_node;
        newobj->ptdoc = obj->ptdoc;
        newobj->ptdoc->ref_count++;
+       newobj->converter = obj->converter;
+       if (obj->converter) obj->converter->ref_count++;
 
        switch(node) {
                case is_root_node: