The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
Changes 99168
LibXML.pm 322
LibXML.pod 18
LibXML.xs 89194
MANIFEST 05
META.json 23
META.yml 1415
Makefile.PL 05
docs/libxml.dbk 11
dom.c 37
example/xmllibxmldocs.pl 96104
inc/Devel/CheckLib.pm 02
lib/XML/LibXML/Attr.pod 18
lib/XML/LibXML/AttributeHash.pm 11
lib/XML/LibXML/Boolean.pm 12
lib/XML/LibXML/CDATASection.pod 18
lib/XML/LibXML/Comment.pod 18
lib/XML/LibXML/Common.pm 12
lib/XML/LibXML/Common.pod 18
lib/XML/LibXML/DOM.pod 18
lib/XML/LibXML/Devel.pm 11
lib/XML/LibXML/Document.pod 18
lib/XML/LibXML/DocumentFragment.pod 18
lib/XML/LibXML/Dtd.pod 18
lib/XML/LibXML/Element.pod 18
lib/XML/LibXML/ErrNo.pm 12
lib/XML/LibXML/ErrNo.pod 18
lib/XML/LibXML/Error.pm 11
lib/XML/LibXML/Error.pod 18
lib/XML/LibXML/InputCallback.pod 18
lib/XML/LibXML/Literal.pm 14
lib/XML/LibXML/Namespace.pod 18
lib/XML/LibXML/Node.pod 18
lib/XML/LibXML/NodeList.pm 11
lib/XML/LibXML/Number.pm 12
lib/XML/LibXML/PI.pod 18
lib/XML/LibXML/Parser.pod 18
lib/XML/LibXML/Pattern.pod 18
lib/XML/LibXML/Reader.pm 11
lib/XML/LibXML/Reader.pod 18
lib/XML/LibXML/RegExp.pod 18
lib/XML/LibXML/RelaxNG.pod 18
lib/XML/LibXML/SAX/Builder.pm 14
lib/XML/LibXML/SAX/Builder.pod 18
lib/XML/LibXML/SAX/Generator.pm 12
lib/XML/LibXML/SAX/Parser.pm 12
lib/XML/LibXML/SAX.pm 13
lib/XML/LibXML/SAX.pod 18
lib/XML/LibXML/Schema.pod 18
lib/XML/LibXML/Text.pod 18
lib/XML/LibXML/XPathContext.pm 12
lib/XML/LibXML/XPathContext.pod 18
lib/XML/LibXML/XPathExpression.pod 18
t/02parse.t 113
t/04node.t 111
t/05text.t 2121
t/07dtd.t 2114
t/12html.t 112
t/26schema.t 142
t/40reader_mem_error.t 915
t/48_rt93429_recover_2_in_html_parsing.t 032
t/90shared_clone_failed_rt_91800.t 050
t/90stack.t 019
t/cpan-changes.t 012
t/data/chinese.xml 04
65 files changed (This is a version diff) 3661217
@@ -1,6 +1,73 @@
 Revision history for Perl extension XML::LibXML
 
-2.0108          Tue 17 Dec 11:04:40 IST 2013
+2.0116  2014-04-12
+    - t/cpan-changes.t : minimum version of Test::CPAN::Changes.
+        - This is to avoid test failures such as:
+            - http://www.cpantesters.org/cpan/report/69ee1a2a-6c09-1014-be8f-3786912f2992
+
+2.0115  2014-04-03
+    - Fix double free when calling $node->addSibling with text nodes.
+          - https://rt.cpan.org/Ticket/Display.html?id=94149
+          - Thanks to Jeff Trout for the report.
+
+2.0114  2014-04-03
+    - Fix memory leaks and segfaults related to removal and insertion of
+      DTD nodes.
+        - https://rt.cpan.org/Ticket/Display.html?id=80521
+    - Fix memory leak in $node->removeChildNodes
+
+2.0113  2014-03-14
+    - Fix test failures with older libxml2 versions.
+        - https://rt.cpan.org/Ticket/Display.html?id=93852
+        - Thanks to Nick Wellnhofer for the patch.
+        - Thanks to the CPAN Testers for reporting this issue.
+
+2.0112  2014-03-13
+    - Fix segfaults when accessing attributes of DTD nodes
+        - https://rt.cpan.org/Ticket/Display.html?id=71076
+        - Thanks to Ralph Merridew for the report.
+    - Make $schema->validate work with elements. This uses
+      xmlSchemaValidateOneElement under the hood.
+        - https://rt.cpan.org/Ticket/Display.html?id=93496
+        - Thanks to Jeremy Marshall for the report.
+    - Fix https://rt.cpan.org/Ticket/Display.html?id=93429 .
+        - Thanks to Nick Wellnhofer for the report and test.
+    - Apply patch to build with MSVC on Windows.
+        - https://rt.cpan.org/Ticket/Display.html?id=90064
+        - Thanks to Nick Wellnhofer for the investigation and the patch.
+
+2.0111  2014-03-05
+    - Skip t/40reader_mem_error.t with libxml2 < 2.7.4
+      The failure is probably due to a known double-free bug.
+        - https://rt.cpan.org/Ticket/Display.html?id=84564
+        - https://bugzilla.gnome.org/show_bug.cgi?id=447899
+        - Thanks to Nick Wellnhofer for the pull request.
+    - Die if a file handle with an encoding layer returns more bytes
+      than requested in parse_fh.
+        - https://rt.cpan.org/Ticket/Display.html?id=78448
+    - Make insertData, deleteData, replaceData work correctly with UTF-8
+      strings.
+    - Fix substringData
+        - https://rt.cpan.org/Ticket/Display.html?id=88730
+    - Fix "Threads still failing?" Bug report.
+        - https://rt.cpan.org/Ticket/Display.html?id=91800
+        - Thanks to Daniel for the bug report and a test case, and to
+        YOREEK for the patch.
+
+2.0110  2014-02-01
+    - Add "use strict;" and "use warnings;" to all modules (CPANTS).
+    - MIN_PERL_VERSION (CPANTS).
+    - Add a LICENSE section to the POD (CPANTS).
+
+2.0109  2014-01-31
+    - Fix for requiring XML::LibXML inside two loops in perl-5.19.6 and up.
+        - https://rt.cpan.org/Ticket/Display.html?id=92606
+        - Thanks to Father Chrysostomos for the investigation, the test
+        case, and the fix.
+        - There are other ways to reproduce the bug, but the tests tests
+        for a require inside two loops.
+
+2.0108  2013-12-17
     - Replace local $^W with << no warnings 'portable'; >> in t/15nodelist.t
         - Should fix https://rt.cpan.org/Public/Bug/Display.html?id=88017
         - Thanks to "pagenyon" for the report.
@@ -10,7 +77,7 @@ Revision history for Perl extension XML::LibXML
         testcase.
     - Convert from "use base" to the more modern "use parent".
 
-2.0107          Thu 31 Oct 09:12:03 IST 2013
+2.0107  2013-10-31
     - Add a unique_key method for namespace objects.
         - https://bitbucket.org/shlomif/perl-xml-libxml/pull-request/24/unique_key-method-for-namespace-objects/diff
         - Thanks to garfieldnate for the pull request.
@@ -18,13 +85,13 @@ Revision history for Perl extension XML::LibXML
         - https://rt.cpan.org/Ticket/Display.html?id=89718
         - Thanks to Gregor Herrman and the Debian Team
 
-2.0106          Tue 17 Sep 19:08:31 IDT 2013
+2.0106  2013-09-17
     - Import croak from "use Carp;" to fix a missing croak definition.
         - https://rt.cpan.org/Ticket/Display.html?id=88624
     - Update Devel::CheckLib under "./inc" to 1.01 :
         - Should fix https://rt.cpan.org/Public/Bug/Display.html?id=81297
 
-2.0105          Sat  7 Sep 20:18:06 IDT 2013
+2.0105  2013-09-07
     - Pull some commits from Jason Mash (JRMASH) to add convenience methods
       to the XML::LibXML::NodeList module.
           - New method 'to_literal_delimited($separator)'
@@ -36,7 +103,7 @@ Revision history for Perl extension XML::LibXML
         - Fixes https://rt.cpan.org/Public/Bug/Display.html?id=88254
         - Thanks to Ulrich for the report and for a patch of sorts.
 
-2.0104          Fri 30 Aug 12:36:06 IDT 2013
+2.0104  2013-08-30
     - Fix https://rt.cpan.org/Ticket/Display.html?id=88060
         - Use quoted version number in the SYNOPSIS.
         - Thanks to Philipp Gortan for the report.
@@ -44,13 +111,13 @@ Revision history for Perl extension XML::LibXML
     directory component that contains whitespace.
         - https://rt.cpan.org/Ticket/Display.html?id=86665
 
-2.0103          Thu 22 Aug 08:34:46 IDT 2013
+2.0103  2013-08-22
     - Apply patch from Yuriy / YOREEK for test failures in t/40reader.t:
         - https://rt.cpan.org/Public/Bug/Display.html?id=83779
         - Changed the variable name to start with an underscore for internal
         use.
 
-2.0102          Mon 19 Aug 15:14:13 IDT 2013
+2.0102  2013-08-19
     - Fixed https://rt.cpan.org/Ticket/Display.html?id=83744
         - XPathContext memory leak on registerFunction.
         - Thanks to DGINEV for the report and Yuriy for the patch.
@@ -63,53 +130,53 @@ Revision history for Perl extension XML::LibXML
         - Thanks to mathias@koerber.org for the report, SREZIC@cpan.org
         and d.thomas@its.uq.edu.au for taking part and Yuriy for the patch.
 
-2.0101          Thu 15 Aug 08:29:15 IDT 2013
+2.0101  2013-08-15
     - Fixed https://rt.cpan.org/Ticket/Display.html?id=87089 .
         - "HTML doctype differs for string/scalar input"
         - Thanks to NGLENN for the report and to Yuriy for the tests and
         fix.
 
-2.0100          Wed 14 Aug 08:23:53 IDT 2013
+2.0100  2013-08-14
     - Added the unique_key() method to XML::LibXML::Node.
     - t/40reader.t: assigning from $@ to a lexical so it won't be
     over-ridden.
         - https://rt.cpan.org/Ticket/Display.html?id=87830
         - Thanks to Douglas Christopher Wilson for the report.
 
-2.0019          Mon  1 Jul 11:04:31 IDT 2013
+2.0019  2013-07-01
     - Correct typos reported in RT #86599.
         - https://rt.cpan.org/Ticket/Display.html?id=86599
         - Thanks to dsteinbrunner.
 
-2.0018          Mon 13 May 13:35:06 IDT 2013
+2.0018  2013-05-13
     - Revert previous change of minimal version of libxml2.
         - This change proved to be unpopular and didn't prevent
         the CPAN test failures.
         - By SHLOMIF
 
-2.0017          Thu  9 May 11:03:36 IDT 2013
+2.0017  2013-05-09
     - Made the minimal version of libxml2 2.9.0 as previous versions were
     too buggy due to spuriourous CPAN test failures.
         - Please upgrade.
         - By SHLOMIF
 
-2.0016          Sat 13 Apr 22:36:51 IDT 2013
+2.0016  2013-04-13
     - Don't enable XML_PARSE_HUGE by default.
         - Fix the previous version due to a mercurial SNAFU.
 
-2.0015          Sat 13 Apr 02:30:33 IDT 2013
+2.0015  2013-04-13
     - Don't enable XML_PARSE_HUGE by default.
         - https://bitbucket.org/shlomif/perl-xml-libxml/pull-request/19
         - Thanks to Grant McLean ( https://metacpan.org/author/GRANTM ) for
         the bug report and patch.
 
-2.0014          Wed  5 Dec 11:06:26 IST 2012
+2.0014  2012-12-05
     - Got 40reader_mem_error.t to not fetch the external DTDs.
         - https://rt.cpan.org/Public/Bug/Display.html?id=81703
         - Thanks to Alexandr Ciornii (CHORNY) for the report and Slaven
         Rezic (SREZIC) for the analysis and a proposed fix.
 
-2.0013          Tue  4 Dec 17:40:27 IST 2012
+2.0013  2012-12-04
     - Fix a memory error (double-free) in XML::LibXML::Reader if we reached
     EOF and
     then called destroy.
@@ -117,14 +184,14 @@ Revision history for Perl extension XML::LibXML
         - Fixed by Shlomi Fish.
         - see t/40reader_mem_error.t
 
-2.0012          Fri  9 Nov 06:39:32 IST 2012
+2.0012  2012-11-09
     - Fix support for references to scalars with overloaded stringification
     magic.
         - https://rt.cpan.org/Public/Bug/Display.html?id=77864
         - Thanks to Christian Hansen (CHANSEN) for a report, a testcase, and
         a patch.
 
-2.0011          Thu  8 Nov 00:25:15 IST 2012
+2.0011  2012-11-08
     - Fix crash in removeChild() when not expanding entities
         - https://rt.cpan.org/Ticket/Display.html?id=80395
             - "removeChild() segfaults when not expanding entities"
@@ -132,43 +199,43 @@ Revision history for Perl extension XML::LibXML
         was adapted into t/48_removeChild_crashes_rt_80395.t ) and for
         a patch to fix it.
 
-2.0010          Thu  1 Nov 20:13:08 IST 2012
+2.0010  2012-11-01
     - Passing debug (an undocumented option) to check_lib in Makefile.PL.
         - This way we get more meaningful traces on perl Makefile.PL DEBUG=1.
         - Thanks to MSTROUT for the report and a proposed fix.
 
-2.0009          Thu  1 Nov 16:26:45 IST 2012
+2.0009  2012-11-01
     - Fix libxml2 detection in Strawberry Perl.
         - Another Devel::CheckOS fallout.
         - Thanks to KMX for the report and for a proposed fix. The actual fix
         was made to be more generic considering the use-cases.
         - https://rt.cpan.org/Ticket/Display.html?id=80540
 
-2.0008          Mon 22 Oct 12:09:11 IST 2012
+2.0008  2012-10-22
     - Fix build error when using non-standard libxml2 installation
         - https://rt.cpan.org/Ticket/Display.html?id=80332
         - Thanks to L RW for the report.
 
-2.0007          Wed 17 Oct 18:38:37 IST 2012
+2.0007  2012-10-17
     - Fix for build failures on Windows with Microsoft Visual C++.
         - https://rt.cpan.org/Ticket/Display.html?id=80229
         - Thanks to Desmond Daignault for the report and an initial patch.
         - Patch modified by Shlomi Fish
 
