]> granicus.if.org Git - php/commitdiff
MFH: Use multibyte specific code for handling files and generic basename
authorIlia Alshanetsky <iliaa@php.net>
Mon, 24 Jan 2005 23:52:27 +0000 (23:52 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Mon, 24 Jan 2005 23:52:27 +0000 (23:52 +0000)
based code in all other instances.

main/rfc1867.c

index d8ebf2d2f590ebc46094aeea2e0dca8045cb68dc..22f998917611d3d53765b2b870780112d861b35e 100644 (file)
@@ -31,6 +31,7 @@
 #include "php_globals.h"
 #include "php_variables.h"
 #include "rfc1867.h"
+#include "ext/standard/php_string.h"
 
 #undef DEBUG_FILE_UPLOAD
 
@@ -1069,17 +1070,16 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler)
                                        s = tmp;
                                }
                                num_vars--;
-                       } else {
-                               s = strrchr(filename, '\\');
-                               if ((tmp = strrchr(filename, '/')) > s) {
-                                       s = tmp;
-                               }
-                       }
-#else
-                       s = strrchr(filename, '\\');
-                       if ((tmp = strrchr(filename, '/')) > s) {
-                               s = tmp;
+                               goto filedone;
                        }
+#endif
+
+                       /* ensure that the uploaded file name only contains the path */
+                       s = php_basename(filename, strlen(filename), NULL, 0);
+                       efree(filename);
+                       filename = s;
+#if HAVE_MBSTRING && !defined(COMPILE_DL_MBSTRING)
+filedone:
 #endif
                        if (s && s > filename) {
                                safe_php_register_variable(lbuf, s+1, NULL, 0 TSRMLS_CC);