CC: | garfieldnate [...] gmail.com |
Subject: | HTML doctype differs for string/scalar input |
I wanted to output HTML with an HTML5 doctype. I discovered I could do that by creating a document with that doctype already there. However, if I create an HTML document with a string pointer instead of a string, the doctype is changed to another really really long doctype:
use strict;
use warnings;
use XML::LibXML;
my $parser = XML::LibXML->new();
my $from_scalar = $parser->load_html(string => '<!DOCTYPE html><html>');
my $from_ref = $parser->load_html(string => \'<!DOCTYPE html><html>');
print $from_scalar->toStringHTML;
print $from_ref->toStringHTML;
Adding a quick check and dereference after line 1086 of LibXML.pm fixed the problem, but I don't know if that's desirable, since large strings might be copied. I'm sorry I don't have the expertise to delve into the XS code.