-2.0006          Sat 13 Oct 22:27:54 IST 2012
+2.0006  2012-10-13
     - When xml2-config returns several paths, the configuration failed.
     Fixed that.
         - https://rt.cpan.org/Public/Bug/Display.html?id=80167
         - Thanks to VOVKASM for the report and fix.
 
-2.0005          Sat 13 Oct 13:18:48 IST 2012
+2.0005  2012-10-13
     - Added t/style-trailing-space.t and removed trailing space.
     - Add a check for the existence of included C headers (*.h) files
     in Makefile.PL to avoid failed compilations.
         - Using Devel::CheckLib.
         - Thanks to its maintainers!
 
-2.0004          Tue  7 Aug 23:04:55 IDT 2012
+2.0004  2012-08-07
     - Add a way to specify a different compiler to be used in the
     "Makefile" by calling Makefile.PL with the CC environment variable
     set to the path to the alternate compiler.
@@ -177,7 +244,7 @@ Revision history for Perl extension XML::LibXML
     - LibXML.pm (_clone): Fix typo in line_numbers handling.
         - Thanks to Bernhard Reutner-Fischer for the report and fix.
 
-2.0003          Fri 27 Jul 17:11:21 IDT 2012
+2.0003  2012-07-27
     - Patch to a potential NULL dereference in xpath.c.
         - Thanks to Ville Skyttä <ville.skytta@iki.fi> and cppcheck.
     - Fix NodeList::item() calling a 1-indxed array reference.
@@ -187,17 +254,17 @@ Revision history for Perl extension XML::LibXML
     - Add the scripts/tag-release.pl script to tag a release using
     Mercurial.
 
-2.0002          Sun Jul  8 18:09:13 IDT 2012
+2.0002  2012-07-08
     - Applied spelling fixes correction patch by
     Ville Skyttä <ville.skytta@iki.fi>.
         - Thanks, Ville!
 
-2.0001          Wed Jun 20 19:40:05 IDT 2012
+2.0001  2012-06-20
     - Remove the leftover perl-libxml-libxml.h from the distribution.
         - https://rt.cpan.org/Ticket/Display.html?id=77924
         - Thanks to Martin Mann for the report.
 
-2.0000          Tue Jun 19 23:04:23 IDT 2012
+2.0000  2012-06-19
     - Fix warnings that appear when compiling using the clang C compiler by
     default.
         - https://rt.cpan.org/Ticket/Display.html?id=77802
