Commits

Shlomi Fish committed 944cf9b

Fix t/49callbacks_returning_undef.t.

See for example:

http://www.cpantesters.org/cpan/report/73182960-cf39-11e0-bbec-9aeec8b7ec30

Comments (0)

Files changed (4)

 Revision history for Perl extension XML::LibXML
 
+1.87
+    - Fix t/49callbacks_returning_undef.t to not read /etc/passed which may
+    not be valid XML. Instead, we're reading a local file while using 
+    URI::file (assuming it exists - else - we skip_all.)
+
 1.86            Thu Aug 25 11:42:55 IDT 2011
     - Changed SvPVx_nolen() to SvPV_nolen() in LibXML.xs for better compatibility.
         - SvPVx_nolen() appears to be undocumented API.
 Av_CharPtrPtr.c
 Av_CharPtrPtr.h
 Changes
-HACKING.txt
-LICENSE
-LibXML.pm
-LibXML.pod
-LibXML.xs
-MANIFEST
-Makefile.PL
-README
-TODO
 debian/changelog
 debian/compat
 debian/control
 docs/libxml.dbk
 dom.c
 dom.h
-example/JBR-ALLENtrees.htm
-example/article.xml
 example/article_bad.xml
 example/article_external_bad.xml
+example/article_internal_bad.xml
 example/article_internal.xml
-example/article_internal_bad.xml
+example/article.xml
 example/bad.dtd
 example/bad.xml
 example/catalog.xml
 example/cb_example.pl
+example/complex/complex2.xml
 example/complex/complex.dtd
 example/complex/complex.xml
-example/complex/complex2.xml
 example/complex/dtd/f.dtd
 example/complex/dtd/g.dtd
 example/dromeds.xml
 example/enc2_latin2.html
 example/enc_latin2.html
 example/ext_ent.dtd
+example/JBR-ALLENtrees.htm
 example/ns.xml
+example/test2.xml
+example/test3.xml
+example/test4.xml
 example/test.dtd
 example/test.html
 example/test.xhtml
 example/test.xml
-example/test2.xml
-example/test3.xml
-example/test4.xml
 example/thedieline.rss
 example/utf-16-1.html
 example/utf-16-2.html
 example/xmlns/goodguy.xml
 example/xpath.pl
 example/yahoo-finance-html-with-errors.html
+HACKING.txt
 lib/XML/LibXML/Attr.pod
 lib/XML/LibXML/Boolean.pm
 lib/XML/LibXML/CDATASection.pod
 lib/XML/LibXML/Comment.pod
 lib/XML/LibXML/Common.pm
 lib/XML/LibXML/Common.pod
+lib/XML/LibXML/DocumentFragment.pod
+lib/XML/LibXML/Document.pod
 lib/XML/LibXML/DOM.pod
-lib/XML/LibXML/Document.pod
-lib/XML/LibXML/DocumentFragment.pod
 lib/XML/LibXML/Dtd.pod
 lib/XML/LibXML/Element.pod
 lib/XML/LibXML/ErrNo.pm
 lib/XML/LibXML/InputCallback.pod
 lib/XML/LibXML/Literal.pm
 lib/XML/LibXML/Namespace.pod
+lib/XML/LibXML/NodeList.pm
 lib/XML/LibXML/Node.pod
-lib/XML/LibXML/NodeList.pm
 lib/XML/LibXML/Number.pm
-lib/XML/LibXML/PI.pod
 lib/XML/LibXML/Parser.pod
 lib/XML/LibXML/Pattern.pod
+lib/XML/LibXML/PI.pod
 lib/XML/LibXML/Reader.pm
 lib/XML/LibXML/Reader.pod
 lib/XML/LibXML/RegExp.pod
 lib/XML/LibXML/RelaxNG.pod
