ID: 43840 Updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] Status: Assigned Bug Type: mbstring related Operating System: Windows XP PHP Version: 5.2CVS-2008-01-14 (snap) Assigned To: hirokawa New Comment:
Here is the entire mbstring section of my php.ini file, I haven't changed it from the default that comes when you download PHP. [mbstring] ; language for internal character representation. ;mbstring.language = Japanese ; internal/script encoding. ; Some encoding cannot work as internal encoding. ; (e.g. SJIS, BIG5, ISO-2022-*) ;mbstring.internal_encoding = EUC-JP ; http input encoding. ;mbstring.http_input = auto ; http output encoding. mb_output_handler must be ; registered as output buffer to function ;mbstring.http_output = SJIS ; enable automatic encoding translation according to ; mbstring.internal_encoding setting. Input chars are ; converted to internal encoding by setting this to On. ; Note: Do _not_ use automatic encoding translation for ; portable libs/applications. ;mbstring.encoding_translation = Off ; automatic encoding detection order. ; auto means ;mbstring.detect_order = auto ; substitute_character used when character cannot be converted ; one from another ;mbstring.substitute_character = none; ; overload(replace) single byte functions by mbstring functions. ; mail(), ereg(), etc are overloaded by mb_send_mail(), mb_ereg(), ; etc. Possible values are 0,1,2,4 or combination of them. ; For example, 7 for overload everything. ; 0: No overload ; 1: Overload mail() function ; 2: Overload str*() functions ; 4: Overload ereg*() functions ;mbstring.func_overload = 0 Thanks Previous Comments: ------------------------------------------------------------------------ [2008-02-10 00:30:07] [EMAIL PROTECTED] Could you show me the mbstring related setting (mbstring.*) in your php.ini ? ------------------------------------------------------------------------ [2008-01-30 15:57:54] [EMAIL PROTECTED] assigning to maintainer ------------------------------------------------------------------------ [2008-01-14 16:36:52] [EMAIL PROTECTED] Description: ------------ The bounds check for the offest argument in mb_strpos appears to be a byte count rather than a character count. In the example below, $string_ascii is 21 characters long and $string_mb is 21 characters (53 bytes) long. In both cases the needle appears twice, first at position 9 and secondly at position 20. With the multibyte string example, when the offset is past the character count of the string it would be expected to return a warning but instead a warning is returned when offest is past the byte count. Reproduce code: --------------- <?php $offsets = array(20, 21, 22, 53, 54); $string_mb = base64_decode('5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCMDEyMzTvvJXvvJbvvJfvvJjvvJnjgII='); $needle = base64_decode('44CC'); foreach($offsets as $i) { echo "\n-- Offset is $i --\n"; echo "--Multibyte String:--\n"; var_dump( mb_strpos($string_mb, $needle, $i, 'UTF-8') ); echo"--ASCII String:--\n"; var_dump(mb_strpos('This is na English ta', 'a', $i)); } ?> Expected result: ---------------- -- Offset is 20 -- --Multibyte String:-- int(20) --ASCII String:-- int(20) -- Offset is 21 -- --Multibyte String:-- bool(false) --ASCII String:-- bool(false) -- Offset is 22 -- --Multibyte String:-- Warning: mb_strpos(): Offset not contained in string. in ...\mb_strpos.php on line 9 bool(false) --ASCII String:-- Warning: mb_strpos(): Offset not contained in string. in ...\mb_strpos.php on line 11 bool(false) -- Offset is 53 -- --Multibyte String:-- Warning: mb_strpos(): Offset not contained in string. in ...\mb_strpos.php on line 9 bool(false) --ASCII String:-- Warning: mb_strpos(): Offset not contained in string. in ...\mb_strpos.php on line 11 bool(false) -- Offset is 54 -- --Multibyte String:-- Warning: mb_strpos(): Offset not contained in string. in ...\mb_strpos.php on line 9 bool(false) --ASCII String:-- Warning: mb_strpos(): Offset not contained in string. in ...\mb_strpos.php on line 11 bool(false) Actual result: -------------- -- Offset is 20 -- --Multibyte String:-- int(20) --ASCII String:-- int(20) -- Offset is 21 -- --Multibyte String:-- bool(false) --ASCII String:-- bool(false) -- Offset is 22 -- --Multibyte String:-- bool(false) --ASCII String:-- Warning: mb_strpos(): Offset not contained in string. in ...\mb_strpos.php on line 11 bool(false) -- Offset is 53 -- --Multibyte String:-- bool(false) --ASCII String:-- Warning: mb_strpos(): Offset not contained in string. in ...\mb_strpos.php on line 11 bool(false) -- Offset is 54 -- --Multibyte String:-- Warning: mb_strpos(): Offset not contained in string. in ...\mb_strpos.php on line 9 bool(false) --ASCII String:-- Warning: mb_strpos(): Offset not contained in string. in ...\mb_strpos.php on line 11 bool(false) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=43840&edit=1