php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39881 document() function failing for long names in path
Submitted: 2006-12-19 11:03 UTC Modified: 2006-12-19 12:57 UTC
From: dashiad at hotmail dot com Assigned:
Status: Not a bug Package: XSLT related
PHP Version: 5.2.0 OS: Windows XP Professional
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: dashiad at hotmail dot com
New email:
PHP Version: OS:

 

 [2006-12-19 11:03 UTC] dashiad at hotmail dot com
Description:
------------
Hello, something strange is happening with the document() XSL function, and long directory (+8 characters) names.

Scenarios:
- Passing a non-existent file path to document() (no long names): 
   Warning issued ("failed to load external entity")
   (Normal behaviour)

- Passing an existent or non-existent file path to document() , using long names:
   No warning, and, if the file exists, nothing is fetched.

- Passing an existent file path to document, using MSDOS equivalent to long names:
   Everything works as it should.Warning, or success.
   
This is, i have to change:
"C:/Archivos de programa/Apache Group/Apache/htdocs/test.xml"
to
"C:/Archiv~1/Apache~1/Apache/htdocs/test.xml"
to make it work.

Havent tested if the problem is still there if is the xml filename the one with long name.

Following is the reproduce code:

Reproduce code:
---------------
/* PHP FILE.The path should be changed as needed.There are two lines, one with long and other with short names. */
<?
  $xml='<?xml version="1.0"?><b></b>';
  $xsl='<?xml version="1.0"?><xsl:stylesheet version="1.0"  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >'.
       '<xsl:template match="/">'.
      // '<xsl:copy-of select="document(\'C:/Archivos de programa/Apache Group/Apache/htdocs/test.xml\')" />'.
       '<xsl:copy-of select="document(\'c:/Archiv~1/Apache~1/Apache/htdocs/test.xml\')" />'.
      '</xsl:template></xsl:stylesheet>';
       
  $xmlDoc=new DOMDocument();
  $xmlDoc->loadXML($xml);

  $xslDoc=new DOMDocument();
  $xslDoc->loadXML($xsl);
  $proc = new XSLTProcessor;   
  $proc->importStyleSheet($xslDoc); // attach the xsl rules   
  echo $proc->transformToXML($xmlDoc)
?>

/* Sample test.xml (external entity).Could be whatever.*/
<?xml version="1.0"?>
<z>
  <q>

  </q>
</z>

Expected result:
----------------
For clarity, i've not added xml headers.The expected result (using short names,it works):
<?xml version="1.0"?>
<z>
  <q>

  </q>
</z>


Actual result:
--------------
When using long names...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=windows-1252"></HEAD>
<BODY></BODY></HTML>

(ie:nothing)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-12-19 11:59 UTC] chregu@php.net
Could it be, that the space in your path is the problem and 
not the "longness" of the filename?

Sorry, no windows here to test...
 [2006-12-19 12:09 UTC] dashiad at hotmail dot com
I've tested using character entities as spaces (&#xA0;), with no luck.And, even if that were the problem,i guess the final result should be a warning about not finding the external entity..
 [2006-12-19 12:19 UTC] rrichards@php.net
Not a PHP issue. Must use URIs for paths Use the following or it tries to build a relative path:

document(\'file:///'.rawurlencode("C:/Archivos de programa/Apache Group/Apache/htdocs/test.xml").'\')
 [2006-12-19 12:57 UTC] dashiad at hotmail dot com
Ok, tested it with rawurlencode and it works..
Then, the only "cosmetic" points i see are:
-The lack of warning (shouldn't the parser arise one,as the file wasnt found?)
-It doesnt look to try a relative path if it's not an URI...Writing the full path using the 8.3 filenames, without prepending "file///", nor rawurlencoding it, finds the file.

I've also tried by changing the location of the xml file, so it woudnt find it "by chance",being in the same directory, and using short filenames, it finds it.
In those tests, i've restarted IE to check the cache wasnt being used.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 00:01:30 2024 UTC