Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder gsnedders's Avatar
    Join Date
    Jan 2004
    Posts
    2,340
    Thanks
    1
    Thanked 7 Times in 7 Posts

    xml_set_external_entity_ref_handler() handler never called

    Under the following code, basic_parser::entity_ref() is never called, despite there being a PUBLIC/SYSTEM entity.
    PHP Code:
    <?php

    class basic_parser
    {
        function 
    parse($data$encoding)
        {
            
    $this->xml xml_parser_create_ns($encoding);
            
    xml_set_object($this->xml$this);
            
    xml_set_external_entity_ref_handler($this->xml'entity_ref');
            
    var_dump(xml_parse($this->xml$datatrue), xml_get_error_code($this->xml), xml_error_string(xml_get_error_code($this->xml)), xml_get_current_line_number($this->xml), xml_get_current_column_number($this->xml));
        }
        
        function 
    entity_ref($parser$open_entity_names$base$system_id$public_id)
        {
            
    var_dump($parser$open_entity_names$base$system_id$public_id);
        }
    }

    $parser = new basic_parser;

    $data '<?xml version="1.0" encoding="iso-8859-1"?>
    <!DOCTYPE rdf:RDF [
    <!ENTITY % HTMLlat1 PUBLIC
     "-//W3C//ENTITIES Latin 1 for XHTML//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent">
    %HTMLlat1;
    ]>
    <rdf:RDF
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns="http://purl.org/rss/1.0/"
    >
     <channel>
         <title>This&nbsp;That</title>
     </channel>
    </rdf:RDF>'
    ;

    $parser->parse($data'ISO-8859-1');

    ?>
    xml_parse() also manages to return 0, giving the script the following output:
    Code:
    int(0)
    int(26)
    string(23) "Undeclared entity error"
    int(7)
    int(3)
    Line 7 column 3 is the LF after the end of the DOCTYPE.

  • #2
    Senior Coder gsnedders's Avatar
    Join Date
    Jan 2004
    Posts
    2,340
    Thanks
    1
    Thanked 7 Times in 7 Posts
    Anyone at all?

  • #3
    Senior Coder gsnedders's Avatar
    Join Date
    Jan 2004
    Posts
    2,340
    Thanks
    1
    Thanked 7 Times in 7 Posts
    Well, having gone over this with a friend in IRC (slowly trying loads of possibilities), we've concluded that xml_set_external_entity_ref_handler()'s handler isn't called on either PHP 4.4.7 or PHP 5.2.2, that the DOCTYPE is never seen in PHP under PHP 5.2.2, and is partially within xml_set_default_handler()'s handler on PHP 4.4.7.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •