Skip to content

Commit

Permalink
Fix PHP warning "idn_to_utf8(): INTL_IDNA_VARIANT_2003 is deprecated"…
Browse files Browse the repository at this point in the history
… with PHP 7.2 (#6075)
  • Loading branch information
alecpl committed Dec 3, 2017
1 parent 489ad88 commit ca39a4e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ CHANGELOG Roundcube Webmail
- Fix broken long filenames when using imap4d server - workaround server bug (#6048)
- Fix so temp_dir misconfiguration prints an error to the log (#6045)
- Fix untagged COPYUID responses handling - again (#5982)
- Fix PHP warning "idn_to_utf8(): INTL_IDNA_VARIANT_2003 is deprecated" with PHP 7.2 (#6075)

RELEASE 1.3.3
-------------
Expand Down
14 changes: 12 additions & 2 deletions program/lib/Roundcube/rcube_utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -886,13 +886,23 @@ public static function idn_convert($input, $is_utf = false)
{
if ($at = strpos($input, '@')) {
$user = substr($input, 0, $at);
$domain = substr($input, $at+1);
$domain = substr($input, $at + 1);
}
else {
$domain = $input;
}

$domain = $is_utf ? idn_to_ascii($domain) : idn_to_utf8($domain);
// Note that in PHP 7.2/7.3 calling idn_to_* functions with default arguments
// throws a warning, so we have to set the variant explicitely (#6075)
$variant = INTL_IDNA_VARIANT_UTS46;
$options = 0;

if ($is_utf) {
$domain = idn_to_ascii($domain, $options, $variant);
}
else {
$domain = idn_to_utf8($domain, $options, $variant);
}

if ($domain === false) {
return '';
Expand Down

0 comments on commit ca39a4e

Please sign in to comment.