From:             andrew at gencon dot co dot uk
Operating system: Linux 2.6.20 Debian testing
PHP version:      5CVS-2007-07-19 (snap)
PHP Bug Type:     DOM XML related
Bug description:  DOMDocument using canonicalized absolute pathname for 
relative Doctype.

Description:
------------
When using PHP5 DOM extension relative DTDs specified on a Doctype that go
through a symlink are resolved using (what appears to be) the canonicalized
absolute pathname. This means that relative paths like ../dtd/test.dtd are
relative to the path the symlink points to and not relative to the symlink
itself. This means you cannot use normal symlink 'shenanigans' to work
around some limitations of DTDs.

Behaviour of sample xml and dtd files tested with PHP4 (4.4.4-9) PHP5
(5.2.0-10 and 5.2.3-1), xmllint using: --loaddtd --noent and rxp.

Snapshot compiled using a simple ./configure and make no options or flags
used. Ran using php5.2-200707191430/sapi/cli/php

Same behavior is also seen using relative DTDs and symlinks in XSLT files
and PHP5.

Reproduce code:
---------------
Sample code for PHP4 and PHP5 with xml and dtd files can be downloaded
from here:

http://www.gencon.co.uk/php_bug_reporting/gencon_php_bug_examples.tgz

In the results below test 1 is not using the symlink and test 2 is using
the symlink.

Expected result:
----------------
Expected to see this output (from PHP4 sample included):

Test XML1:

<?xml version="1.0"?>
<!DOCTYPE doc SYSTEM "../dtd/test.dtd">
<doc><test>a</test></doc>

Test XML2:

<?xml version="1.0"?>
<!DOCTYPE doc SYSTEM "../dtd/test.dtd">
<doc><test>a</test></doc>



Actual result:
--------------
Actually saw this output (any PHP5 version):

Test XML 1:

<?xml version="1.0"?>
<!DOCTYPE doc SYSTEM "../dtd/test.dtd">
<doc><test>a</test></doc>

Test XML 2:

<?xml version="1.0"?>
<!DOCTYPE doc SYSTEM "../dtd/test.dtd">
<doc><test>b</test></doc>

Notice the very last line is now a 'b' and not an 'a' because it has
picked up the wrong DTD defining the entity.

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

Reply via email to