cvs: php4 /ext/mbstring mbstring.c mbstring.h /main rfc1867.c

From: Date: Wed, 03 Jul 2002 13:36:19 +0000
Subject: cvs: php4 /ext/mbstring mbstring.c mbstring.h /main rfc1867.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-12690@lists.php.net to get a copy of this message
hirokawa Wed Jul 3 09:36:19 2002 EDT Modified files: /php4/main rfc1867.c /php4/ext/mbstring mbstring.c mbstring.h Log: fixed shift_jis character corruption including 0x5c as second byte on uploaded filename. Index: php4/main/rfc1867.c diff -u php4/main/rfc1867.c:1.103 php4/main/rfc1867.c:1.104 --- php4/main/rfc1867.c:1.103 Fri Jun 7 04:00:12 2002 +++ php4/main/rfc1867.c Wed Jul 3 09:36:18 2002 @@ -16,7 +16,7 @@ | Jani Taskinen <sniper@php.net> | +----------------------------------------------------------------------+ */ -/* $Id: rfc1867.c,v 1.103 2002/06/07 08:00:12 sesser Exp $ */ +/* $Id: rfc1867.c,v 1.104 2002/07/03 13:36:18 hirokawa Exp $ */ /* * This product includes software developed by the Apache Group @@ -32,6 +32,9 @@ #include "php_variables.h" #include "rfc1867.h" +#if HAVE_MBSTRING +#include "ext/mbstring/mbstring.h" +#endif #undef DEBUG_FILE_UPLOAD @@ -823,7 +826,11 @@ sprintf(lbuf, "%s_name", param); } +#if HAVE_MBSTRING + s = mbstr_strrchr(filename, '\\'); +#else s = strrchr(filename, '\\'); +#endif if (s && s > filename) { safe_php_register_variable(lbuf, s+1, NULL, 0 TSRMLS_CC); } else { Index: php4/ext/mbstring/mbstring.c diff -u php4/ext/mbstring/mbstring.c:1.74 php4/ext/mbstring/mbstring.c:1.75 --- php4/ext/mbstring/mbstring.c:1.74 Wed Jun 19 17:55:42 2002 +++ php4/ext/mbstring/mbstring.c Wed Jul 3 09:36:19 2002 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: mbstring.c,v 1.74 2002/06/19 21:55:42 helly Exp $ */ +/* $Id: mbstring.c,v 1.75 2002/07/03 13:36:19 hirokawa Exp $ */ /* * PHP4 Multibyte String module "mbstring" (currently only for Japanese) @@ -1322,6 +1322,27 @@ } } #endif + + +#define IS_SJIS1(c) ((((c)>=0x81 && (c)<=0x9f) || ((c)>=0xe0 && (c)<=0xf5)) ? 1 : 0) +#define IS_SJIS2(c) ((((c)>=0x40 && (c)<=0x7e) || ((c)>=0x80 && (c)<=0xfc)) ? 1 : 0) + +char *mbstr_strrchr(const char *s, char c){ + unsigned char *p = (unsigned char *)s, *last = NULL; + while(*p++) { + if (*p == c) { + last = p; + } + if (*p == '\0'){ + break; + } + if (MBSTRG(current_language) == mbfl_no_language_japanese + && IS_SJIS1(*p) && IS_SJIS2(*(p+1))) { + p++; + } + } + return last; +} /* http input processing */ void mbstr_treat_data(int arg, char *str, zval* destArray TSRMLS_DC) Index: php4/ext/mbstring/mbstring.h diff -u php4/ext/mbstring/mbstring.h:1.21 php4/ext/mbstring/mbstring.h:1.22 --- php4/ext/mbstring/mbstring.h:1.21 Wed May 8 08:30:47 2002 +++ php4/ext/mbstring/mbstring.h Wed Jul 3 09:36:19 2002 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: mbstring.h,v 1.21 2002/05/08 12:30:47 hirokawa Exp $ */ +/* $Id: mbstring.h,v 1.22 2002/07/03 13:36:19 hirokawa Exp $ */ /* * PHP4 Multibyte String module "mbstring" (currently only for Japanese) @@ -123,6 +123,8 @@ #define PHP_MBREGEX_MAXCACHE 50 int php_mbregex_name2mbctype(const char *pname); #endif + +char *mbstr_strrchr(const char *s, char c); ZEND_BEGIN_MODULE_GLOBALS(mbstring) int language;

« previous php.cvs (#12690) next »