Subject: | empty XHTML elements create malformed output |
Date: | Tue, 18 Oct 2011 13:29:54 +0300 |
To: | bug-HTML-FillInForm [...] rt.cpan.org |
From: | hhaamu [...] gmail.com |
When writing pure XHTML documents, you are allowed to shorthand
<option></option> (i.e. option with an empty "label") as <option/>.
These are not properly treated and result in malformed XML.
The problematic result for the script below is:
<option /="/" value="">
if the empty element is selected, the result is:
<option /="/" value="" selected="selected">
The desired output would be:
<option value="" selected="selected"/>
Adding a space to the XHTML tag (as is recommended for parser
compatibility; such as <br />) does not change the end result.
There may be other tags that break this way, but I could not find any
on a quick test.
This is with HTML::FillInForm 2.1, HTML::Parser 3.68, running on Perl
5.12.4.
Below is a simple test case:
use HTML::FillInForm;
my $html = <<'EOF';
<select name="sor">
<option value=""/>
<option value="3">foo</option>
<option value="5">bar</option>
<option value="6">baz</option>
</select>
EOF
my $q = { sor => 5 };
print HTML::FillInForm->fill( \$html, $q );