Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Fix multibyte string handling for accurate byte and character operations #1229

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions modules/core/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ function is_email_address($val, $allow_local=false) {
$val = trim($val, "<>");
$domain = false;
$local = false;
if (!trim($val) || mb_strlen($val) > 320) {
if (!trim($val) || strlen($val) > 320) {
return false;
}
if (mb_strpos($val, '@') !== false) {
Expand Down Expand Up @@ -213,8 +213,8 @@ function is_email_address($val, $allow_local=false) {
if (!hm_exists('validate_domain_full')) {
function validate_domain_full($val) {
/* check for a dot, max allowed length and standard ASCII characters */
if (mb_strpos($val, '.') === false || mb_strlen($val) > 255 || preg_match("/[^A-Z0-9\-\.]/i", $val) ||
$val[0] == '-' || $val[(mb_strlen($val) - 1)] == '-') {
if (mb_strpos($val, '.') === false || strlen($val) > 255 || preg_match("/[^A-Z0-9\-\.]/i", $val) ||
$val[0] == '-' || $val[(strlen($val) - 1)] == '-') {
return false;
}
return true;
Expand All @@ -229,7 +229,7 @@ function validate_domain_full($val) {
if (!hm_exists('validate_local_full')) {
function validate_local_full($val) {
/* check length, "." rules, and for characters > ASCII 127 */
if (mb_strlen($val) > 64 || $val[0] == '.' || $val[(mb_strlen($val) -1)] == '.' || mb_strstr($val, '..') ||
if (strlen($val) > 64 || $val[0] == '.' || $val[(strlen($val) -1)] == '.' || mb_strstr($val, '..') ||
preg_match('/[^\x00-\x7F]/',$val)) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion modules/core/message_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ function trim_email($val) {
if (!hm_exists('addr_split')) {
function addr_split($str, $seps = array(',', ';')) {
$str = preg_replace('/(\s){2,}/', ' ', $str);
$max = mb_strlen($str);
$max = strlen($str);
$word = '';
$words = array();
$capture = false;
Expand Down
8 changes: 4 additions & 4 deletions modules/imap/hm-imap-base.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ private function command_number() {
private function read_literal($size, $max, $current, $line_length) {
$left_over = false;
$literal_data = $this->fgets($line_length);
$lit_size = mb_strlen($literal_data);
$lit_size = strlen($literal_data);
$current += $lit_size;
while ($lit_size < $size) {
$chunk = $this->fgets($line_length);
$chunk_size = mb_strlen($chunk);
$chunk_size = strlen($chunk);
$lit_size += $chunk_size;
$current += $chunk_size;
$literal_data .= $chunk;
Expand All @@ -85,10 +85,10 @@ private function read_literal($size, $max, $current, $line_length) {
if ($this->max_read) {
while ($lit_size < $size) {
$temp = $this->fgets($line_length);
$lit_size += mb_strlen($temp);
$lit_size += strlen($temp);
}
}
elseif ($size < mb_strlen($literal_data)) {
elseif ($size < strlen($literal_data)) {
$left_over = mb_substr($literal_data, $size);
$literal_data = mb_substr($literal_data, 0, $size);
}
Expand Down