@@ -210,7 +277,7 @@ Revision history for Perl extension XML::LibXML
         Father Chrysostomos ( http://search.cpan.org/~sprout/ ) and
         Mons Anderson for some diagnosis.
 
-1.99            Thu May 31 10:21:23 IDT 2012
+1.99    2012-05-31
     - Apply a patch from Mons Anderson ( mons@cpan.org ) for fixing the
     overloading.
         - t/62overload.t
@@ -221,19 +288,19 @@ Revision history for Perl extension XML::LibXML
         - Thanks to Gregor Herrmann and Niko Tyni from the
         Debian Perl group.
 
-1.98            Sun May 13 21:02:14 IDT 2012
+1.98    2012-05-13
     - Make sure parse_string() and load_xml() also accept references to
     strings (to avoid unnecessary copying).
         - See: https://rt.cpan.org/Ticket/Display.html?id=64051
 
-1.97            Mon Apr 30 20:31:24 IDT 2012
+1.97    2012-04-30
     - Apply a test and a fix to correct keep_blanks having no effect on
     parse_balanced_chunk.
         - fixes https://rt.cpan.org/Ticket/Display.html?id=76696
         - Add t/30keep_blanks.t .
         - Thanks to SREZIC for the report, the test and the fix.
 
-1.96            Fri Mar 16 21:01:09 IST 2012
+1.96    2012-03-16
     - Apply a patch to add leading minus signs to the commands of
     install_sax_driver.
         - This makes the make process succeed even if they fail.
@@ -244,7 +311,7 @@ Revision history for Perl extension XML::LibXML
         - Thanks to Tim Brody for the patch.
         - Fixes the problem reported in http://www.city-fan.org/tips/PaulHowarth/Blog/2011-09-06.
 
-1.95            Tue Mar  6 10:35:26 IST 2012
+1.95    2012-03-06
     - Got rid of a broken test (at least with recent libxml2s) in
     t/03doc.t :
         - https://rt.cpan.org/Ticket/Display.html?id=75403
@@ -253,13 +320,13 @@ Revision history for Perl extension XML::LibXML
         release.
         - Thanks to vcizek for the report.
 
-1.94            Sat Mar  3 22:05:18 IST 2012
+1.94    2012-03-03
     - Fix XML::LibXML::Element tests for ineqaulity with == and eq.
         - Fixes https://rt.cpan.org/Ticket/Display.html?id=75505 .
         - Thanks to Mark Overmeer for the report and for a preliminary patch
         to t/71overload.t .
 
-1.93            Mon Feb 27 11:15:50 IST 2012
+1.93    2012-02-27
     - Fix XML::LibXML::Element comparison with == and eq.
         - Fixes https://rt.cpan.org/Ticket/Display.html?id=75257 ,
         https://rt.cpan.org/Ticket/Display.html?id=75293 ,
@@ -267,13 +334,13 @@ Revision history for Perl extension XML::LibXML
         - Thanks to Toby Inkster for a preliminary patch (that was modified by
         me) and to the various people who reported the problem.
 
-1.92            Tue Feb 21 19:00:48 IST 2012
+1.92    2012-02-21
     - Fix for test failure on perls < 5.10.
         - Fixes https://rt.cpan.org/Public/Bug/Display.html?id=75195
         - Thanks to Paul for the report, and for a patch that was not
         accepted.
 
-1.91            Tue Feb 21 13:57:54 IST 2012
+1.91    2012-02-21
     - Overload hash dereferencing on XML::LibXML::Elements, to provide
     access to the element's attributes.
         - See XML::LibXML::AttributeHash for details.
@@ -285,13 +352,13 @@ Revision history for Perl extension XML::LibXML
     - Printed some warnings regardless if DEBUG is on.
         - Thanks to http://search.cpan.org/~mstrout/ for the suggestion.
 
-1.90            Sun Jan  8 20:57:58 IST 2012
+1.90    2012-01-08
     - Pull a commit from Aaron Crange to fix compilation bugs in Devel.xs:
         - local variable declarations must be in the PREINIT section,
         not `CODE`, at least for some compiler/OS combinations.
         - Thanks, Aaron!
 
-1.89            Sat Dec 24 09:46:26 IDT 2011
+1.89    2011-12-24
     - Apply a patch with spelling fixes by Kevin Lyda :
         - https://rt.cpan.org/Public/Bug/Display.html?id=71403
         - Thanks to Kevin.
@@ -300,7 +367,7 @@ Revision history for Perl extension XML::LibXML
     - Adjust the Win32 Build Instructions in the README file.
         - Thanks to Christopher J. Madsen.
 
-1.88            Wed Sep 21 12:54:33 IDT 2011
+1.88    2011-09-21
     - Add libxml2 2.7.8 as tested and working fine for the Makefile.PL.
     (Thanks to H. Merijn Brand.).
     - Apply a patch to perl-libxml-sax.c to use xmlChar * instead of char *.
@@ -314,18 +381,18 @@ Revision history for Perl extension XML::LibXML
         - Up to then, the version numbers of the modules under lib/ had
         been 1.73.
 
-1.87            Sat Aug 27 14:05:37 IDT 2011
+1.87    2011-08-27
     - 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
+1.86    2011-08-25
     - Changed SvPVx_nolen() to SvPV_nolen() in LibXML.xs for better compatibility.
         - SvPVx_nolen() appears to be undocumented API.
         - Resolves https://rt.cpan.org/Public/Bug/Display.html?id=70476
         - Thanks to Paul for the report.
 
-1.85            Wed Aug 24 17:05:19 IDT 2011
+1.85    2011-08-24
     - Gracefully handle returned undef()s in the read callback under -w ($^W):
         - t/49callbacks_returning_undef.t
         - https://rt.cpan.org/Ticket/Display.html?id=70321
@@ -334,14 +401,14 @@ Revision history for Perl extension XML::LibXML
         - I'm applying it by faith, so if it breaks, blame him. (;-).
         - the patch adds -lllibgettextlib.dll to the Makefile.PL.
 
-1.84            Sat Jul 23 23:12:28 IDT 2011
+1.84    2011-07-23
     - Fix for perl 5.8.x before 5.8.8:
         - "You can now use the x operator to repeat a qw// list. This used to raise a syntax error."
             - http://search.cpan.org/perldoc?perl588delta
         - fixes https://rt.cpan.org/Ticket/Display.html?id=69722 .
         - thanks to paul@city-fan.org for the report.
 
-1.83            Sat Jul 23 14:28:40 IDT 2011
+1.83    2011-07-23
     - Fixed missing declarations after statements:
         - resolves https://rt.cpan.org/Ticket/Display.html?id=69622 again.
         - thanks to Vadim / VKON.
@@ -356,7 +423,7 @@ Revision history for Perl extension XML::LibXML
     reliable.
         - SHLOMIF
 
-1.82            Wed Jul 20 23:43:53 IDT 2011
+1.82    2011-07-20
     - Moved some if blocks after the dSP; (which contains declarations) to be
     compliant with C89/C90, which don't allow declarations in the middle of
     a C function.
@@ -366,7 +433,7 @@ Revision history for Perl extension XML::LibXML
         - "install_sax_driver doesn't like custom INSTALLARCHLIB"
         - thanks to Milki from U.Cal Berkeley.
 
-1.81            Sat Jul 16 18:30:02 IDT 2011
+1.81    2011-07-16
     - Add scripts/fast-eumm.pl to remove the explicit objects dependency on
     the "Makefile" file so after running scripts/fast-eumm.pl one won't have to
     rebuild the C-files.
@@ -379,7 +446,7 @@ Revision history for Perl extension XML::LibXML
     - Convert all remaining Test.pm-based test scripts except t/14sax.t to
     Test::More .
 
-1.80            Tue Jul 12 23:35:03 IDT 2011
+1.80    2011-07-12
     - Fix https://rt.cpan.org/Public/Bug/Display.html?id=69082 :
         - Compilation on strawberry perl.
         - The problem was that stderr required a dTHX; call previously.
@@ -397,7 +464,7 @@ Revision history for Perl extension XML::LibXML
         - Thanks to TODDR.
         - http://www.cpantesters.org/cpan/report/4ac00aae-a73f-11e0-84bd-8881cd42d09c
 
-1.79            Fri Jul  8 20:02:32 IDT 2011
+1.79    2011-07-08
     - t/46err_column.t : add a skip for a test for CentOS/RHEL 4:
         - https://rt.cpan.org/Ticket/Display.html?id=69070
         - old version of libxml2 .
@@ -408,7 +475,7 @@ Revision history for Perl extension XML::LibXML
     - double plan in t/61error.t .
         - in accordance to the previous change.
 
-1.78            Wed Jul  6 20:23:58 IDT 2011
+1.78    2011-07-06
     - Change t/02parse.t to test for the localized error message:
         - https://rt.cpan.org/Public/Bug/Display.html?id=69248
     - Fix the skip() and 'plan skip_all' syntax in t/06elements.t and
@@ -417,7 +484,7 @@ Revision history for Perl extension XML::LibXML
         - It did not match the one specified in Test::More.
     - Convert more test scripts from Test.pm to Test::More.
 
-1.77            Fri Jul  1 22:27:56 IDT 2011
+1.77    2011-07-01
     - Change the signature of XML::LibXML::Reader::byteConsumed to be
     "long" instead of "int", so it can return values above 2**31 in
     64-bit platforms.
@@ -449,7 +516,7 @@ Revision history for Perl extension XML::LibXML
         UTF-8.
         - Thanks to David E. Wheeler (DWHEELER) for the report.
 
-1.76            Thu Jun 30 20:58:46 IDT 2011
+1.76    2011-06-30
     - Cleaned up t/28new_callbacks_multiple.t - convert to a Counter
      and Stacker class.
         - After that, the regression test for was added:
@@ -468,7 +535,7 @@ Revision history for Perl extension XML::LibXML
         - https://rt.cpan.org/Ticket/Display.html?id=69205
         - Thanks to DOUGW .
 
-1.75            Fri Jun 24 19:00:40 IDT 2011
+1.75    2011-06-24
     - Correct some typos reported in
         - https://rt.cpan.org/Ticket/Display.html?id=54390
     - Fix the handling of XML::LibXML::InputCallbacks at load_xml().
@@ -496,7 +563,7 @@ Revision history for Perl extension XML::LibXML
         namespace declaration will cause that attribute to have the other
         prefix. >>
 
-1.74            Thu Jun 23 16:20:42 IDT 2011
+1.74    2011-06-23
     - More work on the t/*.t test scripts.
     - Add scripts/Test.pm-to-Test-More.pl to semi-automatically
     convert a test script from Test.pm to Test::More.
@@ -517,7 +584,7 @@ Revision history for Perl extension XML::LibXML
         - Thanks to Evan Carroll ( http://www.evancarroll.com/ ) for the
         report.
 
-1.73            Sat Jun 18 10:53:44 IDT 2011
+1.73    2011-06-18
     - Calculating $err->column() properly, so it won't be maxed out at
     80:
         - https://rt.cpan.org/Public/Bug/Display.html?id=66642
@@ -554,13 +621,13 @@ Revision history for Perl extension XML::LibXML
         - From https://github.com/frett/perl-libxml .
 
 
-1.72            Thu Jun 16 19:26:13 IDT 2011
+1.72    2011-06-16
     - Removed a stray file from the MANIFEST
         - http://rt.cpan.org/Ticket/Display.html?id=68865
         - Warned on "kit not complete".
         - Thanks to obrien.jk
 
-1.71            Tue Jun 14 19:43:50 IDT 2011
+1.71    2011-06-14
    - turn XML_LIBXML_PARSE_DEFAULTS constant to $XML::LibXML::XML_LIBXML_PARSE_DEFAULTS
    - Apply 0001-XML-LibXML-Error-no-need-to-AUTOLOAD-domain.patch from
      https://rt.cpan.org/Public/Bug/Display.html?id=68575 - no need to
@@ -595,7 +662,7 @@ Revision history for Perl extension XML::LibXML
         -- Fixing https://rt.cpan.org/Ticket/Display.html?id=68564
         -- Thanks to Daniel Perrett .
 
-1.70
+1.70     Unknown
    - various fixes and improvements in the documentation
    - added (convenient yet non-standard) methods nonBlankChildNodes,
      firstNonBlankChild, nextNonBlankSibling, prevNonBlankSibling
@@ -612,13 +679,13 @@ Revision history for Perl extension XML::LibXML
    - added 'eq' and 'cmp' overloading on XML::LibXML::Error and set fallback to 1
    - lots of bugs fixed
 
-1.69_2
+1.69_2   Unknown
    - provide context and more accurate column number in
      structured errors
    - clarify license and copyright
    - support for Win32+mingw+ActiveState
 
-1.69_1
+1.69_1   Unknown
    - merge with XML::LibXML::Common
    - fix compilation on Windows with mingw or msvc
    - fix a bug in structured errors preventing the previous errors from being reported
@@ -627,25 +694,26 @@ Revision history for Perl extension XML::LibXML
    - added getAttributeHash to the reader interface
    - fix segfaults: reconcileNs in domReplaceChild, findnodes with a doc fragment (S. Rezic)
 
-1.69
+1.69     Unknown
    - fix incorrect output of getAttributeNS and possibly other methods on UTF-8
    - added $node_or_xpc->exists($xpath) method
    - remove accidental debug output from XML::LibXML::SAX::Builder
 
-1.68
+1.68     Unknown
    - compilation problem fixes
 
-1.67
+1.67     Unknown
    - many bugfixes (rt.cpan.org)
    - added XML::LibXML::Pattern module and extended pattern support in Reader
-   - added XML::LibXML::XPathExpression module that can pre-compile an XPath expression
+   - added XML::LibXML::XPathExpression module that can pre-compile an XPath
+   expression
    - reimplementation of the thread support (mostly by Tim Brody)
    - structured errors XML::LibXML::Error
    - memory leak fixes
    - documentation fixes
    - README - notes for building on Win32 (C.J. Madsen)
 
-1.66
+1.66     Unknown
    - Perl-thread support contributed by Tim Brody [rt.cpan.org #31945]
    - fix [rt.cpan.org #30610] possible segmentation fault when importing nodes from a document to an element created with XML::LibXML::Element->new
    - fix [rt.cpan.org #30261] Segmentation fault when extracting elements from an XML chunk
@@ -655,7 +723,7 @@ Revision history for Perl extension XML::LibXML
    - give registered Ns declarations precedence over document-specific ones
      in XML::LibXML::XPathContext; fixes [rt.cpan.org #29650]
 
-1.65
+1.65     Unknown
    - fix bug in t/40reader.t revealed by a bugfix in Test::More 0.71 (Jonathan Rockway)
    - fix possible SIGSEGV when PI's or attrs created with
      createDocument can get garbage-collected after their owning
@@ -663,7 +731,7 @@ Revision history for Perl extension XML::LibXML
    - skip tests for unsupported features on unsupported versions of Perl/libxml2
    - make Reader interface require Perl 5.8 (patches to extend to 5.6 are welcome)
 
-1.64
+1.64     Unknown
    - fix reconciliation of the "xml" namespace [rt.cpan.org #26450]
    - make tests pass with libxml2 2.9.29 - PI regression tests now
      accept "" as data of an empty PI [rt.cpan.org #27659]
@@ -679,7 +747,7 @@ Revision history for Perl extension XML::LibXML
    - XML::LibXML::Namespace API fixed in order to achieve
      an agreement between the docs and the implementation
 
-1.63
+1.63     Unknown
    - added no_network parser flag
    - added support for exclusive canonicalization (http://www.w3.org/TR/xml-exc-c14n/)
    - make XInclude reflect parser flags
@@ -689,7 +757,7 @@ Revision history for Perl extension XML::LibXML
    - $doc->actualEncoding returns UTF8 if no document encoding is declared
      (unlike $doc->getEncoding, which returns undef)
 
-1.62
+1.62     Unknown
    - interface to libxml2's pull-parser XML::LibXML::Reader
      (initiated by Heiko Klein)
    - make error messages intended to the user report the line of the
@@ -704,7 +772,7 @@ Revision history for Perl extension XML::LibXML
    - toString on empty text node returns empty string, not undef
    - cloneNode copies attributes on an element as required by the DOM spec
 
-1.61
+1.61     Unknown
    - get{Elements,Children}By{TagName,TagNameNS,LocalName} now
      obey wildcards '*', getChildrenByLocalName was added.
    - XML::LibXML::XPathContext merged in
@@ -717,7 +785,7 @@ Revision history for Perl extension XML::LibXML
    - get/setAttribute(NS)? implementation made xmlns aware
    - all sub-modules have the same version as XML::LibXML
 
-1.60
+1.60     Unknown
    - getElementsById corrected to getElementById and the old name kept
      as an alias. Also re-implemented without XPath for improved
      performance
@@ -730,7 +798,7 @@ Revision history for Perl extension XML::LibXML
      bar:foo, which was the old behavior.)
    - added publicId and systemId methods to XML::LibXML::Dtd
 
-1.59
+1.59     Unknown
    - new parser and callback code (Christian Glahn)
    - new XML::LibXML::InputCallback class
    - many bug fixes (including several memory leaks)
@@ -742,7 +810,7 @@ Revision history for Perl extension XML::LibXML
    - faster getChildrenByTagNameNS implementation
    - remove the SGML parser code no longer supported by libxml (Michael Kröll)
 
-1.58
+1.58     Unknown
    - fixed a pointer initialization in parse_xml_chunk(), fixes
      random several segmentation faults on document fragments.
    - added NSCLEAN feature to the parser interface (bug 4560)
@@ -751,7 +819,7 @@ Revision history for Perl extension XML::LibXML
    - fixed croak while requesting nodeName() of CDATA sections (bug 1694).
    - more documentation updates
 
-1.57
+1.57     Unknown
    - added cloneNode to XML::LibXML::Document
    - include Schema/RelaxNG code only with libxml2 >= 2.6.0 (to support old libxml2)
    - applied patch to example/cb_example.pl (bug 4262)
@@ -787,7 +855,7 @@ Revision history for Perl extension XML::LibXML
    - added version information of libxml2
    - Les Richardson's documentation patch applied.
 
-1.56
+1.56     Unknown
    - added line number interface (thanks to Peter Haworth)
    - patch to make perl 5.8.1 and XML::LibXML work together (thanks to François Pons)
    - added getElementById to XML::LibXML::Document (thanks to Robin Berjon)
@@ -796,7 +864,7 @@ Revision history for Perl extension XML::LibXML
    - tiny code clean ups
    - corrected tested versions after a local setup problem
 
-1.55
+1.55     Unknown
    - fixed possible problems with math.h
    - added C14N interface "toStringC14N()" (thanks to Chip Turner)
    - fixed default namespace bug with libxml2 2.5.8 (by Vaclav Barta)
@@ -806,11 +874,8 @@ Revision history for Perl extension XML::LibXML
    - improved more documentation
    - converted documentation to DocBook
 
-*NOTE:*
-Version 1.54 fixes potentional buffer overflows were possible with earlier
-versions of the package.
 
-1.54
+1.54     Unknown
    - fixed some major bugs, works now with libxml2 2.5.x
    - fixed problem with empty document fragments
    - bad tag and attribute names cannot be created anymore
@@ -842,7 +907,11 @@ versions of the package.
    - improved M
    - more documentation
 
-1.53
+    - *NOTE:*
+    - Version 1.54 fixes potentional buffer overflows were possible with
+    - earlier versions of the package.
+
+1.53     Unknown
    Parser
    - catalog interface
    - enabled SGML parsing
@@ -879,14 +948,14 @@ versions of the package.
    - calling external entity handlers work again
    - XML::LibXML::SAX::Parser will not throw warnings on DTD nodes
 
-1.52
+1.52     Unknown
    - fixed some typos (thanks to Randy Kobes and Hildo Biersma)
    - fixed namespace node handling
    - fixed empty Text Node bug
    - corrected the parser default values.
    - added some documentation
 
-1.51
+1.51     Unknown
    - fixed parser bug with broken XML declarations
    - fixed memory management within documents that have subsets
    - fixed some threaded perl issues
@@ -907,7 +976,7 @@ versions of the package.
    - better libxml2 version testing
    - more documentation
 
-1.50
+1.50     Unknown
    - fixed major problems with the validating parser
    - fixed default behaviour of the generic parser
    - fixed attribute setting of the string parser
@@ -929,7 +998,7 @@ versions of the package.
    - cloneNode clones now within documents
    - more documentation
 
-1.49
+1.49     Unknown
    - memory management has been completely rewritten.
         now the module should not cause that many memory leaks
         (special thanks to Merijn Broeren and Petr Pajas for providing
@@ -951,7 +1020,7 @@ versions of the package.
      $skipXMLDeclaration)
    - more documentation
 
-1.40
+1.40     Unknown
    - new parsefunction: $parser->parse_xml_chunk($string);
    - appendChild( $doc_fragment ) bug fixed
    - removed obsolete files (parser.?)
@@ -969,13 +1038,13 @@ versions of the package.
    - A number of segfault fixes
    - constants added without XML_ prefix
 
-1.31
+1.31     Unknown
     - Removed C-layer parser implementation.
     - Added support for prefixes in find* functions
     - More memory leak fixes (in custom DOMs)
     - Allow global callbacks
 
-1.30
+1.30     Unknown
     - Full PI access
     - New parser implementation (safer)
     - Callbacks API changed to be on the object, not the class
@@ -983,7 +1052,7 @@ versions of the package.
     - Memory leak fixes
     - applied a bunch of patches provided by T.J. Mather
 
-1.00
+1.00     Unknown
     - Added SAX serialisation
     - Added a SAX builder module
     - Fixed findnodes in scalar context to return a NodeList object
@@ -991,13 +1060,13 @@ versions of the package.
     - Added find(), which returns different things depending on the XPath
     - Added Boolean, Number and Literal data types
 
-0.99
+0.99     Unknown
     - Added support for $doc->URI getter/setter
 
-0.98
+0.98     Unknown
     - New have_library implementation
 
-0.97
+0.97     Unknown
     - Addition of Dtd string parser
     - Added support for namespace nodes (e.g. $element->getNamespaces())
     - Some memory leak and segfault fixes
@@ -1005,7 +1074,7 @@ versions of the package.
       $doc->is_valid([$dtd]))
     - Added doc files and test files to CPAN distro
 
-0.96
+0.96     Unknown
     - Addition of HTML parser
     - getOwner method added
     - Element->getAttributes() added
@@ -1014,24 +1083,24 @@ versions of the package.
     - Memory leak fixes
     - Bug Fixes
 
-0.94
+0.94     Unknown
     - Some DOM Level 2 cleanups
     - getParentNode returns XML::LibXML::Document if we get the
       document node
 
-0.93
+0.93     Unknown
     - Addition of DOM Level 2 APIs
     - some more segfault fixes
     - Document is now a Node (which makes lots of things easier)
 
-0.92
+0.92     Unknown
     - Many segfault and other bug fixes
     - More DOM API methods added
 
-0.91
+0.91     Unknown
     - Removed from XML::LibXSLT distribution
     - Added DOM API (phish)
 
-0.01  Sat Mar  3 17:08:00 2001
+0.01    2001-03-03
 	- original version; created by h2xs 1.19
 
@@ -11,6 +11,8 @@
 package XML::LibXML;
 
 use strict;
+use warnings;
+
 use vars qw($VERSION $ABI_VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS
             $skipDTD $skipXMLDeclaration $setTagCompression
             $MatchCB $ReadCB $OpenCB $CloseCB %PARSER_FLAGS
@@ -27,7 +29,7 @@ use XML::LibXML::XPathContext;
 use IO::Handle; # for FH reads called as methods
 
 BEGIN {
-$VERSION = "2.0108"; # VERSION TEMPLATE: DO NOT CHANGE
+$VERSION = "2.0116"; # VERSION TEMPLATE: DO NOT CHANGE
 $ABI_VERSION = 2;
 require Exporter;
 require DynaLoader;
@@ -255,6 +257,8 @@ use constant {
   XML_PARSE_NOBASEFIX	  => 262144,   # do not fixup XINCLUDE xml#base uris
   XML_PARSE_HUGE	  => 524288,   # relax any hardcoded limit from the parser
   XML_PARSE_OLDSAX	  => 1048576,  # parse using SAX2 interface from before 2.7.0
+  HTML_PARSE_RECOVER => (1<<0),       # suppress error reports
+  HTML_PARSE_NOERROR  => (1<<5),       # suppress error reports
 };
 
 $XML_LIBXML_PARSE_DEFAULTS = ( XML_PARSE_NODICT | XML_PARSE_DTDLOAD | XML_PARSE_NOENT );
@@ -611,7 +615,10 @@ sub recover {
 sub recover_silently {
     my $self = shift;
     my $arg = shift;
-    (($arg == 1) ? $self->recover(2) : $self->recover($arg)) if defined($arg);
+    if ( defined($arg) )
+    {
+        $self->recover(($arg == 1) ? 2 : $arg);
+    }
     return (($self->recover()||0) == 2) ? 1 : 0;
 }
 
@@ -1050,7 +1057,19 @@ sub _html_options {
   $opts = {} unless ref $opts;
   #  return (undef,undef) unless ref $opts;
   my $flags = 0;
-  $flags |=     1 if exists $opts->{recover} ? $opts->{recover} : $self->recover;
+  {
+    my $recover = exists $opts->{recover} ? $opts->{recover} : $self->recover;
+
+    if ($recover)
+    {
+      $flags |= HTML_PARSE_RECOVER;
+      if ($recover == 2)
+      {
+        $flags |= HTML_PARSE_NOERROR;
+      }
+    }
+  }
+
   $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 :
@@ -505,7 +505,7 @@ Petr Pajas
 
 =head1 VERSION
 
-2.0108
+2.0116
 
 =head1 COPYRIGHT
 
@@ -516,3 +516,10 @@ Petr Pajas
 2006-2009, Petr Pajas.
 
 =cut
+
+
+=head1 LICENSE
+
+This program is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
@@ -497,6 +497,7 @@ LibXML_read_perl (SV * ioref, char * buffer, int len)
 
     int cnt;
     SV * read_results;
+    IV read_results_iv;
     STRLEN read_length;
     char * chars;
     SV * tbuff = NEWSV(0,len);
@@ -536,9 +537,20 @@ LibXML_read_perl (SV * ioref, char * buffer, int len)
         croak("read error");
     }
 
-    read_length = SvIV(read_results);
+    read_results_iv = SvIV(read_results);
 
     chars = SvPV(tbuff, read_length);
+
+    /*
+     * If the file handle uses an encoding layer, the length parameter is
+     * interpreted as character count, not as byte count. So it's possible
+     * that more than len bytes are read which would overflow the buffer.
+     * Check for this condition also by comparing the return value.
+     */
+    if (read_results_iv != read_length || read_length > len) {
+        croak("Read more bytes than requested. Do you use an encoding-related"
+              " PerlIO layer?");
+    }
     strncpy(buffer, chars, read_length);
 
     PUTBACK;
@@ -1008,6 +1020,39 @@ LibXML_test_node_name( xmlChar * name )
     return(1);
 }
 
