Always simply ignore (pass through) them. Previously the behavior
depended on where the invalid character occurred, as it messed
up the state management.
int inc_len = (*s == '\0' ? 1 : php_mblen(s, len));
switch (inc_len) {
- case -2:
- case -1:
- inc_len = 1;
- php_mb_reset();
- break;
case 0:
goto quit_loop;
case 1:
}
break;
default:
+ if (inc_len < 0) {
+ /* If character is invalid, treat it like other non-significant characters. */
+ inc_len = 1;
+ php_mb_reset();
+ }
if (state == 0) {
basename_start = s;
state = 1;
If the filename ends in suffix this will also be cut off.
*/
-var_dump(basename(chr(-1)));
+setlocale(LC_CTYPE, "C");
+var_dump(bin2hex(basename("\xff")));
+var_dump(bin2hex(basename("a\xffb")));
echo "Done\n";
--EXPECT--
-string(0) ""
+string(2) "ff"
+string(6) "61ff62"
Done