php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38580 Can't resolve external character entities
Submitted: 2006-08-24 10:30 UTC Modified: 2006-08-25 11:56 UTC
From: dandrikop at cosmote dot gr Assigned: rrichards (profile)
Status: Not a bug Package: DOM XML related
PHP Version: 5.1.5 OS: Fedora Core 5
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: dandrikop at cosmote dot gr
New email:
PHP Version: OS:

 

 [2006-08-24 10:30 UTC] dandrikop at cosmote dot gr
Description:
------------
The PHP DOM extension cannot resolve entities declared in an external DTD file.

Reproduce code:
---------------
<?php

        $imp = new DOMImplementation();
        $dtd = $imp->createDocumentType( 'clickAPI', null, 'clickatell.dtd' );

        $xml_request = $imp->createDocument( null, null, $dtd );
        $xml_request->version = '1.0';
        $xml_request->encoding = 'ISO-8859-1';
        $xml_request->formatOutput = true;
        $xml_request->resolveExternals = true;
        $xml_request->substituteEntities = true;
        $xml_request->standalone = false;


        // Create the tag 'clickAPI'.
        $clickAPI = $xml_request->appendChild(  new DOMElement( 'clickAPI' )  );

        // Create the tag 'sendMsg'.
        $sendMsg = $clickAPI->appendChild(  new DOMElement( 'sendMsg' )  );

        // Add elements under the 'auth' tag.
        $sendMsg->appendChild(  new DOMElement( 'session_id', 'aaaaaaaaaaaaaaaaa' )  );

        $sendMsg->appendChild(  new DOMElement( 'text', "Test &testme;" )  );

        $sendMsg->appendChild(  new DOMElement( 'to', '306978888888' )  );


        if( $xml_request->validate() ){
                echo "OK\n";
        } else {
                echo "Not OK!\n";
        }

        echo "\n" . $xml_request->saveXML() . "\n";
?>

Expected result:
----------------
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<!DOCTYPE clickAPI SYSTEM "clickatell.dtd">
<clickAPI>
  <sendMsg>
    <session_id>aaaaaaaaaaaaaaaaa</session_id>
    <text>Test HELLO</text>
    <to>306978888888</to>
  </sendMsg>
</clickAPI>

Actual result:
--------------
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<!DOCTYPE clickAPI SYSTEM "clickatell.dtd">
<clickAPI>
  <sendMsg>
    <session_id>aaaaaaaaaaaaaaaaa</session_id>
    <text>Test &testme;</text>
    <to>306978888888</to>
  </sendMsg>
</clickAPI>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-08-24 10:47 UTC] tony2001@php.net
Warning: DOMDocument::validate(): I/O warning : failed to load external entity "clickatell.dtd" in /tmp/1.php on line 33

Warning: DOMDocument::validate(): Could not load the external subset "clickatell.dtd" in /tmp/1.php on line 33
 [2006-08-24 10:49 UTC] dandrikop at cosmote dot gr
This is the "clickatell.dtd" file:


