Skip to content

Commit

Permalink
Merge pull request #1987 from ampproject/fix-icu-intl-edge-case
Browse files Browse the repository at this point in the history
Work around edge case combination of PHP 7.2+ with old ICU version
  • Loading branch information
westonruter authored Mar 18, 2019
2 parents b3837cb + 28354f7 commit 9e1a9d6
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions includes/class-amp-http.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,9 @@ public static function get_amp_cache_hosts() {
*/
foreach ( $domains as $domain ) {
if ( function_exists( 'idn_to_utf8' ) ) {
if ( version_compare( PHP_VERSION, '5.4', '>=' ) && defined( 'INTL_IDNA_VARIANT_UTS46' ) ) {
$domain = idn_to_utf8( $domain, IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46 ); // phpcs:ignore PHPCompatibility.FunctionUse.NewFunctionParameters.idn_to_utf8_variantFound, PHPCompatibility.Constants.NewConstants.intl_idna_variant_uts46Found
} else {
$domain = idn_to_utf8( $domain );
}
// The third parameter is set explicitly to prevent issues with newer PHP versions compiled with an old ICU version.
// phpcs:ignore PHPCompatibility.Constants.RemovedConstants.intl_idna_variant_2003Deprecated
$domain = idn_to_utf8( $domain, IDNA_DEFAULT, defined( 'INTL_IDNA_VARIANT_UTS46' ) ? INTL_IDNA_VARIANT_UTS46 : INTL_IDNA_VARIANT_2003 );
}
$subdomain = str_replace( '-', '--', $domain );
$subdomain = str_replace( '.', '-', $subdomain );
Expand Down

0 comments on commit 9e1a9d6

Please sign in to comment.