#38410 [Opn->Asn]: PHP Interpreter Crash with schemaValidate on XML with CDATA sections.

From: Date: Thu, 10 Aug 2006 16:49:05 +0000
Subject: #38410 [Opn->Asn]: PHP Interpreter Crash with schemaValidate on XML with CDATA sections.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-100658@lists.php.net to get a copy of this message
 ID:               38410
 Updated by:       tony2001@php.net
 Reported By:      adam at sccode dot com
-Status:           Open
+Status:           Assigned
 Bug Type:         Reproducible crash
 Operating System: Windows 2000/XP/2003
 PHP Version:      5.1.4
-Assigned To:      
+Assigned To:      edink
 New Comment:

I can reproduce it with libxml2-2.6.22, but not with libxml2-2.6.23. 
So, apparently this is libxml2 bug and win32 builds should use a newer
libxml2 version (2.6.26 is the latest one at the moment).


Previous Comments:
------------------------------------------------------------------------

[2006-08-10 16:05:26] adam at sccode dot com

Using the latest Windows Snapshot (5.2.0RC2-dev - Build: Aug 10 2006
16:15:11) I receive the same error. Note that removing the whitespace
before the CDATA section does eliminate the problem and could be used
as a workaround:

Crashes interpreter:
<?xml version="1.0"?>
<test xmlns="http://www.php.net/bugtests">
	<value>
		<![CDATA[ 
			test 
			]]>
	</value>
 
</test>

Works:
<?xml version="1.0"?>
<test xmlns="http://www.php.net/bugtests">
	<value><![CDATA[ 
			test 
			]]>
	</value>
 
</test>

As the XML specification allows for whitespace after tags, I don't
think the interpreter should crash upon encountering these.

------------------------------------------------------------------------

[2006-08-10 13:51:01] tony2001@php.net

Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip

Cannot reproduce.

------------------------------------------------------------------------

[2006-08-10 11:14:28] adam at sccode dot com

Description:
------------
Attempting to validate an XML document against a schema containing a
CDATA section with whitespace preceeding the opening tag causes the PHP
Interpreter to crash with an exception in Windows 2000/XP and 2003 on
both IIS and Apache.

Example:
<?xml version="1.0"?>
<test xmlns="http://www.php.net/bugtests">
	<value>
		<![CDATA[ 
			test 
			]]>
	</value>
 
</test>

Validating the schema using xmllint with libxml 2.6.22 DLL works as
expected and does not crash.


I found a similar, possibly the same bug
(http://bugs.php.net/bug.php?id=37435&edit=2) which has been closed. As
I could not reproduce it with xmllint, I figure that it must be the PHP
interpreter.

Reproduce code:
---------------
crash-test.php:
<?php
    $xml = new DOMDocument('1.0');
    $xml->load('crash-test.xml');

    $xml->schemaValidate('crash-test.xsd'); // crash here
?>

crash-test.xml:
<?xml version="1.0"?>
<test xmlns="http://www.php.net/bugtests">
	<value>
		<![CDATA[ 
			test 
			]]>
	</value>
 
</test>

crash-test.xsd:
<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema
	xmlns:xs="http://www.w3.org/2001/XMLSchema"
	targetNamespace="http://www.php.net/bugtests"
	 xmlns="http://www.php.net/bugtests"
	elementFormDefault="qualified">

	<xs:element name="test">
		<xs:complexType>
			<xs:sequence>	
				<xs:element maxOccurs="unbounded" name="value" type="xs:string"
/>
			</xs:sequence>
		</xs:complexType>
	</xs:element>	
</xs:schema>


Expected result:
----------------
validated schema

Actual result:
--------------
php interpreter crashes with exception


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=38410&edit=1


Thread (6 messages)

« previous php.bugs (#100658) next »