Anonymous avatar Anonymous committed 3282103

- entity handler does not work in < 2.6.27 correctly
- make the checks at the end of the various parse_* command consistent (although they may be unnecessary)

Comments (0)

Files changed (3)

                 real_doc->URL = xmlStrdup((const xmlChar*)directory);
             }
 
-            if ( recover || ( well_formed &&
+            if ( ! LibXML_will_die_ctx(saved_error, recover) &&
+		 (recover || ( well_formed &&
                               ( !validate
                                 || ( valid || ( real_doc->intSubset == NULL
-                                                && real_doc->extSubset == NULL ))))) {
+                                                && real_doc->extSubset == NULL )))))) {
                 RETVAL = LibXML_NodeToSv( real_obj, INT2PTR(xmlNodePtr,real_doc) );
             } else {
                 xmlFreeDoc(real_doc);
         }
 
         if ( real_doc != NULL ) {
-            if ( recover || ( well_formed &&
+            if ( ! LibXML_will_die_ctx(saved_error, recover) &&
+		 (recover || ( well_formed &&
                               ( !validate
                                 || ( valid || ( real_doc->intSubset == NULL
-                                                && real_doc->extSubset == NULL ))))) {
+                                                && real_doc->extSubset == NULL )))))) {
                 RETVAL = LibXML_NodeToSv( real_obj, INT2PTR(xmlNodePtr,real_doc) );
             } else {
                 xmlFreeDoc(real_doc);
 	      <para>/parser/</para>
 	      <para>Provide a custom external entity handler
 	      to be used when expand_entities is set to 1.
-	      Possible value is a subroutine reference.</para>
+	      Possible value is a subroutine reference.
+	      </para>
+	      <para>This feature does not work properly in libxml2 &lt; 2.6.27!</para>
 	      <para>The subroutine provided is called whenever
 	      the parser needs to retrieve the content of an external entity.
 	      It is called with two arguments: the system ID (URI) and the public ID.
 use XML::LibXML;
 $|=1;
 
+if (20627 > XML::LibXML::LIBXML_VERSION) {
+    skip("skipping for libxml2 < 2.6.27") for 1..7;
+} else {
+
 my $parser = XML::LibXML->new({
   expand_entities => 1,
   ext_ent_handler => \&handler,
 # its man page ( perldoc Test::More ) for help writing this test script.
 
 
+}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.