PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » XML » XML_DTD » Bug #3461

doublequote in DTD

Details

Request #3461doublequote in DTD
Submitted2005-02-14 13:38 UTC
Fromfauvet_b at 3ie dot org
Assignedifeghali
StatusBogus
PackageXML_DTD
PHP Version4.3.3
OSall
Roadmaps(Not assigned)

Comments

[2005-02-14 13:38 UTC] fauvet_b at 3ie dot org

Description:
------------
In the DTD to parse, if we have something like that:

<!ATTLIST elem attr CDATA #FIXED "sentence with spaces" >

the generated DTD_Tree is false, cutting value according to spaces...

Reproduce code:
---------------
I quickly fixed it by adding a new state in XML_DTD_Parser::parse() :
like the parenthesis and the $in/$out variables, i've created a $doublequote variable, added it in the splitting condition and added a test to set/unset this variable. The manual splitting modified is so:

for ($i = 0; $i < strlen($tag); $i++) {
if ($tag{$i} == ' ' && !$in && $buff && !$doublequote) {
$fields[] = $buff;
$buff = '';
continue;
}
if ($tag{$i} == '(') {
$in++;
} elseif ($tag{$i} == ')') {
$in--;
} elseif ($tag{$i} == '"') {
$doublequote = ($doublequote == 0) ? 1 : 0;
}
$buff .= $tag{$i};
}

Expected result:
----------------
When a fixed attribute value is surrounded by double quotes, manage it, so as to have a single value, not cut at the first space.

printing $data array in _ATTLIST() function, I obtain:
Array
(
[0] => attr
[1] => CDATA
[2] => #FIXED
[3] => "sentence
[4] => with
[5] => spaces"
)
and it would be better if it was:
Array
(
[0] => attr
[1] => CDATA
[2] => #FIXED
[3] => "sentence with spaces"
)