php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53250 bugs on : Phar::interceptFileFuncs
Submitted: 2010-11-07 05:34 UTC Modified: 2013-02-18 00:34 UTC
Votes:2
Avg. Score:4.0 ± 1.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: popon8947 at gmail dot com Assigned:
Status: No Feedback Package: PHAR related
PHP Version: 5.2.14 OS: Windows
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2010-11-07 05:34 UTC] popon8947 at gmail dot com
Description:
------------
run attached file

relative path file name

function fails

file_get_contents
or
file_exists

on Phar

Test script:
---------------
<?php

/*
PHP Version 5.2.14
PHP Version 5.3.3

 bugs on : Phar::interceptFileFuncs 
 bugs: file_exists and file_get_contents on phar.
*/

/*
.htaccess
#AddHandler php5-script  .php
#AddHandler php5_3-script  .php
#AddHandler php6-script  .php
*/

if (ini_get('phar.readonly'))
   exit('error : php.ini : phar.readonly is true. '."\n"
       .' php -d phar.readonly=0 '.basename($argv[0])."\n"
	   );

$pack_top_dir_name = 'php-bug-file';
$target_phar_name  = 'test_php-bug-file.phar';
$target_phar_filename = $target_phar_name.'.php';

if (file_exists($target_phar_filename)) @unlink($target_phar_filename);

try {
 $phar = new Phar($target_phar_filename);
 $phar->startBuffering();

$test_file_get_contents = <<<ENDTEXT
<?php
  header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
  header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");   // 

  // this is relative path.
  print "this is relative path.<br>\\n";
  foreach( array('','./') as \$filename ) 
  {
    \$filename .= 'test/file_get_contents';
  printf("test :: file_exists('\$filename') : %s <br>\\n", (file_exists(\$filename) ? 'true' : '<b>false</b>' ) );
  \$s = file_get_contents(\$filename);
  printf("test :: file_get_contents('\$filename') : %s <br>\\n", (\$s !==false ? \$s : '<b>false</b>' ) );
  \$s = file_get_contents(\$filename , FILE_USE_INCLUDE_PATH);
  printf("test :: file_get_contents('\$filename' ,FILE_USE_INCLUDE_PATH) : %s <br>\\n", (\$s !==false ? \$s : '<b>false</b>' ) );
  print "<br>\\n";
  }
  print "PHP version : ".phpversion()."<br>\\n";
?>
ENDTEXT;

 $phar[basename($pack_top_dir_name)."/test/file_get_contents"] = 'test : file_get_contents is ok.';
 $phar[basename($pack_top_dir_name)."/index.php"] = $test_file_get_contents;
 $phar->setStub('<?php '."\n"
     . 'Phar::interceptFileFuncs();'."\n"
     . 'Phar::mungServer(array("REQUEST_URI","PHP_SELF","SCRIPT_NAME","SCRIPT_FILENAME"));'."\n"
     . sprintf('Phar::webPhar("%s", "%s/index.php");', $target_phar_name , basename($pack_top_dir_name))."\n"
     . '__HALT_COMPILER();'."\n"
     .'?>');
 $phar->stopBuffering();
 } catch (Exception $e) {
    echo 'error: phar : '.$target_phar_filename.' : ', $e;
 }

$phar->extractTo("./test-php-bug/");


?>


Expected result:
----------------
function is success.

Actual result:
--------------
function return false

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-11-08 10:25 UTC] aharvey@php.net
-Package: Filesystem function related +Package: PHAR related
 [2011-11-16 14:23 UTC] felipe@php.net
Please try using this snapshot:

  http://snaps.php.net/php5.3-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2011-11-16 14:23 UTC] felipe@php.net
-Status: Open +Status: Feedback
 [2013-02-18 00:34 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 08:01:27 2024 UTC