Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.3.8

Bug #6078 func-mode does not handle all allowed letters in tags
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)    
Subscription  


 [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.

Comments

 [2006-12-01 16:51 UTC] schst (Stephan Schmidt)
Thank you for your bug report. This issue has been fixed in the latest released version of the package, which you can download at http://pear.php.net/get/XML_Parser