#39980 [NEW]: PHP functions that read xml try to validate that the namespace uri exsist,wrong

From: Date: Thu, 28 Dec 2006 19:48:38 +0000
Subject: #39980 [NEW]: PHP functions that read xml try to validate that the namespace uri exsist,wrong
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-106975@lists.php.net to get a copy of this message
From:             hatkyinc at gmail dot com
Operating system: Windows xp sp2
PHP version:      5.2.0
PHP Bug Type:     SimpleXML related
Bug description:  PHP functions that read xml try to validate that the namespace uri exsist,wrong

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">



-- 
Edit bug report at http://bugs.php.net/?id=39980&edit=1
-- 
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=39980&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=39980&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=39980&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=39980&r=fixedcvs
Fixed in release:             http://bugs.php.net/fix.php?id=39980&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=39980&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=39980&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=39980&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=39980&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=39980&r=notwrong
Not enough info:              http://bugs.php.net/fix.php?id=39980&r=notenoughinfo
Submitted twice:              http://bugs.php.net/fix.php?id=39980&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=39980&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=39980&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=39980&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=39980&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=39980&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=39980&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=39980&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=39980&r=mysqlcfg


Thread (4 messages)

« previous php.bugs (#106975) next »