<?xml version="1.0" encoding="ISO-8859-1"?>
<!ELEMENT clickAPI (auth?, sendMsg?, queryMsg?, delMsg?, ping?, getBalance?, startBatch?, sendItem?, quickSend?, endBatch?, sendOTA?, authResp?, sendMsgResp?, queryMsgResp?, delMsgResp?, pingResp?, getBalanceResp?, startBatchResp?, sendItemResp?, quickSendResp?, endBatchResp?, sendOTAResp?)>
<!ELEMENT auth ((api_id, user, password), sequence_no?)>
<!ELEMENT authResp ((session_id | fault), sequence_no?)>
<!ELEMENT sendMsg (((api_id, user, password) | session_id), concat?, callback?, cliMsgId?, deliv_ack?, deliv_time?, escalate?, from?, max_credits?, msg_type?, queue?, req_feat?, text, to, udh?, unicode?, validity?, sequence_no?)>
<!ELEMENT sendMsgResp ((apiMsgId | fault), sequence_no?)>
<!ELEMENT delMsg (((api_id, user, password) | session_id), (cliMsgId | apiMsgId), sequence_no?)>
<!ELEMENT delMsgResp (((apiMsgId, status) | fault), sequence_no?)>
<!ELEMENT getBalance (((api_id, user, password) | session_id), sequence_no?)>
<!ELEMENT getBalanceResp ((ok | fault), sequence_no?)>
<!ELEMENT ping (session_id, sequence_no?)>
<!ELEMENT pingResp ((ok | fault), sequence_no?)>
<!ELEMENT tokenPay (session_id, token, sequence_no?)>
<!ELEMENT tokenPayResp ((ok | fault), sequence_no?)>
<!ELEMENT routeCoverage (msisdn, sequence_no?)>
<!ELEMENT routeCoverageResp ((ok | fault), sequence_no?)>
<!ELEMENT queryMsg (((api_id, user, password) | session_id), (cliMsgId | apiMsgId), sequence_no?)>
<!ELEMENT queryMsgResp (((apiMsgId, status) | fault), sequence_no?)>
<!ELEMENT startBatch (((api_id, user, password) | session_id), concat?, callback?, cliMsgId?, deliv_ack?, deliv_time?, escalate?, from?, max_credits?, msg_type?, queue?, req_feat?, template, udh?, unicode?, validity?, sequence_no?)>
<!ELEMENT startBatchResp ((batch_id | fault), sequence_no?)>
<!ELEMENT quickSend (((api_id, user, password) | session_id), batch_id, to, sequence_no?)>
<!ELEMENT quickSendResp ((apiMsgId | fault), sequence_no?)>
<!ELEMENT sendItem (((api_id, user, password) | session_id), batch_id, to, fields?, sequence_no?)>
<!ELEMENT sendItemResp ((apiMsgId | fault), sequence_no?)>
<!ELEMENT endBatch (((api_id, user, password) | session_id), batch_id, sequence_no?)>
<!ELEMENT endBatchResp ((ok | fault), sequence_no?)>
<!ELEMENT sendOTA (((api_id, user, password) | session_id), concat?, callback?, cliMsgId?, deliv_ack?, deliv_time?, validity?, from?, to, ota_type, name?, url?, bearer?, ppp_logintype?, ppp_authtype?, ppp_authname?, ppp_authsecret?, proxy?, csd_dialstring?, csd_callspeed?, csd_calltype?, proxy_type?, proxy_logintype?, proxy_authname?, proxy_authsecret?, port?, isp_name?, sms_smsc?, gprs_access?, xml?, sequence_no?)>
<!ELEMENT sendOTAResp ((apiMsgId | fault), sequence_no?)>
<!ELEMENT fields (#PCDATA | field1 | field2 | field3 | field4 | field5 | field6 | field7 | field8 | field9 | field10)*>
<!ELEMENT api_id (#PCDATA)>
<!ELEMENT apiMsgId (#PCDATA)>
<!ELEMENT batch_id (#PCDATA)>
<!ELEMENT bearer (#PCDATA)>
<!ELEMENT callback (#PCDATA)>
<!ELEMENT cliMsgId (#PCDATA)>
<!ELEMENT concat (#PCDATA)>
<!ELEMENT csd_callspeed (#PCDATA)>
<!ELEMENT csd_calltype  (#PCDATA)>
<!ELEMENT csd_dialstring  (#PCDATA)>
<!ELEMENT deliv_ack (#PCDATA)>
<!ELEMENT deliv_time (#PCDATA)>
<!ELEMENT escalate (#PCDATA)>
<!ELEMENT fault (#PCDATA)>
<!ELEMENT field1 (#PCDATA)>
<!ELEMENT field2 (#PCDATA)>
<!ELEMENT field3 (#PCDATA)>
<!ELEMENT field4 (#PCDATA)>
<!ELEMENT field5 (#PCDATA)>
<!ELEMENT field6 (#PCDATA)>
<!ELEMENT field7 (#PCDATA)>
<!ELEMENT field8 (#PCDATA)>
<!ELEMENT field9 (#PCDATA)>
<!ELEMENT field10 (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT gprs_access (#PCDATA)>
<!ELEMENT isp_name (#PCDATA)>
<!ELEMENT max_credits (#PCDATA)>
<!ELEMENT msg_type (#PCDATA)>
<!ELEMENT name  (#PCDATA)>
<!ELEMENT ok (#PCDATA)>
<!ELEMENT ota_type (#PCDATA)>
<!ELEMENT password (#PCDATA)>
<!ELEMENT port (#PCDATA)>
<!ELEMENT ppp_authname (#PCDATA)>
<!ELEMENT ppp_authsecret (#PCDATA)>
<!ELEMENT ppp_authtype (#PCDATA)>
<!ELEMENT ppp_logintype  (#PCDATA)>
<!ELEMENT proxy (#PCDATA)>
<!ELEMENT proxy_authname (#PCDATA)>
<!ELEMENT proxy_authsecret (#PCDATA)>
<!ELEMENT proxy_logintype (#PCDATA)>
<!ELEMENT proxy_type (#PCDATA)>
<!ELEMENT queue (#PCDATA)>
<!ELEMENT req_feat (#PCDATA)>
<!ELEMENT sequence_no (#PCDATA)>
<!ELEMENT session_id (#PCDATA)>
<!ELEMENT sms_smsc (#PCDATA)>
<!ELEMENT status (#PCDATA)>
<!ELEMENT text (#PCDATA)>
<!ELEMENT template (#PCDATA)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT udh (#PCDATA)>
<!ELEMENT unicode (#PCDATA)>
<!ELEMENT url (#PCDATA)>
<!ELEMENT user (#PCDATA)>
<!ELEMENT validity (#PCDATA)>
<!ELEMENT xml (#PCDATA)>
<!ENTITY testme "HELLO">
 [2006-08-25 11:56 UTC] rrichards@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

entities are only resolved/expanded (if requested) when the tree is being loaded into DOM; otherwise entity references are contained within the document. Sincde you are creating a document, entity references are added.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Fri Dec 04 03:01:23 2020 UTC