+/* Assumes that the node has a proxy. */
+static void
+LibXML_reparent_removed_node(xmlNodePtr node) {
+    /*
+     * Attribute nodes can't be added to document fragments. Adding
+     * DTD nodes would cause a memory leak.
+     */
+    if (node->type != XML_ATTRIBUTE_NODE
+        && node->type != XML_DTD_NODE) {
+        ProxyNodePtr docfrag = PmmNewFragment(node->doc);
+        xmlAddChild(PmmNODE(docfrag), node);
+        PmmFixOwner(PmmPROXYNODE(node), docfrag);
+    }
+}
+
+static void
+LibXML_set_int_subset(xmlDocPtr doc, xmlNodePtr dtd) {
+    xmlNodePtr old_dtd = (xmlNodePtr)doc->intSubset;
+    if (old_dtd == dtd) {
+        return;
+    }
+
+    if (old_dtd != NULL) {
+        xmlUnlinkNode(old_dtd);
+
+        if (PmmPROXYNODE(old_dtd) == NULL) {
+            xmlFreeDtd((xmlDtdPtr)old_dtd);
+        }
+    }
+
+    doc->intSubset = (xmlDtdPtr)dtd;
+}
+
 /* ****************************************************************
  * XPathContext helper functions
  * **************************************************************** */
@@ -1486,6 +1531,11 @@ PROTOTYPES: DISABLE
 BOOT:
     /* Load Devel first, so debug_memory can
        be called before any allocation. */
+
+    /* The ++ is a bit hacky, but boot_blahblah_Devel, being an
+     * XSUB body, will try to pop once more the mark we have just
+     * (implicitly) popped, this boot sector also being an XSUB body */
+    PL_markstack_ptr++;
     boot_XML__LibXML__Devel(aTHX_ cv);
     LIBXML_TEST_VERSION
     xmlInitParser();
@@ -3805,6 +3855,9 @@ importNode( self, node, dummy=0 )
             croak( "Can't import Documents!" );
             XSRETURN_UNDEF;
         }
+        if (node->type == XML_DTD_NODE) {
+            croak("Can't import DTD nodes");
+        }
 
         ret = domImportNode( self, node, 0, 1 );
         if ( ret ) {
@@ -3831,6 +3884,9 @@ adoptNode( self, node )
             croak( "Can't adopt Documents!" );
             XSRETURN_UNDEF;
         }
+        if (node->type == XML_DTD_NODE) {
+            croak("Can't adopt DTD nodes");
+        }
 
         ret = domImportNode( self, node, 1, 1 );
 
@@ -4095,8 +4151,33 @@ MODULE = XML::LibXML         PACKAGE = XML::LibXML::Node
 void
 DESTROY( node )
         SV * node
+    PREINIT:
+        int count;
+        SV *is_shared;
     CODE:
 #ifdef XML_LIBXML_THREADS
