Commits

Shlomi Fish committed b2b0973

Implement no_defdtd.

Thanks to zzgrim.

Comments (0)

Files changed (5)

     (Thanks to H. Merijn Brand.).
     - Correct the README so it won't read XML-LibXML-Common.
         - see http://code.activestate.com/lists/perl-xml/8907/
+    - Add a patch to implement the no_defdtd option in recent libxml2's:
+        - https://rt.cpan.org/Ticket/Display.html?id=70878
+        - Thanks to zzgrim@gmail.com .
 
 1.87            Sat Aug 27 14:05:37 IDT 2011
     - Fix t/49callbacks_returning_undef.t to not read /etc/passed which may
   #  return (undef,undef) unless ref $opts;
   my $flags = 0;
   $flags |=     1 if exists $opts->{recover} ? $opts->{recover} : $self->recover;
+  $flags |=     4 if $opts->{no_defdtd}; # default is ON: injects DTD as needed
   $flags |=    32 if exists $opts->{suppress_errors} ? $opts->{suppress_errors} : $self->get_option('suppress_errors');
   # This is to fix https://rt.cpan.org/Ticket/Display.html?id=58024 :
   # <quote> 
   $flags |=   128 if exists $opts->{pedantic_parser} ? $opts->{pedantic_parser} : $self->pedantic_parser;
   $flags |=   256 if exists $opts->{no_blanks} ? $opts->{no_blanks} : !$self->keep_blanks;
   $flags |=  2048 if exists $opts->{no_network} ? $opts->{no_network} : !$self->no_network;
-  $flags |= 16384 if  $opts->{no_cdata};
+  $flags |= 16384 if $opts->{no_cdata};
   $flags |= 65536 if $opts->{compact}; # compact small text nodes; no modification
                                          # of the tree allowed afterwards
                                          # (WILL possibly CRASH IF YOU try to MODIFY THE TREE)
 
 Get the latest version of XML-LibXML from CPAN. Extract them.
 
-Issue these commands in the XML-LibXML-${VERSION} directory:
+Issue these commands in the XML-LibXML-Common-VERSION directory:
 
 >   perl Makefile.PL INC=-Ic:\Prog\LibXML\include LIBS=-Lc:\Prog\LibXML\lib
 >   nmake
             </listitem>
           </varlistentry>
           <varlistentry>
+            <term>no_defdtd</term>
+            <listitem>
+	      <para>/html/</para>
+              <para>do not add a default DOCTYPE; possible values are 0 and 1</para>
+              <para>the default is (0) to add a DTD when the input html lacks one</para>
+            </listitem>
+          </varlistentry>
+          <varlistentry>
             <term>expand_xinclude or xinclude</term>
             <listitem>
 	      <para>/parser, reader/</para>
 use strict;
 use warnings;
 
-# should be 41.
-use Test::More tests => 41;
+# should be 43.
+use Test::More tests => 43;
 
 use XML::LibXML;
 use IO::File;
   # TEST
   is ($val, 'working', 'XPath');
 }
+
+
+{
+    # 70878
+    # HTML_PARSE_NODEFDTD
+
+    SKIP: {
+        skip("LibXML version is below 20708", 2) unless ( XML::LibXML::LIBXML_VERSION >= 20708 );
+
+        my $html = q(<body bgcolor='#ffffff' style="overflow: hidden;" leftmargin=0 MARGINWIDTH=0 CLASS="text">);
+        my $p = XML::LibXML->new;
+
+        # TEST
+        like( $p->parse_html_string( $html, {
+                    recover => 2,
+                    no_defdtd => 1,
+                    encoding => 'UTF-8' } )->toStringHTML, qr/^\Q<html>\E/, 'do not add a default DOCTYPE' );
+
+        # TEST
+        like ( $p->parse_html_string( $html, {
+                    recover => 2,
+                    encoding => 'UTF-8' } )->toStringHTML, qr/^\Q<!DOCTYPE html\E/, 'add a default DOCTYPE' );
+    }
+}
+
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.