cellog          Thu Apr 30 04:40:31 2009 UTC

  Added files:                 
    /php-src/ext/phar/tests     phar_construct_invalidurl.phpt 

  Modified files:              
    /php-src/ext/phar   phar.c 
  Log:
  MFPECL: fixed PECL Bug #14646: phar error message unclear with php stream 
wrappers
  
http://cvs.php.net/viewvc.cgi/php-src/ext/phar/phar.c?r1=1.397&r2=1.398&diff_format=u
Index: php-src/ext/phar/phar.c
diff -u php-src/ext/phar/phar.c:1.397 php-src/ext/phar/phar.c:1.398
--- php-src/ext/phar/phar.c:1.397       Wed Apr 29 03:24:08 2009
+++ php-src/ext/phar/phar.c     Thu Apr 30 04:40:31 2009
@@ -17,7 +17,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: phar.c,v 1.397 2009/04/29 03:24:08 cellog Exp $ */
+/* $Id: phar.c,v 1.398 2009/04/30 04:40:31 cellog Exp $ */
 
 #define PHAR_MAIN 1
 #include "phar_internal.h"
@@ -1262,7 +1262,11 @@
        /* next try to create a new file */
        if (FAILURE == phar_detect_phar_fname_ext(fname, fname_len, &ext_str, 
&ext_len, !is_data, 1, 1 TSRMLS_CC)) {
                if (error) {
-                       spprintf(error, 0, "Cannot create phar '%s', file 
extension (or combination) not recognised", fname);
+                       if (ext_len == -2) {
+                               spprintf(error, 0, "Cannot create a phar 
archive from a URL like \"%s\".  Phar objects can only be created from local 
files", fname);
+                       } else {
+                               spprintf(error, 0, "Cannot create phar '%s', 
file extension (or combination) not recognised", fname);
+                       }
                }
                return FAILURE;
        }
@@ -1903,6 +1907,12 @@
        pos = memchr(filename, '/', filename_len);
 
        if (pos && pos != filename) {
+               /* check for url like http:// or phar:// */
+               if (*(pos - 1) == ':' && (pos - filename) < filename_len - 1 && 
*(pos + 1) == '/') {
+                       *ext_len = -2;
+                       *ext_str = NULL;
+                       return FAILURE;
+               }
                if (zend_hash_exists(&(PHAR_GLOBALS->phar_alias_map), (char *) 
filename, pos - filename)) {
                        *ext_str = pos;
                        *ext_len = -1;
@@ -3624,7 +3634,7 @@
        php_info_print_table_header(2, "Phar: PHP Archive support", "enabled");
        php_info_print_table_row(2, "Phar EXT version", PHP_PHAR_VERSION);
        php_info_print_table_row(2, "Phar API version", PHP_PHAR_API_VERSION);
-       php_info_print_table_row(2, "CVS revision", "$Revision: 1.397 $");
+       php_info_print_table_row(2, "CVS revision", "$Revision: 1.398 $");
        php_info_print_table_row(2, "Phar-based phar archives", "enabled");
        php_info_print_table_row(2, "Tar-based phar archives", "enabled");
        php_info_print_table_row(2, "ZIP-based phar archives", "enabled");

http://cvs.php.net/viewvc.cgi/php-src/ext/phar/tests/phar_construct_invalidurl.phpt?view=markup&rev=1.1
Index: php-src/ext/phar/tests/phar_construct_invalidurl.phpt
+++ php-src/ext/phar/tests/phar_construct_invalidurl.phpt
--TEST--
Phar object passed URL
--INI--
default_charset=UTF-8
--SKIPIF--
<?php if (!extension_loaded("phar")) die("skip"); ?>
--FILE--
<?php
try {
        $a = new Phar('http://should.fail.com');
} catch (UnexpectedValueException $e) {
        echo $e->getMessage(),"\n";
}
try {
        $a = new Phar('http://');
} catch (UnexpectedValueException $e) {
        echo $e->getMessage(),"\n";
}
try {
        $a = new Phar('http:/');
} catch (UnexpectedValueException $e) {
        echo $e->getMessage(),"\n";
}
?>
===DONE===
--EXPECT--
Cannot create a phar archive from a URL like "http://should.fail.com";.  Phar 
objects can only be created from local files
Cannot create a phar archive from a URL like "http://";.  Phar objects can only 
be created from local files
Cannot create phar 'http:/', file extension (or combination) not recognised
===DONE===


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to