Home » XML » XML_Parser » Bug #6078
func-mode does not handle all allowed letters in tags
Details
| Submitted | 2005-11-26 15:07 UTC |
|---|---|
| From | elandril at gmail dot com |
| Assigned | schst |
| Status | Closed |
| Package | XML_Parser |
| PHP Version | 4.3.11 |
| OS | Linux |
| Roadmaps | (Not assigned) |
Comments
[2005-11-26 15:07 UTC] elandril at gmail dot com
Description:
------------
The XML_Parser in func-mode cannot handle any tags containing the following letters '-' and ':'!
In the code there is a str_replace converting any '.' into an '_', but the two chars mentioned above are not converted.
XML allows tags using the schema
TagName ::= (Letter | '_' | ':')(NameChar)*
NameChar ::= Letter | Digit | '.' | '-' | '_' | ':' | OtherChars
Thus the str_replace (and the strchr used in the enclosing if) should be extended to convert at least '-' and ':'.
e.g.
OLD: str_replace('.', '_', $func)
NEW: str_replace( array('.', '-', '_'), '_', $func)
The documentation should be updated to include the replacement for these characters.
Test script:
---------------
$p =& new myParser;
$p->setmode('func');
$p->setInputFile('myfile.xml);
$p->parse();
myfile.xml:
<?xml version="1.0" ?>
<root-elem>
<my-tag>
</my-tag>
<tag:another>
</tag:another>
</root-elem>
Expected result:
----------------
the following function should be called:
$p->xmltag_root_elem
$p->xmltag_my_tag
$p->xmltag_my_tag_
$p->xmltag_tag_another
$p->xmltag_tag_another_
$p->xmltag_root_elem_
Actual result:
--------------
Multiple warnings of the type:
Warning: call_user_func(xmltag_my-tag): First argument is expected to be a valid callback in ...
Reason: PHP doesn't support '-' and ':' in function names.