-lib/XML/LibXML/SAX.pm
-lib/XML/LibXML/SAX.pod
 lib/XML/LibXML/SAX/Builder.pm
 lib/XML/LibXML/SAX/Builder.pod
 lib/XML/LibXML/SAX/Generator.pm
 lib/XML/LibXML/SAX/Parser.pm
+lib/XML/LibXML/SAX.pm
+lib/XML/LibXML/SAX.pod
 lib/XML/LibXML/Schema.pod
 lib/XML/LibXML/Text.pod
 lib/XML/LibXML/XPathContext.pm
 lib/XML/LibXML/XPathContext.pod
 lib/XML/LibXML/XPathExpression.pod
+LibXML.pm
+LibXML.pod
+LibXML.xs
+LICENSE
+Makefile.PL
+MANIFEST
 perl-libxml-mm.c
 perl-libxml-mm.h
 perl-libxml-sax.c
 perl-libxml-sax.h
 ppport.h
-scripts/Test.pm-to-Test-More.pl
+README
 scripts/fast-eumm.pl
 scripts/prints-to-comments.pl
+scripts/Test.pm-to-Test-More.pl
 t/01basic.t
 t/02parse.t
 t/03doc.t
 t/45regex.t
 t/46err_column.t
 t/47load_xml_callbacks.t
+t/48importing_nodes_IDs_rt_69520.t
 t/48_rt55000.t
-t/48importing_nodes_IDs_rt_69520.t
-t/49_load_html.t
 t/49callbacks_returning_undef.t
 t/49global_extent.t
+t/49_load_html.t
 t/60error_prev_chain.t
 t/60struct_error.t
 t/61error.t
 t/80registryleak.t
 t/90threads.t
-t/lib/Collector.pm
-t/lib/Counter.pm
-t/lib/Stacker.pm
-t/lib/TestHelpers.pm
-t/pod.t
+t/data/callbacks_returning_undef.xml
 test/relaxng/badschema.rng
-test/relaxng/demo.rng
-test/relaxng/demo.xml
 test/relaxng/demo2.rng
 test/relaxng/demo3.rng
 test/relaxng/demo4.rng
+test/relaxng/demo.rng
+test/relaxng/demo.xml
 test/relaxng/invaliddemo.xml
 test/relaxng/schema.rng
 test/schema/badschema.xsd
 test/xinclude/entity.txt
 test/xinclude/test.xml
 test/xinclude/xinclude.xml
+t/lib/Collector.pm
+t/lib/Counter.pm
+t/lib/Stacker.pm
+t/lib/TestHelpers.pm
+TODO
+t/pod.t
 typemap
 xpath.c
+xpathcontext.h
 xpath.h
-xpathcontext.h

t/49callbacks_returning_undef.t

 
 use lib './t/lib';
 
-use Test::More tests => 1;
+use Test::More;
+use File::Spec;
 
 use XML::LibXML;
 
-my $string = <<EOF;
+if (! eval { require URI::file; } )
+{
+    plan skip_all => "URI::file is not available.";
+}
+else
+{
+    plan tests => 1;
+}
+
+sub _escape_html
+{
+    my $string = shift;
+    $string =~ s{&}{&amp;}gso;
+    $string =~ s{<}{&lt;}gso;
+    $string =~ s{>}{&gt;}gso;
+    $string =~ s{"}{&quot;}gso;
+    return $string;
+}
+
+
+my $uri = URI::file->new(
+    File::Spec->rel2abs(
+        File::Spec->catfile(
+            File::Spec->curdir(), "t", "data", "callbacks_returning_undef.xml"
+        )
+    )
+);
+
+my $esc_path = _escape_html("$uri");
+
+my $string = <<"EOF";
 <?xml version="1.0" encoding="us-ascii"?>
 <!DOCTYPE foo [
-    <!ENTITY foo SYSTEM "file:///etc/passwd">
+    <!ENTITY foo SYSTEM "${esc_path}">
 ]>
 <methodCall>
   <methodName>metaWeblog.newPost</methodName>

t/data/callbacks_returning_undef.xml

+<foobar />