+    if ( (is_shared = get_sv("XML::LibXML::__threads_shared", 0)) == NULL ) {
+        is_shared = &PL_sv_undef;
+    }
+    if ( SvTRUE(is_shared) ) {
+        dSP;
+        ENTER;
+        SAVETMPS;
+        PUSHMARK(SP);
+        XPUSHs(node);
+        PUTBACK;
+        count = call_pv("threads::shared::is_shared", G_SCALAR);
+        SPAGAIN;
+        if (count != 1)
+            croak("Couldn't checks if the variable is shared or not\n");
+        is_shared = POPs;
+        PUTBACK;
+        FREETMPS;
+        LEAVE;
+        if (is_shared != &PL_sv_undef) {
+            XSRETURN_UNDEF;
+        }
+    }
 	if( PmmUSEREGISTRY ) {
 	  SvLOCK(PROXY_NODE_REGISTRY_MUTEX);
 	  PmmRegistryREFCNT_dec(SvPROXYNODE(node));
@@ -4566,7 +4647,8 @@ _attributes( self )
         int wantarray = GIMME_V;
     PPCODE:
         PERL_UNUSED_VAR(ix);
-        if ( self->type != XML_ATTRIBUTE_NODE ) {
+        if ( self->type != XML_ATTRIBUTE_NODE
+             && self->type != XML_DTD_NODE ) {
             attr = self->properties;
             while ( attr != NULL ) {
                 if ( wantarray != G_SCALAR ) {
@@ -4628,7 +4710,8 @@ int
 hasAttributes( self )
         xmlNodePtr self
     CODE:
-        if ( self->type == XML_ATTRIBUTE_NODE ) {
+        if ( self->type == XML_ATTRIBUTE_NODE
+             || self->type == XML_DTD_NODE ) {
             RETVAL = 0;
         }
         else {
@@ -4689,11 +4772,13 @@ insertBefore( self, nNode, refNode )
         if ( rNode != NULL ) {
             RETVAL = PmmNodeToSv( rNode,
                                   PmmOWNERPO(PmmPROXYNODE(self)) );
-            PmmFixOwner(PmmOWNERPO(SvPROXYNODE(RETVAL)),
-                        PmmOWNERPO(PmmPROXYNODE(self)) );
+            if (rNode->type == XML_DTD_NODE) {
+                LibXML_set_int_subset(self->doc, rNode);
+            }
+            PmmFixOwner(PmmPROXYNODE(rNode), PmmOWNERPO(PmmPROXYNODE(self)));
         }
         else {
-                 XSRETURN_UNDEF;
+            XSRETURN_UNDEF;
         }
     OUTPUT:
         RETVAL
@@ -4712,8 +4797,10 @@ insertAfter( self, nNode, refNode )
         if ( rNode != NULL ) {
             RETVAL = PmmNodeToSv( rNode,
                                   PmmOWNERPO(PmmPROXYNODE(self)) );
-                PmmFixOwner(PmmOWNERPO(SvPROXYNODE(RETVAL)),
-                            PmmOWNERPO(PmmPROXYNODE(self)) );
+            if (rNode->type == XML_DTD_NODE) {
+                LibXML_set_int_subset(self->doc, rNode);
+            }
+            PmmFixOwner(PmmPROXYNODE(rNode), PmmOWNERPO(PmmPROXYNODE(self)));
         }
         else {
             XSRETURN_UNDEF;
@@ -4728,7 +4815,6 @@ replaceChild( self, nNode, oNode )
         xmlNodePtr oNode
     PREINIT:
         xmlNodePtr ret = NULL;
-        ProxyNodePtr docfrag = NULL;
     CODE:
        if ( self->type == XML_DOCUMENT_NODE ) {
                 switch ( nNode->type ) {
@@ -4754,16 +4840,15 @@ replaceChild( self, nNode, oNode )
             XSRETURN_UNDEF;
         }
         else {
-                docfrag = PmmNewFragment( self->doc );
-                /* create document fragment */
-                xmlAddChild( PmmNODE(docfrag), ret );
-                RETVAL = PmmNodeToSv(ret, docfrag);
-
-                if ( nNode->_private != NULL ) {
-                    PmmFixOwner( PmmPROXYNODE(nNode),
-                                 PmmOWNERPO(PmmPROXYNODE(self)) );
-                }
-                PmmFixOwner( SvPROXYNODE(RETVAL), docfrag );
+            LibXML_reparent_removed_node(ret);
+            RETVAL = PmmNodeToSv(ret, PmmOWNERPO(PmmPROXYNODE(ret)));
+            if (nNode->type == XML_DTD_NODE) {
+                LibXML_set_int_subset(nNode->doc, nNode);
+            }
+            if ( nNode->_private != NULL ) {
+                PmmFixOwner( PmmPROXYNODE(nNode),
+                             PmmOWNERPO(PmmPROXYNODE(self)) );
+            }
         }
     OUTPUT:
         RETVAL
@@ -4774,14 +4859,12 @@ replaceNode( self,nNode )
         xmlNodePtr nNode
     PREINIT:
         xmlNodePtr ret = NULL;
-        ProxyNodePtr docfrag = NULL;
+        ProxyNodePtr owner = NULL;
     CODE:
         if ( domIsParent( self, nNode ) == 1 ) {
             XSRETURN_UNDEF;
         }
-        if ( self->doc != nNode->doc ) {
-            domImportNode( self->doc, nNode, 1, 1 );
-        }
+        owner = PmmOWNERPO(PmmPROXYNODE(self));
 
         if ( self->type != XML_ATTRIBUTE_NODE ) {
               ret = domReplaceChild( self->parent, nNode, self);
@@ -4790,21 +4873,14 @@ replaceNode( self,nNode )
              ret = xmlReplaceNode( self, nNode );
         }
         if ( ret ) {
-            if ( ret->type == XML_ATTRIBUTE_NODE ) {
-                docfrag = NULL;
+            LibXML_reparent_removed_node(ret);
+            RETVAL = PmmNodeToSv(ret, PmmOWNERPO(PmmPROXYNODE(ret)));
+            if (nNode->type == XML_DTD_NODE) {
+                LibXML_set_int_subset(nNode->doc, nNode);
             }
-            else {
-                /* create document fragment */
-                docfrag = PmmNewFragment( self->doc );
-                xmlAddChild( PmmNODE(docfrag), ret );
-            }
-
-            RETVAL = PmmNodeToSv(ret, docfrag);
             if ( nNode->_private != NULL ) {
-                PmmFixOwner( PmmPROXYNODE(nNode),
-                             PmmOWNERPO(PmmPROXYNODE(self)));
+                PmmFixOwner(PmmPROXYNODE(nNode), owner);
             }
-            PmmFixOwner( SvPROXYNODE(RETVAL), docfrag );
         }
         else {
             croak( "replacement failed" );
@@ -4825,10 +4901,8 @@ removeChild( self, node )
             XSRETURN_UNDEF;
         }
         else {
-                ProxyNodePtr docfrag = PmmNewFragment( ret->doc );
-                xmlAddChild( PmmNODE(docfrag), ret );
-                RETVAL = PmmNodeToSv(ret,NULL);
-                PmmFixOwner( SvPROXYNODE(RETVAL), docfrag );
+            LibXML_reparent_removed_node(ret);
+            RETVAL = PmmNodeToSv(ret, NULL);
         }
     OUTPUT:
         RETVAL
@@ -4844,22 +4918,31 @@ removeChildNodes( self )
         fragment = PmmNODE( docfrag );
         elem = self->children;
         while ( elem ) {
+            xmlNodePtr next = elem->next;
             xmlUnlinkNode( elem );
-            /* this following piece is the function of domAppendChild()
-             * but in this special case we can avoid most of the logic of
-             * that function.
-             */
-            if ( fragment->children != NULL ) {
-                xs_warn("unlink node!\n");
-                domAddNodeToList( elem, fragment->last, NULL );
+            if (elem->type == XML_ATTRIBUTE_NODE
+                || elem->type == XML_DTD_NODE) {
+                if (PmmPROXYNODE(elem) == NULL) {
+                    xmlFreeNode(elem);
+                }
             }
             else {
-                fragment->children = elem;
-                fragment->last     = elem;
-                elem->parent= fragment;
+                /* this following piece is the function of domAppendChild()
+                 * but in this special case we can avoid most of the logic of
+                 * that function.
+                 */
+                if ( fragment->children != NULL ) {
+                    xs_warn("unlink node!\n");
+                    domAddNodeToList( elem, fragment->last, NULL );
+                }
+                else {
+                    fragment->children = elem;
+                    fragment->last     = elem;
+                    elem->parent= fragment;
+                }
+                PmmFixOwnerNode( elem, docfrag );
             }
-            PmmFixOwnerNode( elem, docfrag );
-            elem = elem->next;
+            elem = next;
         }
 
         self->children = self->last = NULL;
@@ -4882,11 +4965,7 @@ unbindNode( self )
         if ( self->type != XML_DOCUMENT_NODE
              && self->type != XML_DOCUMENT_FRAG_NODE ) {
             xmlUnlinkNode( self );
-            if ( self->type != XML_ATTRIBUTE_NODE ) {
-                docfrag = PmmNewFragment( self->doc );
-                xmlAddChild( PmmNODE(docfrag), self );
-            }
-            PmmFixOwner( PmmPROXYNODE(self), docfrag );
+            LibXML_reparent_removed_node(self);
         }
 
 SV*
@@ -4926,6 +5005,9 @@ appendChild( self, nNode )
 
         RETVAL = PmmNodeToSv( nNode,
                               PmmOWNERPO(PmmPROXYNODE(self)) );
+        if (nNode->type == XML_DTD_NODE) {
+            LibXML_set_int_subset(self->doc, nNode);
+        }
         PmmFixOwner( SvPROXYNODE(RETVAL), PmmPROXYNODE(self) );
     OUTPUT:
         RETVAL
@@ -4988,20 +5070,44 @@ addSibling( self, nNode )
         xmlNodePtr nNode
     PREINIT:
         xmlNodePtr ret = NULL;
+        ProxyNodePtr owner = NULL;
     CODE:
         if ( nNode->type == XML_DOCUMENT_FRAG_NODE ) {
             croak("Adding document fragments with addSibling not yet supported!");
             XSRETURN_UNDEF;
         }
+        owner = PmmOWNERPO(PmmPROXYNODE(self));
 
-        ret = xmlAddSibling( self, nNode );
+        if (self->type == XML_TEXT_NODE && nNode->type == XML_TEXT_NODE
+            && self->name == nNode->name) {
+            /* As a result of text merging, the added node may be freed. */
+            xmlNodePtr copy = xmlCopyNode(nNode, 0);
+            ret = xmlAddSibling(self, copy);
 
-        if ( ret ) {
-            RETVAL = PmmNodeToSv(ret,NULL);
-            PmmFixOwner( SvPROXYNODE(RETVAL), PmmOWNERPO(PmmPROXYNODE(self)) );
+            if (ret) {
+                RETVAL = PmmNodeToSv(ret, owner);
+                /* Unlink original node. */
+                xmlUnlinkNode(nNode);
+                LibXML_reparent_removed_node(nNode);
+            }
+            else {
+                xmlFreeNode(copy);
+                XSRETURN_UNDEF;
+            }
         }
         else {
-            XSRETURN_UNDEF;
+            ret = xmlAddSibling( self, nNode );
+
+            if ( ret ) {
+                RETVAL = PmmNodeToSv(ret, owner);
+                if (nNode->type == XML_DTD_NODE) {
+                    LibXML_set_int_subset(self->doc, nNode);
+                }
+                PmmFixOwner(SvPROXYNODE(RETVAL), owner);
+            }
+            else {
+                XSRETURN_UNDEF;
+            }
         }
     OUTPUT:
         RETVAL
@@ -6505,18 +6611,11 @@ substringData( self, offset, length )
     PREINIT:
         xmlChar * data = NULL;
         xmlChar * substr = NULL;
-        int len = 0;
-        int dl = 0;
     CODE:
-        if ( offset >= 0 && length > 0 ) {
-            dl = offset + length - 1 ;
+        if ( offset >= 0 && length >= 0 ) {
             data = domGetNodeValue( self );
-            len = xmlStrlen( data );
-            if ( data != NULL && len > 0 && len > offset ) {
-                if ( dl > len )
-                    dl = offset + len;
-
-                substr = xmlStrsub( data, offset, dl );
+            if ( data != NULL ) {
+                substr = xmlUTF8Strsub( data, offset, length );
                 RETVAL = C2Sv( (const xmlChar*)substr, NULL );
                 xmlFree( substr );
             }
@@ -6580,17 +6679,17 @@ insertData( self, offset, value )
             if ( encstring != NULL && xmlStrlen( encstring ) > 0 ) {
                 data = domGetNodeValue(self);
                 if ( data != NULL && xmlStrlen( data ) > 0 ) {
-                    if ( xmlStrlen( data ) < offset ) {
+                    if ( xmlUTF8Strlen( data ) < offset ) {
                         data = xmlStrcat( data, encstring );
                         domSetNodeValue( self, data );
                     }
                     else {
-                        dl = xmlStrlen( data ) - offset;
+                        dl = xmlUTF8Strlen( data ) - offset;
 
                         if ( offset > 0 )
-                            new   = xmlStrsub(data, 0, offset );
+                            new   = xmlUTF8Strsub(data, 0, offset );
 
-                        after = xmlStrsub(data, offset, dl );
+                        after = xmlUTF8Strsub(data, offset, dl );
 
                         if ( new != NULL ) {
                             new = xmlStrcat(new, encstring );
@@ -6631,17 +6730,17 @@ deleteData( self, offset, length )
     CODE:
         if ( length > 0 && offset >= 0 ) {
             data = domGetNodeValue(self);
-            len = xmlStrlen( data );
+            len = xmlUTF8Strlen( data );
             if ( data != NULL
                  && len > 0
                  && len > offset ) {
                 dl1 = offset + length;
                 if ( offset > 0 )
-                    new = xmlStrsub( data, 0, offset );
+                    new = xmlUTF8Strsub( data, 0, offset );
 
                 if ( len > dl1 ) {
                     dl2 = len - dl1;
-                    after = xmlStrsub( data, dl1, dl2 );
+                    after = xmlUTF8Strsub( data, dl1, dl2 );
                     if ( new != NULL ) {
                         new = xmlStrcat( new, after );
                         xmlFree(after);
@@ -6677,7 +6776,7 @@ replaceData( self, offset,length, value )
 
             if ( encstring != NULL && xmlStrlen( encstring ) > 0 ) {
                 data = domGetNodeValue(self);
-                len = xmlStrlen( data );
+                len = xmlUTF8Strlen( data );
 
                 if ( data != NULL
                      && len > 0
@@ -6685,16 +6784,16 @@ replaceData( self, offset,length, value )
 
                     dl1 = offset + length;
                     if ( dl1 < len ) {
-                        dl2 = xmlStrlen( data ) - dl1;
+                        dl2 = xmlUTF8Strlen( data ) - dl1;
                         if ( offset > 0 ) {
-                            new = xmlStrsub(data, 0, offset );
+                            new = xmlUTF8Strsub(data, 0, offset );
                             new = xmlStrcat(new, encstring );
                         }
                         else {
                             new   = xmlStrdup( encstring );
                         }
 
-                        after = xmlStrsub(data, dl1, dl2 );
+                        after = xmlUTF8Strsub(data, dl1, dl2 );
                         new = xmlStrcat(new, after );
 
                         domSetNodeValue( self, new );
@@ -6705,7 +6804,7 @@ replaceData( self, offset,length, value )
                     else {
                         /* replace until end! */
                         if ( offset > 0 ) {
-                            new = xmlStrsub(data, 0, offset );
+                            new = xmlUTF8Strsub(data, 0, offset );
                             new = xmlStrcat(new, encstring );
                         }
                         else {
@@ -7437,18 +7536,18 @@ parse_buffer( self, perlstring )
 
 
 int
-validate( self, doc )
+validate( self, node )
         xmlSchemaPtr self
-        xmlDocPtr doc
+        xmlNodePtr node
     PREINIT:
         xmlSchemaValidCtxtPtr vctxt = NULL;
         PREINIT_SAVED_ERROR
     CODE:
         INIT_ERROR_HANDLER;
 
-        if (doc) {
-            PmmClearPSVI(doc);
-            PmmInvalidatePSVI(doc);
+        if (node->type == XML_DOCUMENT_NODE) {
+            PmmClearPSVI((xmlDocPtr)node);
+            PmmInvalidatePSVI((xmlDocPtr)node);
         }
         vctxt  = xmlSchemaNewValidCtxt( self );
         if ( vctxt == NULL ) {
@@ -7463,7 +7562,13 @@ validate( self, doc )
                                   (xmlSchemaValidityWarningFunc)LibXML_error_handler_ctx,
                                   saved_error );
 
-        RETVAL = xmlSchemaValidateDoc( vctxt, doc );
+        if (node->type == XML_DOCUMENT_NODE) {
+            RETVAL = xmlSchemaValidateDoc(vctxt, (xmlDocPtr)node);
+        }
+        else {
+            RETVAL = xmlSchemaValidateOneElement(vctxt, node);
+        }
+
         xmlSchemaFreeValidCtxt( vctxt );
 
         CLEANUP_ERROR_HANDLER;
@@ -163,6 +163,7 @@ t/48_memleak_rt_83744.t
 t/48_removeChild_crashes_rt_80395.t
 t/48_replaceNode_DTD_nodes_rT_80521.t
 t/48_rt55000.t
+t/48_rt93429_recover_2_in_html_parsing.t
 t/48importing_nodes_IDs_rt_69520.t
 t/49_load_html.t
 t/49callbacks_returning_undef.t
@@ -176,9 +177,13 @@ t/62overload.t
 t/71overloads.t
 t/72destruction.t
 t/80registryleak.t
+t/90shared_clone_failed_rt_91800.t
+t/90stack.t
 t/90threads.t
 t/91unique_key.t
+t/cpan-changes.t
 t/data/callbacks_returning_undef.xml
+t/data/chinese.xml
 t/lib/Collector.pm
 t/lib/Counter.pm
 t/lib/Stacker.pm
@@ -4,7 +4,7 @@
       "Petr Pajas"
    ],
    "dynamic_config" : 1,
-   "generated_by" : "ExtUtils::MakeMaker version 6.78, CPAN::Meta::Converter version 2.132830",
+   "generated_by" : "ExtUtils::MakeMaker version 6.94, CPAN::Meta::Converter version 2.140640",
    "keywords" : [
       "dom",
       "html",
@@ -55,6 +55,7 @@
             "XML::SAX" : "0.11",
             "base" : "0",
             "parent" : "0",
+            "perl" : "5.008",
             "strict" : "0",
             "vars" : "0",
             "warnings" : "0"
@@ -68,5 +69,5 @@
          "url" : "https://bitbucket.org/shlomif/perl-xml-libxml"
       }
    },
-   "version" : "2.0108"
+   "version" : "2.0116"
 }
@@ -3,11 +3,11 @@ abstract: 'Interface to Gnome libxml2 xml parsing and DOM library'
 author:
   - 'Petr Pajas'
 build_requires:
-  ExtUtils::MakeMaker: 0
+  ExtUtils::MakeMaker: '0'
 configure_requires:
-  ExtUtils::MakeMaker: 0
+  ExtUtils::MakeMaker: '0'
 dynamic_config: 1
-generated_by: 'ExtUtils::MakeMaker version 6.78, CPAN::Meta::Converter version 2.132830'
+generated_by: 'ExtUtils::MakeMaker version 6.94, CPAN::Meta::Converter version 2.140640'
 keywords:
   - dom
   - html
@@ -27,23 +27,24 @@ keywords:
 license: perl
 meta-spec:
   url: http://module-build.sourceforge.net/META-spec-v1.4.html
-  version: 1.4
+  version: '1.4'
 name: XML-LibXML
 no_index:
   directory:
     - t
     - inc
 requires:
-  ExtUtils::MakeMaker: 6.56
-  Test::More: 0
-  XML::NamespaceSupport: 1.07
-  XML::SAX: 0.11
-  base: 0
-  parent: 0
-  strict: 0
-  vars: 0
-  warnings: 0
+  ExtUtils::MakeMaker: '6.56'
+  Test::More: '0'
+  XML::NamespaceSupport: '1.07'
+  XML::SAX: '0.11'
+  base: '0'
+  parent: '0'
+  perl: '5.008'
+  strict: '0'
+  vars: '0'
+  warnings: '0'
 resources:
   homepage: https://bitbucket.org/shlomif/perl-xml-libxml
   repository: https://bitbucket.org/shlomif/perl-xml-libxml
-version: 2.0108
+version: '2.0116'
@@ -37,6 +37,10 @@ my %INFOS = (
     'AUTHOR'    => 'Petr Pajas',
     'ABSTRACT'  => 'Interface to Gnome libxml2 xml parsing and DOM library',
     'LICENSE' => 'perl',
+    (($ExtUtils::MakeMaker::VERSION >= 6.48)
+        ? (MIN_PERL_VERSION => '5.008',)
+        : ()
+    ),
     'PREREQ_PM' => {
         'base' => 0,
         'ExtUtils::MakeMaker' => '6.56',
@@ -305,6 +309,7 @@ if (!defined $config{LIBS} || $config{LIBS} !~ /\-l(?:lib)?xml2\b/) {
             # Put several options.
             $config_LIBS_alternatives = [
                 map { "$l $_" }
+                q/ -llibxml2/,
                 q/ -lxml2 -lzlib/,
                 q/ -llibxml2 -lzlib -llibgettextlib.dll/
             ];
@@ -22,7 +22,7 @@
         </authorgroup>
 
 
-        <edition>2.0108</edition>
+        <edition>2.0116</edition>
         <copyright>
             <year>2001-2007</year>
             <holder>AxKit.com Ltd</holder>
@@ -544,6 +544,12 @@ domUnlinkNode( xmlNodePtr node ) {
         return;
     }
 
+    if (node->type == XML_DTD_NODE) {
+        /* This clears the doc->intSubset pointer. */
+        xmlUnlinkNode(node);
+        return;
+    }
+
     if ( node->prev != NULL ) {
         node->prev->next = node->next;
     }
@@ -573,9 +579,7 @@ domImportNode( xmlDocPtr doc, xmlNodePtr node, int move, int reconcileNS ) {
 
     if ( move ) {
         return_node = node;
-        if ( node->type != XML_DTD_NODE ) {
-            domUnlinkNode( node );
-        }
+        domUnlinkNode( node );
     }
     else {
         if ( node->type == XML_DTD_NODE ) {
@@ -124,18 +124,26 @@ sub set_general_info {
     my @copyright = $infonode->findnodes( "copyright" );
     if ( @copyright ) {
         $infostr .= "=head1 COPYRIGHT\n\n";
-	foreach my $copyright (@copyright) {
-	  my $node_y = $copyright->getChildrenByTagName( "year" );
-	  my $node_h = $copyright->getChildrenByTagName( "holder" );
-	  if ( defined $node_y ) {
+        foreach my $copyright (@copyright) {
+          my $node_y = $copyright->getChildrenByTagName( "year" );
+          my $node_h = $copyright->getChildrenByTagName( "holder" );
+          if ( defined $node_y ) {
             $infostr .= $node_y->string_value() . ", ";
-	  }
-	  if ( defined $node_h ) {
+          }
+          if ( defined $node_h ) {
             $infostr .= $node_h->string_value();
-	  }
-	  $infostr .= ".\n\n";
-	}
-        $infostr .= "=cut\n"
+          }
+          $infostr .= ".\n\n";
+        }
+        $infostr .= "=cut\n";
+
+        $infostr .= "\n\n".<<'EOF';
+=head1 LICENSE
+
+This program is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
+EOF
     }
 
     $self->{infoblock} = $infostr;
@@ -164,7 +172,7 @@ sub handle {
         # dangerous for nested modules, which do not exist at the time of writing
         # this code.
 
-	unless ( length $filename ) {
+        unless ( length $filename ) {
             $dir = "";
             $filename = "LibXML";
         }
@@ -327,16 +335,16 @@ sub dump_pod {
         my ( $title ) = $chap->getChildrenByTagName( "title" );
         my ( $ttlabbr ) = $chap->getChildrenByTagName( "titleabbrev" );
         my $str =  $ttlabbr->string_value() . " - ".$title->string_value();
-	$str=~s/^\s+|\s+$//g;
+        $str=~s/^\s+|\s+$//g;
         $self->{OFILE}->print(  "=head1 NAME\n\n$str\n" );
-	my ($synopsis) = $chap->findnodes( "sect1[title='Synopsis']" );
+        my ($synopsis) = $chap->findnodes( "sect1[title='Synopsis']" );
         my @funcs = $chap->findnodes( ".//funcsynopsis" );
-	if ($synopsis or scalar @funcs) {
+        if ($synopsis or scalar @funcs) {
             $self->{OFILE}->print( "\n=head1 SYNOPSIS\n\n" )
-	}
-	if ($synopsis) {
-	  $self->dump_pod( $synopsis );
-	}
+        }
+        if ($synopsis) {
+          $self->dump_pod( $synopsis );
+        }
         if ( scalar @funcs ) {
             foreach my $s ( @funcs ) {
                 $self->dump_pod( $s );
@@ -347,46 +355,46 @@ sub dump_pod {
 
     foreach my $node ( $chap->childNodes() ) {
       if ( $node->nodeType == XML_TEXT_NODE ||
-	     $node->nodeType == XML_CDATA_SECTION_NODE ) {
- 	# we split at the last whitespace before 80 chars
-	my $prev_inline =
-	  ($node->previousSibling and
-	   $node->previousSibling->nodeName !~
-	     /^(?:itemizedlist|orderedlist|variablelist|programlisting|funcsynopsis)/)
-	    ? 1 : 0;
-	my $str = $node->data();
-	$str=~s/(^|\n)[ \t]+($|\n)/$1$2/g;
-	if ($str=~/\S/) {
-	  my $string = $str;
-	  my $space_before = ($string =~ s/^\s+//g) ? $prev_inline : 0;
-	  my $space_after = ($string =~ s/\s+$//g) ? 1 : 0;
-	  $self->{OFILE}->print( " " ) if $space_before;
-	  my $os = "";
-	  my @words = split /\s+/, $string;
-	  foreach my $word ( @words ) {
-	    if ( (length( $os ) + length( $word ) + 1) < 80 ) {
-	      if ( length $os ) { $os .= " "; }
-	    $os .= $word;
-	    }
-	    else {
-	      $self->{OFILE}->print( $os . "\n" );
-	      $os = $word;
-	    }
-	  }
-	  $os.=" " if $space_after;
-	  $self->{OFILE}->print( $os );
-	}
+             $node->nodeType == XML_CDATA_SECTION_NODE ) {
+        # we split at the last whitespace before 80 chars
+        my $prev_inline =
+          ($node->previousSibling and
+           $node->previousSibling->nodeName !~
+             /^(?:itemizedlist|orderedlist|variablelist|programlisting|funcsynopsis)/)
+            ? 1 : 0;
+        my $str = $node->data();
+        $str=~s/(^|\n)[ \t]+($|\n)/$1$2/g;
+        if ($str=~/\S/) {
+          my $string = $str;
+          my $space_before = ($string =~ s/^\s+//g) ? $prev_inline : 0;
+          my $space_after = ($string =~ s/\s+$//g) ? 1 : 0;
+          $self->{OFILE}->print( " " ) if $space_before;
+          my $os = "";
+          my @words = split /\s+/, $string;
+          foreach my $word ( @words ) {
+            if ( (length( $os ) + length( $word ) + 1) < 80 ) {
+              if ( length $os ) { $os .= " "; }
+            $os .= $word;
+            }
+            else {
+              $self->{OFILE}->print( $os . "\n" );
+              $os = $word;
+            }
+          }
+          $os.=" " if $space_after;
+          $self->{OFILE}->print( $os );
+        }
       } elsif ( $node->nodeName() eq "para" ) {
-	$self->dump_pod( $node );
-	$self->{OFILE}->print( "\n\n" );
+        $self->dump_pod( $node );
+        $self->{OFILE}->print( "\n\n" );
       } elsif ( $node->nodeName() eq "sect1" ) {
             my ( $title ) = $node->getChildrenByTagName( "title" );
-	    my $str = $title->string_value();
-	    unless ($chap->nodeName eq "chapter" and $str eq 'Synopsis') {
-	      $self->{OFILE}->print( "\n=head1 " . uc($str) );
-	      $self->{OFILE}->print( "\n\n" );
-	      $self->dump_pod( $node );
-	    }
+            my $str = $title->string_value();
+            unless ($chap->nodeName eq "chapter" and $str eq 'Synopsis') {
+              $self->{OFILE}->print( "\n=head1 " . uc($str) );
+              $self->{OFILE}->print( "\n\n" );
+              $self->dump_pod( $node );
+            }
         }
         elsif (  $node->nodeName() eq "sect2" ) {
             my ( $title ) = $node->getChildrenByTagName( "title" );
@@ -411,7 +419,7 @@ sub dump_pod {
             $self->{OFILE}->print( "\n=over 4\n\n" );
             foreach my $item ( @items ) {
                 $self->{OFILE}->print( "=item *\n\n" );
-		$self->dump_pod( $item );
+                $self->dump_pod( $item );
                 $self->{OFILE}->print( "\n\n" );
             }
             $self->{OFILE}->print( "=back\n\n" );
@@ -424,7 +432,7 @@ sub dump_pod {
             foreach my $item ( @items ) {
                 $i++;
                 $self->{OFILE}->print( "=item $i.\n\n" );
-		$self->dump_pod($item);
+                $self->dump_pod($item);
                 $self->{OFILE}->print( "\n\n" );
             }
             $self->{OFILE}->print( "=back\n\n" );
@@ -439,7 +447,7 @@ sub dump_pod {
             my ( $term ) = $node->findnodes( "term" );
             $self->{OFILE}->print( "=item " );
             if ( defined $term ) {
-	      $self->dump_pod( $term );
+              $self->dump_pod( $term );
             }
             $self->{OFILE}->print( "\n\n" );
             my @nodes =$node->findnodes( "listitem" );
@@ -450,14 +458,14 @@ sub dump_pod {
         }
         elsif ( $node->nodeName() eq "programlisting" ) {
             my $str = $node->string_value();
-	    $str =~ s/^\s+|\s+$//g;
+            $str =~ s/^\s+|\s+$//g;
             $str =~ s/\n/\n  /g;
-	    $str=~s/(^|\n)[ \t]+($|\n)/$1$2/g;
+            $str=~s/(^|\n)[ \t]+($|\n)/$1$2/g;
             $self->{OFILE}->print( "\n\n" );
             $self->{OFILE}->print( "  ". $str );
             $self->{OFILE}->print( "\n\n" );
         }
-	elsif ( $node->nodeName() eq "funcsynopsis") {
+        elsif ( $node->nodeName() eq "funcsynopsis") {
             if (($node->getAttribute('role')||'') ne 'synopsis') {
               $self->dump_pod($node);
               $self->{OFILE}->print( "\n" );
@@ -468,57 +476,57 @@ sub dump_pod {
             $str =~ s/\n/\n  /g;
             $self->{OFILE}->print( "  $str\n" );
         } elsif(  $node->nodeName() eq "title" or
-		  $node->nodeName() eq "titleabbrev"
-		 ) {
-	  # IGNORE
+                  $node->nodeName() eq "titleabbrev"
+                 ) {
+          # IGNORE
         } elsif(  $node->nodeName() eq "emphasis" ) {
             my $str = $node->string_value() ;
             $str =~ s/\n/ /g;
             $self->{OFILE}->print( "I<<<<<< $str >>>>>>" );
         } elsif(  $node->nodeName() eq "function" or
-		  $node->nodeName() eq "email" or
-		  $node->nodeName() eq "literal"
-	       ) {
+                  $node->nodeName() eq "email" or
+                  $node->nodeName() eq "literal"
+               ) {
             my $str = $node->string_value() ;
             $str =~ s/\n/ /g;
             $self->{OFILE}->print( "C<<<<<< $str >>>>>>" );
         } elsif(  $node->nodeName() eq "ulink" ) {
             my $str = $node->string_value() ;
-	    my $url = $node->getAttribute('url');
+            my $url = $node->getAttribute('url');
             $str =~ s/\n/ /g;
-	    if ($str eq $url) {
-	      $self->{OFILE}->print( "L<<<<<< $url >>>>>>" );
-	    } else {
-	      $self->{OFILE}->print( "$str (L<<<<<< $url >>>>>>)" );
-	    }
+            if ($str eq $url) {
+              $self->{OFILE}->print( "L<<<<<< $url >>>>>>" );
+            } else {
+              $self->{OFILE}->print( "$str (L<<<<<< $url >>>>>>)" );
+            }
         } elsif(  $node->nodeName() eq "xref" ) {
-	    my $linkend = $node->getAttribute('linkend');
-	    my ($target) = $node->findnodes(qq(//*[\@id="$linkend"]/titleabbrev));
-	    ($target) = $node->findnodes(qq(//*[\@id="$linkend"]/title)) unless $target;
-	    if ($target) {
-	      my $str = $target->string_value() ;
-	      $str =~ s/\n/ /g;
-	      $self->{OFILE}->print( "L<<<<<< $str >>>>>>" );
-	    } else {
-	      warn "WARNING: Didn't find any section with id='$linkend'\n";
-	      $self->{OFILE}->print( "$linkend" );
-	    }
+            my $linkend = $node->getAttribute('linkend');
+            my ($target) = $node->findnodes(qq(//*[\@id="$linkend"]/titleabbrev));
+            ($target) = $node->findnodes(qq(//*[\@id="$linkend"]/title)) unless $target;
+            if ($target) {
+              my $str = $target->string_value() ;
+              $str =~ s/\n/ /g;
+              $self->{OFILE}->print( "L<<<<<< $str >>>>>>" );
+            } else {
+              warn "WARNING: Didn't find any section with id='$linkend'\n";
+              $self->{OFILE}->print( "$linkend" );
+            }
         } elsif(  $node->nodeName() eq "olink" ) {
             my $str = $node->string_value() ;
-	    my $url = $node->getAttribute('targetdoc');
-	    if (!defined $url) {
-	      warn $node->toString(1),"\n";
-	    }
+            my $url = $node->getAttribute('targetdoc');
+            if (!defined $url) {
+              warn $node->toString(1),"\n";
+            }
             $str =~ s/\n/ /g;
-	    if ($str eq $url) {
-	      $self->{OFILE}->print( "L<<<<<< $url >>>>>>" );
-	    } else {
-	      $self->{OFILE}->print( "$str (L<<<<<< $url >>>>>>)" );
-	    }
+            if ($str eq $url) {
+              $self->{OFILE}->print( "L<<<<<< $url >>>>>>" );
+            } else {
+              $self->{OFILE}->print( "$str (L<<<<<< $url >>>>>>)" );
+            }
         } else {
-	  print STDERR "Ignoring ",$node->nodeName(),"\n";
-	  $self->dump_pod($node);
-	}
+          print STDERR "Ignoring ",$node->nodeName(),"\n";
+          $self->dump_pod($node);
+        }
     }
 }
 
@@ -5,6 +5,8 @@ Devel::CheckLib;
 
 use 5.00405; #postfix foreach
 use strict;
+use warnings;
+
 use vars qw($VERSION @ISA @EXPORT);
 $VERSION = '1.01';
 use Config qw(%Config);
@@ -121,7 +121,7 @@ Petr Pajas
 
 =head1 VERSION
 
-2.0108
+2.0116
 
 =head1 COPYRIGHT
 
@@ -132,3 +132,10 @@ Petr Pajas
 2006-2009, Petr Pajas.
 
 =cut
+
+
+=head1 LICENSE
+
+This program is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
@@ -7,7 +7,7 @@ use Tie::Hash;
 our @ISA = qw/Tie::Hash/;
 
 use vars qw($VERSION);
-$VERSION = "2.0108"; # VERSION TEMPLATE: DO NOT CHANGE
+$VERSION = "2.0116"; # VERSION TEMPLATE: DO NOT CHANGE
 
 BEGIN
 {
@@ -12,10 +12,11 @@ package XML::LibXML::Boolean;
 use XML::LibXML::Number;
 use XML::LibXML::Literal;
 use strict;
+use warnings;
 
 use vars qw ($VERSION);
 
-$VERSION = "2.0108"; # VERSION TEMPLATE: DO NOT CHANGE
+$VERSION = "2.0116"; # VERSION TEMPLATE: DO NOT CHANGE
 
 use overload
         '""' => \&value,
@@ -45,7 +45,7 @@ Petr Pajas
 
 =head1 VERSION
 
-2.0108
+2.0116
 
 =head1 COPYRIGHT
 
@@ -56,3 +56,10 @@ Petr Pajas
 2006-2009, Petr Pajas.
 
 =cut
+
+
+=head1 LICENSE
+
+This program is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
@@ -46,7 +46,7 @@ Petr Pajas
 
 =head1 VERSION
 
-2.0108
+2.0116
 
 =head1 COPYRIGHT
 
@@ -57,3 +57,10 @@ Petr Pajas
 2006-2009, Petr Pajas.
 
 =cut
+
+
+=head1 LICENSE
+
+This program is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
@@ -16,6 +16,7 @@ package XML::LibXML::Common;
 # global blur                                                             #
 #-------------------------------------------------------------------------#
 use strict;
+use warnings;
 
 require Exporter;
 require DynaLoader;
@@ -23,7 +24,7 @@ use vars qw( @ISA $VERSION @EXPORT @EXPORT_OK %EXPORT_TAGS);
 
 @ISA = qw(Exporter);
 
-$VERSION = "2.0108"; # VERSION TEMPLATE: DO NOT CHANGE
+$VERSION = "2.0116"; # VERSION TEMPLATE: DO NOT CHANGE
 
 use XML::LibXML qw(:libxml);
 
@@ -116,7 +116,7 @@ Petr Pajas
 
 =head1 VERSION
 
-2.0108
+2.0116
 
 =head1 COPYRIGHT
 
@@ -127,3 +127,10 @@ Petr Pajas
 2006-2009, Petr Pajas.
 
 =cut
+
+
+=head1 LICENSE
+
+This program is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
@@ -129,7 +129,7 @@ Petr Pajas
 
 =head1 VERSION
 
-2.0108
+2.0116
 
 =head1 COPYRIGHT
 
@@ -140,3 +140,10 @@ Petr Pajas
 2006-2009, Petr Pajas.
 
 =cut
+
+
+=head1 LICENSE
+
+This program is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
@@ -12,7 +12,7 @@ use warnings;
 use XML::LibXML;
 
 use vars qw ($VERSION);
-$VERSION = "2.0108"; # VERSION TEMPLATE: DO NOT CHANGE
+$VERSION = "2.0116"; # VERSION TEMPLATE: DO NOT CHANGE
 
 use 5.008_000;
 
@@ -683,7 +683,7 @@ Petr Pajas
 
 =head1 VERSION
 
-2.0108
+2.0116
 
 =head1 COPYRIGHT
 
@@ -694,3 +694,10 @@ Petr Pajas
 2006-2009, Petr Pajas.
 
 =cut
+
+
+=head1 LICENSE
+
+This program is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
@@ -27,7 +27,7 @@ Petr Pajas
 
 =head1 VERSION
 
-2.0108
+2.0116
 
 =head1 COPYRIGHT
 
@@ -38,3 +38,10 @@ Petr Pajas
 2006-2009, Petr Pajas.
 
 =cut
+
+
+=head1 LICENSE
+
+This program is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
@@ -89,7 +89,7 @@ Petr Pajas
 
 =head1 VERSION
 
-2.0108
+2.0116
 
 =head1 COPYRIGHT
 
@@ -100,3 +100,10 @@ Petr Pajas
 2006-2009, Petr Pajas.
 
 =cut
+
+
+=head1 LICENSE
+
+This program is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
@@ -382,7 +382,7 @@ Petr Pajas
 
 =head1 VERSION
 
-2.0108
+2.0116
 
 =head1 COPYRIGHT
 
@@ -393,3 +393,10 @@ Petr Pajas
 2006-2009, Petr Pajas.
 
 =cut
+
+
+=head1 LICENSE
+
+This program is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
@@ -11,9 +11,10 @@
 package XML::LibXML::ErrNo;
 
 use strict;
+use warnings;
 use vars qw($VERSION);
 
-$VERSION = "2.0108"; # VERSION TEMPLATE: DO NOT CHANGE
+$VERSION = "2.0116"; # VERSION TEMPLATE: DO NOT CHANGE
 
 use constant ERR_OK                               => 0;
 use constant ERR_INTERNAL_ERROR                   => 1;
@@ -14,7 +14,7 @@ Petr Pajas
 
 =head1 VERSION
 
-2.0108
+2.0116
 
 =head1 COPYRIGHT
 
@@ -25,3 +25,10 @@ Petr Pajas
 2006-2009, Petr Pajas.
 
 =cut
+
+
+=head1 LICENSE
+
+This program is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
@@ -29,7 +29,7 @@ use overload
   fallback => 1;
 
 $WARNINGS = 0; # 0: suppress, 1: report via warn, 2: report via die
-$VERSION = "2.0108"; # VERSION TEMPLATE: DO NOT CHANGE
+$VERSION = "2.0116"; # VERSION TEMPLATE: DO NOT CHANGE
 
 use constant XML_ERR_NONE            => 0;
 use constant XML_ERR_WARNING         => 1; # A simple warning
@@ -244,7 +244,7 @@ Petr Pajas
 
 =head1 VERSION
 
-2.0108
+2.0116
 
 =head1 COPYRIGHT
 
@@ -255,3 +255,10 @@ Petr Pajas
 2006-2009, Petr Pajas.
 
 =cut
+
+
+=head1 LICENSE
+
+This program is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
@@ -280,7 +280,7 @@ Petr Pajas
 
 =head1 VERSION
 
-2.0108
+2.0116
 
 =head1 COPYRIGHT
 
@@ -291,3 +291,10 @@ Petr Pajas
 2006-2009, Petr Pajas.
 
 =cut
+
+
+=head1 LICENSE
+
+This program is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
@@ -8,12 +8,15 @@
 #
 
 package XML::LibXML::Literal;
+
 use XML::LibXML::Boolean;
 use XML::LibXML::Number;
+
 use strict;
+use warnings;
 
 use vars qw ($VERSION);
-$VERSION = "2.0108"; # VERSION TEMPLATE: DO NOT CHANGE
+$VERSION = "2.0116"; # VERSION TEMPLATE: DO NOT CHANGE
 
 use overload
 		'""' => \&value,
@@ -141,7 +141,7 @@ Petr Pajas
 
 =head1 VERSION
 
-2.0108
+2.0116
 
 =head1 COPYRIGHT
 
@@ -152,3 +152,10 @@ Petr Pajas
 2006-2009, Petr Pajas.
 
 =cut
+
+
+=head1 LICENSE
+
+This program is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
@@ -763,7 +763,7 @@ Petr Pajas
 
 =head1 VERSION
 
-2.0108
+2.0116
 
 =head1 COPYRIGHT
 
@@ -774,3 +774,10 @@ Petr Pajas
 2006-2009, Petr Pajas.
 
 =cut
+
+
+=head1 LICENSE
+
+This program is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
@@ -17,7 +17,7 @@ use XML::LibXML::Literal;
 use XML::LibXML::Number;
 
 use vars qw($VERSION);
-$VERSION = "2.0108"; # VERSION TEMPLATE: DO NOT CHANGE
+$VERSION = "2.0116"; # VERSION TEMPLATE: DO NOT CHANGE
 
 use overload
         '""' => \&to_literal,
@@ -11,9 +11,10 @@ package XML::LibXML::Number;
 use XML::LibXML::Boolean;
 use XML::LibXML::Literal;
 use strict;
+use warnings;
 
 use vars qw ($VERSION);
-$VERSION = "2.0108"; # VERSION TEMPLATE: DO NOT CHANGE
+$VERSION = "2.0116"; # VERSION TEMPLATE: DO NOT CHANGE
 
 use overload
         '""' => \&value,
@@ -74,7 +74,7 @@ Petr Pajas
 
 =head1 VERSION
 
-2.0108
+2.0116
 
 =head1 COPYRIGHT
 
@@ -85,3 +85,10 @@ Petr Pajas
 2006-2009, Petr Pajas.
 
 =cut
+
+
+=head1 LICENSE
+
+This program is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
@@ -984,7 +984,7 @@ Petr Pajas
 
 =head1 VERSION
 
-2.0108
+2.0116
 
 =head1 COPYRIGHT
 
@@ -995,3 +995,10 @@ Petr Pajas
 2006-2009, Petr Pajas.
 
 =cut
+
+
+=head1 LICENSE
+
+This program is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
@@ -94,7 +94,7 @@ Petr Pajas
 
 =head1 VERSION
 
-2.0108
+2.0116
 
 =head1 COPYRIGHT
 
@@ -105,3 +105,10 @@ Petr Pajas
 2006-2009, Petr Pajas.
 
 =cut
+
+
+=head1 LICENSE
+
+This program is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
@@ -14,7 +14,7 @@ use strict;
 use warnings;
 
 use vars qw ($VERSION);
-$VERSION = "2.0108"; # VERSION TEMPLATE: DO NOT CHANGE
+$VERSION = "2.0116"; # VERSION TEMPLATE: DO NOT CHANGE
 
 use 5.008_000;
 
@@ -656,7 +656,7 @@ Petr Pajas
 
 =head1 VERSION
 
-2.0108
+2.0116
 
 =head1 COPYRIGHT
 
@@ -667,3 +667,10 @@ Petr Pajas
 2006-2009, Petr Pajas.
 
 =cut
+
+
+=head1 LICENSE
+
+This program is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
@@ -58,7 +58,7 @@ Petr Pajas
 
 =head1 VERSION
 
-2.0108
+2.0116
 
 =head1 COPYRIGHT
 
@@ -69,3 +69,10 @@ Petr Pajas
 2006-2009, Petr Pajas.
 
 =cut
+
+
+=head1 LICENSE
+
+This program is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
@@ -70,7 +70,7 @@ Petr Pajas
 
 =head1 VERSION
 
-2.0108
+2.0116
 
 =head1 COPYRIGHT
 
@@ -81,3 +81,10 @@ Petr Pajas
 2006-2009, Petr Pajas.
 
 =cut
+
+
+=head1 LICENSE
+
+This program is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
@@ -9,6 +9,9 @@
 
 package XML::LibXML::SAX::Builder;
 
+use strict;
+use warnings;
+
 use XML::LibXML;
 use XML::NamespaceSupport;
 
@@ -18,7 +21,7 @@ sub CLONE_SKIP {
   return $XML::LibXML::__threads_shared ? 0 : 1;
 }
 
-$VERSION = "2.0108"; # VERSION TEMPLATE: DO NOT CHANGE
+$VERSION = "2.0116"; # VERSION TEMPLATE: DO NOT CHANGE
 
 sub new {
     my $class = shift;
@@ -38,7 +38,7 @@ Petr Pajas
 
 =head1 VERSION
 
-2.0108
+2.0116
 
 =head1 COPYRIGHT
 
@@ -49,3 +49,10 @@ Petr Pajas
 2006-2009, Petr Pajas.
 
 =cut
+
+
+=head1 LICENSE
+
+This program is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
@@ -10,11 +10,12 @@
 package XML::LibXML::SAX::Generator;
 
 use strict;
+use warnings;
 
 use XML::LibXML;
 use vars qw ($VERSION);
 
-$VERSION = "2.0108"; # VERSION TEMPLATE: DO NOT CHANGE
+$VERSION = "2.0116"; # VERSION TEMPLATE: DO NOT CHANGE
 
 sub CLONE_SKIP {
   return $XML::LibXML::__threads_shared ? 0 : 1;
@@ -10,6 +10,7 @@
 package XML::LibXML::SAX::Parser;
 
 use strict;
+use warnings;
 use vars qw($VERSION @ISA);
 
 use XML::LibXML;
@@ -17,7 +18,7 @@ use XML::LibXML::Common qw(:libxml);
 use XML::SAX::Base;
 use XML::SAX::DocumentLocator;
 
-$VERSION = "2.0108"; # VERSION TEMPLATE: DO NOT CHANGE
+$VERSION = "2.0116"; # VERSION TEMPLATE: DO NOT CHANGE
 @ISA = ('XML::SAX::Base');
 
 sub CLONE_SKIP {
@@ -10,9 +10,11 @@
 package XML::LibXML::SAX;
 
 use strict;
+use warnings;
+
 use vars qw($VERSION @ISA);
 
-$VERSION = "2.0108"; # VERSION TEMPLATE: DO NOT CHANGE
+$VERSION = "2.0116"; # VERSION TEMPLATE: DO NOT CHANGE
 
 use XML::LibXML;
 use XML::SAX::Base;
@@ -47,7 +47,7 @@ Petr Pajas
 
 =head1 VERSION
 
-2.0108
+2.0116
 
 =head1 COPYRIGHT
 
@@ -58,3 +58,10 @@ Petr Pajas
 2006-2009, Petr Pajas.
 
 =cut
+
+
+=head1 LICENSE
+
+This program is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
@@ -66,7 +66,7 @@ Petr Pajas
 
 =head1 VERSION
 
-2.0108
+2.0116
 
 =head1 COPYRIGHT
 
@@ -77,3 +77,10 @@ Petr Pajas
 2006-2009, Petr Pajas.
 
 =cut
+
+
+=head1 LICENSE
+
+This program is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
@@ -170,7 +170,7 @@ Petr Pajas
 
 =head1 VERSION
 
-2.0108
+2.0116
 
 =head1 COPYRIGHT
 
@@ -181,3 +181,10 @@ Petr Pajas
 2006-2009, Petr Pajas.
 
 =cut
+
+
+=head1 LICENSE
+
+This program is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
@@ -10,13 +10,14 @@
 package XML::LibXML::XPathContext;
 
 use strict;
+use warnings;
 use vars qw($VERSION @ISA $USE_LIBXML_DATA_TYPES);
 
 use Carp;
 use XML::LibXML;
 use XML::LibXML::NodeList;
 
-$VERSION = "2.0108"; # VERSION TEMPLATE: DO NOT CHANGE
+$VERSION = "2.0116"; # VERSION TEMPLATE: DO NOT CHANGE
 
 # should LibXML XPath data types be used for simple objects
 # when passing parameters to extension functions (default: no)
@@ -359,7 +359,7 @@ Petr Pajas
 
 =head1 VERSION
 
-2.0108
+2.0116
 
 =head1 COPYRIGHT
 
@@ -370,3 +370,10 @@ Petr Pajas
 2006-2009, Petr Pajas.
 
 =cut
+
+
+=head1 LICENSE
+
+This program is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
@@ -52,7 +52,7 @@ Petr Pajas
 
 =head1 VERSION
 
-2.0108
+2.0116
 
 =head1 COPYRIGHT
 
@@ -63,3 +63,10 @@ Petr Pajas
 2006-2009, Petr Pajas.
 
 =cut
+
+
+=head1 LICENSE
+
+This program is free software; you can redistribute it and/or modify it under
+the same terms as Perl itself.
+
@@ -7,7 +7,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 531;
+use Test::More tests => 533;
 use IO::File;
 
 use XML::LibXML::Common qw(:libxml);
@@ -940,6 +940,18 @@ EOXML
 
 }
 
+{
+    my $parser = XML::LibXML->new();
+    open(my $fh, '<:utf8', 't/data/chinese.xml');
+    ok( $fh, 'open chinese.xml');
+    eval {
+        $parser->parse_fh($fh);
+    };
+    like( $@, qr/Read more bytes than requested/,
+          'UTF-8 encoding layer throws exception' );
+    close($fh);
+}
+
 sub tsub {
     my $doc = shift;
 
@@ -11,7 +11,7 @@
 # since all tests are run on a preparsed
 
 # Should be 166.
-use Test::More tests => 194;
+use Test::More tests => 195;
 
 use XML::LibXML;
 use XML::LibXML::Common qw(:libxml);
@@ -713,3 +713,13 @@ EOF
     }
 }
 
+{
+    # RT #94149
+    # https://rt.cpan.org/Ticket/Display.html?id=94149
+
+    my $orig = XML::LibXML::Text->new('Double ');
+    my $ret = $orig->addSibling(XML::LibXML::Text->new('Free'));
+    # TEST
+    is( $ret->textContent, 'Double Free', 'merge text nodes with addSibling' );
+}
+
@@ -6,7 +6,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 36;
+use Test::More tests => 58;
 
 use XML::LibXML;
 
@@ -27,8 +27,11 @@ my $doc = XML::LibXML::Document->new();
     my $tnstr = $textnode->substringData( 1,2 );
     # TEST
     is( $tnstr , "oo", 'substring 1');
+    $tnstr = $textnode->substringData( 0,3 );
     # TEST
-    is( $textnode->nodeValue(), $foo,  'substring 2' );
+    is( $tnstr , "foo", 'substring 2');
+    # TEST
+    is( $textnode->nodeValue(), $foo,  'substring - text node unchanged' );
 
     # 3. Expansion
     $textnode->appendData( $foo );
@@ -145,6 +148,122 @@ my $doc = XML::LibXML::Document->new();
 }
 
 {
+    # UTF-8 tests
+
+    my $test_str  = "te\xDFt";
+    # Latin1 strings still fail.
+    utf8::upgrade($test_str);
+
+    # 1. creation
+    my $textnode = $doc->createTextNode($test_str);
+    # TEST
+    ok( $textnode, 'UTF-8 creation 1');
+    # TEST
+    is( $textnode->nodeValue(), $test_str,  'UTF-8 creation 2',);
+    my $foo_str = "\x{0444}oo\x{0431}ar";
+    $textnode = $doc->createTextNode($foo_str);
+    # TEST
+    ok( $textnode, 'UTF-8 creation 3');
+    # TEST
+    is( $textnode->nodeValue(), $foo_str,  'UTF-8 creation 4',);
+
+    # 2. substring
+    my $tnstr = $textnode->substringData( 1,2 );
+    # TEST
+    is( $tnstr , "oo", 'UTF-8 substring 1');
+    $tnstr = $textnode->substringData( 0,3 );
+    # TEST
+    is( $tnstr , "\x{0444}oo", 'UTF-8 substring 2');
+
+    # 3. Expansion
+    $textnode->appendData( $foo_str );
+    # TEST
+    is( $textnode->nodeValue(), $foo_str . $foo_str, 'UTF-8 expansion 1');
+
+    my $ins_str = "\x{0424}OO";
+    $textnode->insertData( 6, $ins_str );
+    # TEST
+    is( $textnode->nodeValue(), $foo_str.$ins_str.$foo_str,
+        'UTF-8 expansion 2' );
+
+    $textnode->setData( $foo_str );
+    $textnode->insertData( 6, $ins_str );
+    # TEST
+    is( $textnode->nodeValue(), $foo_str.$ins_str, 'UTF-8 expansion 3');
+
+    # 4. Removal
+    $textnode->setData( $foo_str );
+    $textnode->deleteData( 1,3 );
+    # TEST
+    is( $textnode->nodeValue(), "\x{0444}ar", 'UTF-8 Removal 1');
+    $textnode->setData( $foo_str );
+    $textnode->deleteData( 1,10 );
+    # TEST
+    is( $textnode->nodeValue(), "\x{0444}", 'UTF-8 Removal 2');
+    $textnode->setData( $foo_str );
+    $textnode->deleteData( 6,100 );
+    # TEST
+    is( $textnode->nodeValue(), $foo_str, 'UTF-8 Removal 3');
+
+    # 5. Replacement
+    my $phish_str = "ph\x{2160}sh";
+    $textnode->setData( $test_str );
+    $textnode->replaceData( 1,2, $phish_str );
+    # TEST
+    is( $textnode->nodeValue(), "t".$phish_str."t", 'UTF-8 Replacement 1');
+    $textnode->setData( $test_str );
+    $textnode->replaceData( 1,4, $phish_str );
+    # TEST
+    is( $textnode->nodeValue(), "t".$phish_str, 'UTF-8 Replacement 2');
+    $textnode->setData( $test_str );
+    $textnode->replaceData( 1,0, $phish_str );
+    # TEST
+    is( $textnode->nodeValue(), "t".$phish_str."e\xDFt",
+        'UTF-8 Replacement 3');
+
+    # 6. XML::LibXML features
+    $textnode->setData( $test_str );
+
+    my $new_str = "n\x{1D522}w";
+    $textnode->replaceDataString( "e\xDF", $new_str );
+    # TEST
+    is( $textnode->nodeValue(), "t".$new_str."t",
+        'UTF-8 replaceDataString() 1');
+
+    $textnode->replaceDataRegEx( 'n(.)w', '$1s' );
+    # TEST
+    is( $textnode->nodeValue(), "t\x{1D522}st", 'UTF-8 replaceDataRegEx() 2');
+
+    $textnode->setData( "blue $phish_str, white $phish_str, no $phish_str" );
+    $textnode->replaceDataRegEx( $phish_str, $test_str );
+    # TEST
+    is( $textnode->nodeValue(),
+        "blue $test_str, white $phish_str, no $phish_str",
+        'UTF-8 replaceDataRegEx 3',);
+
+    # replace them all!
+    $textnode->replaceDataRegEx( $phish_str, $test_str, 'g' );
+    # TEST
+    is( $textnode->nodeValue(),
+        "blue $test_str, white $test_str, no $test_str",
+        'UTF-8 replaceDataRegEx g',);
+
+    # check if deleteDataString works
+    my $hit_str = "hi\x{1D54B}";
+    my $pit_str = "\x{2119}it";
+    $textnode->setData( "$hit_str$pit_str$hit_str" );
+    $textnode->deleteDataString( $hit_str );
+    # TEST
+    is( $textnode->nodeValue(), "$pit_str$hit_str", 'UTF-8 deleteDataString 1' );
+
+    # check if deleteDataString all works
+    $textnode->setData( "$hit_str$pit_str$hit_str" );
+    $textnode->deleteDataString( $hit_str, 1 );
+    # TEST
+    is( $textnode->nodeValue(), $pit_str, 'UTF-8 deleteDataString 2' );
+}
+
+{
     # standalone test
     my $node = XML::LibXML::Text->new("foo");
     # TEST
@@ -3,8 +3,8 @@
 use strict;
 use warnings;
 
-# Should be 38.
-use Test::More tests => 38;
+# Should be 54.
+use Test::More tests => 54;
 
 use lib './t/lib';
 use TestHelpers;
@@ -219,3 +219,115 @@ EOF
         ok( $@, ' TODO : Add test name' );
     }
 }
+
+{
+    # RT #71076: https://rt.cpan.org/Public/Bug/Display.html?id=71076
+
+    my $parser = XML::LibXML->new();
+    my $doc = $parser->parse_string(<<'EOF');
+<!DOCTYPE test [
+ <!ELEMENT test (#PCDATA)>
+ <!ATTLIST test
+  attr CDATA #IMPLIED
+ >
+]>
+<test>
+</test>
+EOF
+    my $dtd = $doc->internalSubset;
+
+    # TEST
+    ok( !$dtd->hasAttributes, 'hasAttributes' );
+    # TEST
+    is_deeply( [ $dtd->attributes ], [], 'attributes' );
+}
+
+# Remove DTD nodes
+
+sub test_remove_dtd {
+    my ($test_name, $remove_sub) = @_;
+
+    my $parser = XML::LibXML->new;
+    my $doc    = $parser->parse_file('example/dtd.xml');
+    my $dtd    = $doc->internalSubset;
+
+    $remove_sub->($doc, $dtd);
+
+    # TEST*3
+    ok( !$doc->internalSubset, "remove DTD via $test_name" );
+}
+
+test_remove_dtd( "unbindNode", sub {
+    my ($doc, $dtd) = @_;
+    $dtd->unbindNode;
+} );
+test_remove_dtd( "removeChild", sub {
+    my ($doc, $dtd) = @_;
+    $doc->removeChild($dtd);
+} );
+test_remove_dtd( "removeChildNodes", sub {
+    my ($doc, $dtd) = @_;
+    $doc->removeChildNodes;
+} );
+
+# Insert DTD nodes
+
+sub test_insert_dtd {
+    my ($test_name, $insert_sub) = @_;
+
+    my $parser  = XML::LibXML->new;
+    my $src_doc = $parser->parse_file('example/dtd.xml');
+    my $dtd     = $src_doc->internalSubset;
+    my $doc     = $parser->parse_file('example/dtd.xml');
+
+    $insert_sub->($doc, $dtd);
+
+    # TEST*11
+    ok( $doc->internalSubset->isSameNode($dtd), "insert DTD via $test_name" );
+}
+
+test_insert_dtd( "insertBefore internalSubset", sub {
+    my ($doc, $dtd) = @_;
+    $doc->insertBefore($dtd, $doc->internalSubset);
+} );
+test_insert_dtd( "insertBefore documentElement", sub {
+    my ($doc, $dtd) = @_;
+    $doc->insertBefore($dtd, $doc->documentElement);
+} );
+test_insert_dtd( "insertAfter internalSubset", sub {
+    my ($doc, $dtd) = @_;
+    $doc->insertAfter($dtd, $doc->internalSubset);
+} );
+test_insert_dtd( "insertAfter documentElement", sub {
+    my ($doc, $dtd) = @_;
+    $doc->insertAfter($dtd, $doc->documentElement);
+} );
+test_insert_dtd( "replaceChild internalSubset", sub {
+    my ($doc, $dtd) = @_;
+    $doc->replaceChild($dtd, $doc->internalSubset);
+} );
+test_insert_dtd( "replaceChild documentElement", sub {
+    my ($doc, $dtd) = @_;
+    $doc->replaceChild($dtd, $doc->documentElement);
+} );
+test_insert_dtd( "replaceNode internalSubset", sub {
+    my ($doc, $dtd) = @_;
+    $doc->internalSubset->replaceNode($dtd);
+} );
+test_insert_dtd( "replaceNode documentElement", sub {
+    my ($doc, $dtd) = @_;
+    $doc->documentElement->replaceNode($dtd);
+} );
+test_insert_dtd( "appendChild", sub {
+    my ($doc, $dtd) = @_;
+    $doc->appendChild($dtd);
+} );
+test_insert_dtd( "addSibling internalSubset", sub {
+    my ($doc, $dtd) = @_;
+    $doc->internalSubset->addSibling($dtd);
+} );
+test_insert_dtd( "addSibling documentElement", sub {
+    my ($doc, $dtd) = @_;
+    $doc->documentElement->addSibling($dtd);
+} );
+
@@ -217,6 +217,11 @@ EOHTML
     SKIP:
     {
         my $num_tests = 2;
+
+        # LibXML_read_perl doesn't play well with encoding layers. Skip
+        # unconditionally for now.
+        skip("skipping until LibXML_read_perl is fixed", $num_tests);
+
         if (1000*$] < 5008)
         {
             skip("skipping for Perl < 5.8", $num_tests);
@@ -262,9 +267,15 @@ EOHTML
 
     SKIP:
     {
+        my $num_tests = 2;
+
+        # LibXML_read_perl doesn't play well with encoding layers. Skip
+        # unconditionally for now.
+        skip("skipping until LibXML_read_perl is fixed", $num_tests);
+
         if (1000*$] < 5008)
         {
-            skip("skipping for Perl < 5.8", 2);
+            skip("skipping for Perl < 5.8", $num_tests);
         }
         # translate to UTF8 on perl-side
         open my $fh, '<:encoding(iso-8859-2)', $test_file
@@ -15,7 +15,7 @@ use Test::More;
 use XML::LibXML;
 
 if ( XML::LibXML::LIBXML_VERSION >= 20510 ) {
-    plan tests => 6;
+    plan tests => 8;
 }
 else {
     plan skip_all => 'No Schema Support compiled.';
@@ -71,3 +71,44 @@ my $invalidfile  = "test/schema/invaliddemo.xml";
     ok ( $@, 'Invalid file throws an excpetion.');
 }
 
+# 4 validate a node
+{
+    my $doc = $xmlparser->load_xml(string => <<'EOF');
+<shiporder orderid="889923">
+  <orderperson>John Smith</orderperson>
+  <shipto>
+    <name>Ola Nordmann</name>
+  </shipto>
+</shiporder>
+EOF
+
+    my $schema = XML::LibXML::Schema->new(string => <<'EOF');
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+  <xs:element name="shiporder">
+    <xs:complexType>
+      <xs:sequence>
+        <xs:element name="orderperson" type="xs:string"/>
+        <xs:element ref="shipto"/>
+      </xs:sequence>
+      <xs:attribute name="orderid" type="xs:string" use="required"/>
+    </xs:complexType>
+  </xs:element>
+  <xs:element name="shipto">
+    <xs:complexType>
+      <xs:sequence>
+        <xs:element name="name" type="xs:string"/>
+      </xs:sequence>
+    </xs:complexType>
+  </xs:element>
+</xs:schema>
+EOF
+
+    my $nodelist = $doc->findnodes('/shiporder/shipto');
+    my $result = 1;
+    eval { $result = $schema->validate($nodelist->get_node(1)); };
+    # TEST
+    is( $@, '', 'validate() with element doesn\'t throw' );
+    # TEST
+    is( $result, 0, 'validate() with element returns 0' );
+}
+
@@ -263,8 +263,6 @@ sub is_xml_ordered
     return $comparator->compare();
 }
 
-1;
-
 my $xml_source = <<'EOF';
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
@@ -337,13 +335,21 @@ my $final_source = <<'EOF';
 </html>
 EOF
 
-my @common = (validation => 0, load_ext_dtd => 0, no_network => 1);
-# TEST
-Test::XML::Ordered::is_xml_ordered(
-    [ string => $final_source, @common,],
-    [ string => $xml_source, @common,],
-    "foo",
-);
+SKIP: {
+    # RT #84564
+    # https://bugzilla.gnome.org/show_bug.cgi?id=447899
+    if (XML::LibXML::LIBXML_RUNTIME_VERSION() < 20704) {
+        skip('Known double-free with libxml2 < 2.7.4', 1);
+    }
+
+    my @common = (validation => 0, load_ext_dtd => 0, no_network => 1);
+    # TEST
+    Test::XML::Ordered::is_xml_ordered(
+        [ string => $final_source, @common,],
+        [ string => $xml_source, @common,],
+        "foo",
+    );
+}
 
 # TEST
 ok (1, "Finished");
@@ -0,0 +1,32 @@
+#!/usr/bin/perl
+
+# Test for:
+# https://rt.cpan.org/Ticket/Display.html?id=93429
+#
+# Contributed by Nick Wellnhofer.
+
+use strict;
+use warnings;
+
+use Test::More tests => 1;
+
+use XML::LibXML;
+
+{
+    my $err_html = '<html><body><lkj/></body></html>';
+
+    my $parser = XML::LibXML->new();
+
+    my $buf = '';
+    open(my $fh, '>', \$buf);
+
+    {
+        local *STDERR = $fh;
+        $parser->load_html( string => $err_html, recover => 2, );
+    }
+
+    close($fh);
+
+    is($buf, '', 'No warning emitted on load_html with recover => 2.');
+}
+
@@ -0,0 +1,50 @@
+use strict;
+use warnings;
+
+use Test::More;
+use Config;
+
+BEGIN
+{
+    my $will_run = 0;
+    if ( $Config{useithreads} )
+    {
+        if ($ENV{THREAD_TEST})
+        {
+            require threads;
+            require threads::shared;
+            $will_run = 1;
+        }
+        else
+        {
+            plan skip_all => "optional (set THREAD_TEST=1 to run these tests)";
+        }
+    }
+    else
+    {
+        plan skip_all => "no ithreads in this Perl";
+    }
+
+    if ($will_run)
+    {
+        plan tests => 3;
+    }
+}
+
+use XML::LibXML qw(:threads_shared);
+
+# TEST
+ok(1, 'Loaded');
+
+my $p = XML::LibXML->new();
+
+# TEST
+ok($p, 'Parser initted.');
+
+{
+    my $doc = $p->parse_string(qq{<root><foo id="1">bar</foo></root>});
+    my $cloned = threads::shared::shared_clone($doc);
+
+    # TEST
+    ok(1,  "Shared clone");
+}
@@ -0,0 +1,19 @@
+# -*- cperl -*-
+
+##
+# This test checks that the XS code handles the perl stack correctly
+# when the module loads.  This failed in 5.19.6+.
+#
+# See: https://rt.cpan.org/Ticket/Display.html?id=92606 .
+
+use Test::More tests => 1;
+
+for (1) {
+    for (1,0) {
+        require XML::LibXML;
+    }
+}
+
+# If we get this far, then all is fine.
+# TEST
+pass("Loading XML::LibXML works inside multiple foreach loops");
@@ -0,0 +1,12 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More;
+
+eval 'use Test::CPAN::Changes 0.27';
+plan skip_all => 'Test::CPAN::Changes 0.27 required for this test' if $@;
+
+changes_ok();
+
@@ -0,0 +1,4 @@
+<chinese>
+    <characters>主題</characters>
+    <characters>關鍵詞</characters>
+</chinese>