Commits

Shlomi Fish committed 7bdabe8

- Fix the handling of XML::LibXML::InputCallbacks at load_xml().

- https://rt.cpan.org/Ticket/Display.html?id=58190
- The problem was that the input callbacks were not cloned in
_clone().

Comments (0)

Files changed (4)

 
     - Correct some typos reported in 
         - https://rt.cpan.org/Ticket/Display.html?id=54390
+    - Fix the handling of XML::LibXML::InputCallbacks at load_xml().
+        - https://rt.cpan.org/Ticket/Display.html?id=58190
+        - The problem was that the input callbacks were not cloned in
+        _clone().
 
 1.74            Thu Jun 23 16:20:42 IDT 2011
     - More work on the t/*.t test scripts.
       gdome => $self->{XML_LIBXML_GDOME},
       set_parser_flags => $self->{XML_LIBXML_PARSER_OPTIONS},
     });
+  $new->input_callbacks($self->input_callbacks());
   return $new;
 }
 
 t/44extent.t
 t/45regex.t
 t/46err_column.t
+t/47load_xml_callbacks.t
 t/60struct_error.t
 t/61error.t
 t/80registryleak.t

t/47load_xml_callbacks.t

+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 3;
+
+use XML::LibXML;
+
+{
+    my $got_open = 0;
+    my $got_read = 0;
+    my $got_close = 0;
+
+    my $input_callbacks = XML::LibXML::InputCallback->new();
+    $input_callbacks->register_callbacks([
+            sub { 1 },
+            sub { $got_open = 1; open my $fh, '<', shift; return $fh; },
+            sub { $got_read = 1; my $buffer; read(shift, $buffer, shift); return $buffer; },
+            sub { $got_close = 1; close shift },
+        ]);
+
+    my $xml_parser = XML::LibXML->new();
+    $xml_parser->input_callbacks($input_callbacks);
+
+    my $TEST_FILENAME = 'example/dromeds.xml';
+
+    $xml_parser->load_xml(location => $TEST_FILENAME);
+
+    # TEST
+    ok ($got_open, 'load_xml() encountered the open InputCallback');
+
+    # TEST
+    ok ($got_read, 'load_xml() encountered the read InputCallback');
+
+    # TEST
+    ok ($got_close, 'load_xml() encountered the close InputCallback');
+}