felipe          Mon Sep  1 23:44:00 2008 UTC

  Added files:                 (Branch: PHP_5_3)
    /php-src/ext/fileinfo/tests mime_content_type_001.phpt 

  Modified files:              
    /php-src/ext/fileinfo       fileinfo.c 
    /php-src/ext/fileinfo/tests finfo_file_001.phpt 
  Log:
  - Fixed mime_content_type() behavior when a string is given
  - Fixed check for "empty file name"
  - MFH: New test
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/fileinfo/fileinfo.c?r1=1.20.2.10&r2=1.20.2.11&diff_format=u
Index: php-src/ext/fileinfo/fileinfo.c
diff -u php-src/ext/fileinfo/fileinfo.c:1.20.2.10 
php-src/ext/fileinfo/fileinfo.c:1.20.2.11
--- php-src/ext/fileinfo/fileinfo.c:1.20.2.10   Mon Sep  1 18:56:06 2008
+++ php-src/ext/fileinfo/fileinfo.c     Mon Sep  1 23:44:00 2008
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: fileinfo.c,v 1.20.2.10 2008/09/01 18:56:06 pajoye Exp $ */
+/* $Id: fileinfo.c,v 1.20.2.11 2008/09/01 23:44:00 felipe Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -437,6 +437,7 @@
                        case IS_STRING:
                                buffer = Z_STRVAL_P(what);
                                buffer_len = Z_STRLEN_P(what);
+                               mode = FILEINFO_MODE_FILE;
                                break;
 
                        case IS_RESOURCE:
@@ -505,7 +506,7 @@
                        php_stream_wrapper *wrap;
                        struct stat sb;
 
-                       if (buffer_len < 1) {
+                       if (buffer == NULL || !*buffer) {
                                php_error_docref(NULL TSRMLS_CC, E_WARNING, 
"Empty filename or path");
                                RETURN_FALSE;
                        }
@@ -523,6 +524,9 @@
                                php_stream *stream = 
php_stream_open_wrapper_ex(buffer, "rb", ENFORCE_SAFE_MODE | REPORT_ERRORS, 
NULL, context);
 
                                if (!stream) {
+                                       if (mimetype_emu) {
+                                               magic_close(magic);
+                                       }
                                        RETURN_FALSE;
                                }
 
http://cvs.php.net/viewvc.cgi/php-src/ext/fileinfo/tests/finfo_file_001.phpt?r1=1.1.2.4&r2=1.1.2.5&diff_format=u
Index: php-src/ext/fileinfo/tests/finfo_file_001.phpt
diff -u php-src/ext/fileinfo/tests/finfo_file_001.phpt:1.1.2.4 
php-src/ext/fileinfo/tests/finfo_file_001.phpt:1.1.2.5
--- php-src/ext/fileinfo/tests/finfo_file_001.phpt:1.1.2.4      Mon Sep  1 
18:56:06 2008
+++ php-src/ext/fileinfo/tests/finfo_file_001.phpt      Mon Sep  1 23:44:00 2008
@@ -12,6 +12,7 @@
 
 ?>
 --EXPECTF--
+Warning: finfo_file(): Empty filename or path in %s on line %d
 bool(false)
 
 Warning: finfo_file(): Empty filename or path in %s on line %d

http://cvs.php.net/viewvc.cgi/php-src/ext/fileinfo/tests/mime_content_type_001.phpt?view=markup&rev=1.1
Index: php-src/ext/fileinfo/tests/mime_content_type_001.phpt
+++ php-src/ext/fileinfo/tests/mime_content_type_001.phpt
--TEST--
mime_content_type(): Testing wrong parameters
--FILE--
<?php

mime_content_type(1);
mime_content_type(NULL);
mime_content_type(new stdclass);
mime_content_type(array());
mime_content_type('foo/inexistent');
mime_content_type('');
mime_content_type("\0");

?>
--EXPECTF--
Warning: mime_content_type(): Can only process string or stream arguments in %s 
on line %d

Warning: mime_content_type(): Can only process string or stream arguments in %s 
on line %d

Warning: mime_content_type(): Can only process string or stream arguments in %s 
on line %d

Warning: mime_content_type(): Can only process string or stream arguments in %s 
on line %d

Warning: mime_content_type(foo/inexistent): failed to open stream: No such file 
or directory in %s on line %d

Warning: mime_content_type(): Empty filename or path in %s on line %d

Warning: mime_content_type(): Empty filename or path in %s on line %d



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

Reply via email to