php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39980 PHP functions that read xml try to validate that the namespace uri exsist,wrong
Submitted: 2006-12-28 19:48 UTC Modified: 2006-12-28 21:52 UTC
From: hatkyinc at gmail dot com Assigned:
Status: Not a bug Package: SimpleXML related
PHP Version: 5.2.0 OS: Windows xp sp2
Private report: No CVE-ID: None
 [2006-12-28 19:48 UTC] hatkyinc at gmail dot com
Description:
------------
A lot of php functions that read xml try to validate that the uri exsist, which is wrong by w3.org.

If the xmlns uri is not valid the functions don't work at all.

Functions tried: 
SimpleXMLElement()
DOMDocument->loadHTMLFile()

I am opening this after opening a problem with w3.org which create the problematic xml, they realied the fallowing:

http://www.w3.org/2005/10/markup-validator is a namespace URI, and there is no
requirement for it to actually point to anything - it's just an identifier.  If
something makes an assumption that it can retrieve anything at all from a
namespace URI, it needs to be fixed not to assume that, let alone try it
automatically.

http://www.w3.org/TR/xml-names/
http://www.rpbourret.com/xml/NamespacesFAQ.htm#q12_3




Reproduce code:
---------------
a.xml

<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<env:Body>
<m:markupvalidationresponse env:encodingStyle="http://www.w3.org/2003/05/soap-encoding" xmlns:m="http://www.w3.org/2005/10/soap-encoding">
    <m:uri>http://www.microsoft.com/en/us/default.aspx</m:uri>
    <m:checkedby>http://validator.w3.org/</m:checkedby>
    <m:doctype>-//W3C//DTD HTML 4.0 Transitional//EN</m:doctype>
    <m:charset>utf-8</m:charset>
    <m:validity>false</m:validity>
    <m:errors>
        <m:errorcount>5</m:errorcount>
        <m:errorlist>
          
            <m:error>
                <m:line>1</m:line>
                <m:col>6012</m:col>                                           
                <m:message>there is no attribute &quot;TABINDEX&quot;</m:message>
            </m:error>
           
            <m:error>
                <m:line>1</m:line>
                <m:col>6116</m:col>                                           
                <m:message>document type does not allow element &quot;DIV&quot; here; missing one of &quot;APPLET&quot;, &quot;OBJECT&quot;, &quot;MAP&quot;, &quot;IFRAME&quot;, &quot;BUTTON&quot; start-tag</m:message>
            </m:error>
           
            <m:error>
                <m:line>1</m:line>
                <m:col>6154</m:col>                                           
                <m:message>document type does not allow element &quot;DIV&quot; here; missing one of &quot;APPLET&quot;, &quot;OBJECT&quot;, &quot;MAP&quot;, &quot;IFRAME&quot;, &quot;BUTTON&quot; start-tag</m:message>
            </m:error>
           
            <m:error>
                <m:line>1</m:line>
                <m:col>9671</m:col>                                           
                <m:message>there is no attribute &quot;TABINDEX&quot;</m:message>
            </m:error>
           
            <m:error>
                <m:line>1</m:line>
                <m:col>9744</m:col>                                           
                <m:message>there is no attribute &quot;ONFOCUS&quot;</m:message>
            </m:error>
           
        </m:errorlist>
    </m:errors>
    <m:warnings>
        <m:warningcount>0</m:warningcount>
        <m:warninglist>
        
        
        </m:warninglist>
    </m:warnings>
</m:markupvalidationresponse>
</env:Body>
</env:Envelope>


$uri ='c:\a.xml';

$handle = fopen($uri, "r");

$contents = '';
while (!feof($handle)) {
  $contents .= fread($handle, 8192);
}
fclose($handle);

//echo $contents;

$entries = new  SimpleXMLElement($contents);

$result= $entries->children('http://www.w3.org/2003/05/soap-envelope')->Body->children('http://www.w3.org/2003/05/soap-encoding')->markupvalidationresponse;
echo $result->uri ;

Expected result:
----------------
expected to put on screen
http://www.microsoft.com/en/us/default.aspx

Actual result:
--------------
Nothing is put on screen.

if you change a.xml line
<m:markupvalidationresponse env:encodingStyle="http://www.w3.org/2003/05/soap-encoding" xmlns:m="http://www.w3.org/2005/10/soap-encoding">

xmlns:m= uri to anything that validates this works 
example
<m:markupvalidationresponse env:encodingStyle="http://www.w3.org/2003/05/soap-encoding" xmlns:m="http://www.w3.org/2003/05/soap-encoding">



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-12-28 21:22 UTC] rrichards@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.


 [2006-12-28 21:38 UTC] hatkyinc at gmail dot com
I don't understand why you say this is not a problem in PHP?

I give here an exact code with a valid input and show it dosn't work and a case that is does work.

From my understanding there is either a problem in some XML validation or parsing code.

I don't see the reason for refering me to support, I show you a code that work and an exact case it breaks where is should still work and link to the reason why it is a valid case that should still work.

Please say why do you think is it ok for PHP not to work in this case (with this valide input XML)?
 [2006-12-28 21:52 UTC] rrichards@php.net
no bug here except in your code
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 13:01:30 2024 UTC