cataphract Sat, 11 Dec 2010 02:08:02 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=306216
Log:
- Tests and small parsing correction for php://fd wrapper
Changed paths:
U php/php-src/branches/PHP_5_3/ext/standard/php_fopen_wrapper.c
A
php/php-src/branches/PHP_5_3/ext/standard/tests/file/php_fd_wrapper_01.phpt
A
php/php-src/branches/PHP_5_3/ext/standard/tests/file/php_fd_wrapper_02.phpt
A
php/php-src/branches/PHP_5_3/ext/standard/tests/file/php_fd_wrapper_03.phpt
A
php/php-src/branches/PHP_5_3/ext/standard/tests/file/php_fd_wrapper_04.phpt
U php/php-src/trunk/ext/standard/php_fopen_wrapper.c
A php/php-src/trunk/ext/standard/tests/file/php_fd_wrapper_01.phpt
A php/php-src/trunk/ext/standard/tests/file/php_fd_wrapper_02.phpt
A php/php-src/trunk/ext/standard/tests/file/php_fd_wrapper_03.phpt
A php/php-src/trunk/ext/standard/tests/file/php_fd_wrapper_04.phpt
Modified: php/php-src/branches/PHP_5_3/ext/standard/php_fopen_wrapper.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/standard/php_fopen_wrapper.c
2010-12-11 01:52:13 UTC (rev 306215)
+++ php/php-src/branches/PHP_5_3/ext/standard/php_fopen_wrapper.c
2010-12-11 02:08:02 UTC (rev 306216)
@@ -265,7 +265,7 @@
start = &path[3];
fildes_ori = strtol(start, &end, 10);
- if (end == start || (*end != '\0' && *end != '/')) {
+ if (end == start || *end != '\0') {
php_stream_wrapper_log_error(wrapper, options TSRMLS_CC,
"php://fd/ stream must be specified in the form
php://fd/<orig fd>");
return NULL;
Added:
php/php-src/branches/PHP_5_3/ext/standard/tests/file/php_fd_wrapper_01.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/standard/tests/file/php_fd_wrapper_01.phpt
(rev 0)
+++ php/php-src/branches/PHP_5_3/ext/standard/tests/file/php_fd_wrapper_01.phpt
2010-12-11 02:08:02 UTC (rev 306216)
@@ -0,0 +1,11 @@
+--TEST--
+php://fd wrapper: basic test
+--FILE--
+<?php
+$f = fopen("php://fd/1", "wb");
+fwrite($f, "hi!");
+
+echo "\nDone.\n";
+--EXPECT--
+hi!
+Done.
Added:
php/php-src/branches/PHP_5_3/ext/standard/tests/file/php_fd_wrapper_02.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/standard/tests/file/php_fd_wrapper_02.phpt
(rev 0)
+++ php/php-src/branches/PHP_5_3/ext/standard/tests/file/php_fd_wrapper_02.phpt
2010-12-11 02:08:02 UTC (rev 306216)
@@ -0,0 +1,11 @@
+--TEST--
+php://fd wrapper: mode is ignored
+--FILE--
+<?php
+$f = fopen("php://fd/1", "rkkk");
+fwrite($f, "hi!");
+
+echo "\nDone.\n";
+--EXPECT--
+hi!
+Done.
Added:
php/php-src/branches/PHP_5_3/ext/standard/tests/file/php_fd_wrapper_03.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/standard/tests/file/php_fd_wrapper_03.phpt
(rev 0)
+++ php/php-src/branches/PHP_5_3/ext/standard/tests/file/php_fd_wrapper_03.phpt
2010-12-11 02:08:02 UTC (rev 306216)
@@ -0,0 +1,22 @@
+--TEST--
+php://fd wrapper: bad syntax
+--FILE--
+<?php
+fopen("php://fd", "w");
+fopen("php://fd/", "w");
+fopen("php://fd/-2", "w");
+fopen("php://fd/1/", "w");
+
+echo "\nDone.\n";
+--EXPECTF--
+Warning: fopen(): Invalid php:// URL specified in %s on line %d
+
+Warning: fopen(php://fd): failed to open stream: operation failed in %s on
line 2
+
+Warning: fopen(php://fd/): failed to open stream: php://fd/ stream must be
specified in the form php://fd/<orig fd> in %s on line %d
+
+Warning: fopen(php://fd/-2): failed to open stream: The file descriptors must
be non-negative numbers smaller than %d in %s on line %d
+
+Warning: fopen(php://fd/1/): failed to open stream: php://fd/ stream must be
specified in the form php://fd/<orig fd> in %s on line %d
+
+Done.
Added:
php/php-src/branches/PHP_5_3/ext/standard/tests/file/php_fd_wrapper_04.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/standard/tests/file/php_fd_wrapper_04.phpt
(rev 0)
+++ php/php-src/branches/PHP_5_3/ext/standard/tests/file/php_fd_wrapper_04.phpt
2010-12-11 02:08:02 UTC (rev 306216)
@@ -0,0 +1,20 @@
+--TEST--
+php://fd wrapper: invalid file descriptor
+--SKIPIF--
+<?php include('skipif.inc');
+if(substr(PHP_OS, 0, 3) == "WIN")
+ die("skip Not for Windows");
+
+//we'd need a release and a test variation for windows, because in debug
builds we get this message:
+//Warning: Invalid parameter detected in CRT function '_dup'
(f:\dd\vctools\crt_bld\self_x86\crt\src\dup.c:52)
+//I greped the CRT sources and found no function capable of validating a file
descriptor
+
+--FILE--
+<?php
+fopen("php://fd/12", "w");
+
+echo "\nDone.\n";
+--EXPECTF--
+Warning: fopen(php://fd/12): failed to open stream: Error duping file
descriptor 12; possibly it doesn't exist: [9]: %s in %s on line %d
+
+Done.
Modified: php/php-src/trunk/ext/standard/php_fopen_wrapper.c
===================================================================
--- php/php-src/trunk/ext/standard/php_fopen_wrapper.c 2010-12-11 01:52:13 UTC
(rev 306215)
+++ php/php-src/trunk/ext/standard/php_fopen_wrapper.c 2010-12-11 02:08:02 UTC
(rev 306216)
@@ -265,7 +265,7 @@
start = &path[3];
fildes_ori = strtol(start, &end, 10);
- if (end == start || (*end != '\0' && *end != '/')) {
+ if (end == start || *end != '\0') {
php_stream_wrapper_log_error(wrapper, options TSRMLS_CC,
"php://fd/ stream must be specified in the form
php://fd/<orig fd>");
return NULL;
Added: php/php-src/trunk/ext/standard/tests/file/php_fd_wrapper_01.phpt
===================================================================
--- php/php-src/trunk/ext/standard/tests/file/php_fd_wrapper_01.phpt
(rev 0)
+++ php/php-src/trunk/ext/standard/tests/file/php_fd_wrapper_01.phpt
2010-12-11 02:08:02 UTC (rev 306216)
@@ -0,0 +1,11 @@
+--TEST--
+php://fd wrapper: basic test
+--FILE--
+<?php
+$f = fopen("php://fd/1", "wb");
+fwrite($f, "hi!");
+
+echo "\nDone.\n";
+--EXPECT--
+hi!
+Done.
Added: php/php-src/trunk/ext/standard/tests/file/php_fd_wrapper_02.phpt
===================================================================
--- php/php-src/trunk/ext/standard/tests/file/php_fd_wrapper_02.phpt
(rev 0)
+++ php/php-src/trunk/ext/standard/tests/file/php_fd_wrapper_02.phpt
2010-12-11 02:08:02 UTC (rev 306216)
@@ -0,0 +1,11 @@
+--TEST--
+php://fd wrapper: mode is ignored
+--FILE--
+<?php
+$f = fopen("php://fd/1", "rkkk");
+fwrite($f, "hi!");
+
+echo "\nDone.\n";
+--EXPECT--
+hi!
+Done.
Added: php/php-src/trunk/ext/standard/tests/file/php_fd_wrapper_03.phpt
===================================================================
--- php/php-src/trunk/ext/standard/tests/file/php_fd_wrapper_03.phpt
(rev 0)
+++ php/php-src/trunk/ext/standard/tests/file/php_fd_wrapper_03.phpt
2010-12-11 02:08:02 UTC (rev 306216)
@@ -0,0 +1,22 @@
+--TEST--
+php://fd wrapper: bad syntax
+--FILE--
+<?php
+fopen("php://fd", "w");
+fopen("php://fd/", "w");
+fopen("php://fd/-2", "w");
+fopen("php://fd/1/", "w");
+
+echo "\nDone.\n";
+--EXPECTF--
+Warning: fopen(): Invalid php:// URL specified in %s on line %d
+
+Warning: fopen(php://fd): failed to open stream: operation failed in %s on
line 2
+
+Warning: fopen(php://fd/): failed to open stream: php://fd/ stream must be
specified in the form php://fd/<orig fd> in %s on line %d
+
+Warning: fopen(php://fd/-2): failed to open stream: The file descriptors must
be non-negative numbers smaller than %d in %s on line %d
+
+Warning: fopen(php://fd/1/): failed to open stream: php://fd/ stream must be
specified in the form php://fd/<orig fd> in %s on line %d
+
+Done.
Added: php/php-src/trunk/ext/standard/tests/file/php_fd_wrapper_04.phpt
===================================================================
--- php/php-src/trunk/ext/standard/tests/file/php_fd_wrapper_04.phpt
(rev 0)
+++ php/php-src/trunk/ext/standard/tests/file/php_fd_wrapper_04.phpt
2010-12-11 02:08:02 UTC (rev 306216)
@@ -0,0 +1,20 @@
+--TEST--
+php://fd wrapper: invalid file descriptor
+--SKIPIF--
+<?php include('skipif.inc');
+if(substr(PHP_OS, 0, 3) == "WIN")
+ die("skip Not for Windows");
+
+//we'd need a release and a test variation for windows, because in debug
builds we get this message:
+//Warning: Invalid parameter detected in CRT function '_dup'
(f:\dd\vctools\crt_bld\self_x86\crt\src\dup.c:52)
+//I greped the CRT sources and found no function capable of validating a file
descriptor
+
+--FILE--
+<?php
+fopen("php://fd/12", "w");
+
+echo "\nDone.\n";
+--EXPECTF--
+Warning: fopen(php://fd/12): failed to open stream: Error duping file
descriptor 12; possibly it doesn't exist: [9]: %s in %s on line %d
+
+Done.
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php