Skip to content

Commit

Permalink
OC4: fix broken utf8_substr with default 0 length
Browse files Browse the repository at this point in the history
Now it always returns an empty string
  • Loading branch information
stalker780 committed May 30, 2022
1 parent 022cdfe commit 3a2c5aa
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions upload/system/helper/utf8.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function utf8_strrpos(string $string, string $needle, int $offset = 0) {
}

function utf8_substr(string $string, int $offset, int $length = 0) {
if ($length === '') {
if ($length == 0) {
return mb_substr($string, $offset, utf8_strlen($string));
} else {
return mb_substr($string, $offset, $length);
Expand Down Expand Up @@ -45,7 +45,7 @@ function utf8_strrpos(string $string, string $needle) {
}

function utf8_substr(string $string, int $offset, int $length = 0) {
if ($length === '') {
if ($length == 0) {
return iconv_substr($string, $offset, utf8_strlen($string), 'UTF-8');
} else {
return iconv_substr($string, $offset, $length, 'UTF-8');
Expand Down

0 comments on commit 3a2c5aa

Please sign in to comment.