From: Ilia Alshanetsky Date: Mon, 24 Jan 2005 23:52:27 +0000 (+0000) Subject: MFH: Use multibyte specific code for handling files and generic basename X-Git-Tag: php-4.3.11RC1~105 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=72818b5c0d23f9168afb8ef1b2ecff1ab7c1f51b;p=php MFH: Use multibyte specific code for handling files and generic basename based code in all other instances. --- diff --git a/main/rfc1867.c b/main/rfc1867.c index d8ebf2d2f5..22f9989176 100644 --- a/main/rfc1867.c +++ b/main/rfc1867.c @@ -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);