diff --git a/lib/classes/idna/class.idna_convert_wrapper.php b/lib/classes/idna/class.idna_convert_wrapper.php index d9597c91..51f909eb 100644 --- a/lib/classes/idna/class.idna_convert_wrapper.php +++ b/lib/classes/idna/class.idna_convert_wrapper.php @@ -67,6 +67,16 @@ class idna_convert_wrapper } } + public function encode_uri($to_encode) + { + if (version_compare("5.6.0", PHP_VERSION, ">=")) { + return $this->_do_action('encode', $to_encode); + } else { + $to_encode = $this->is_utf8($to_encode) ? $to_encode : utf8_encode($to_encode); + return $this->idna_converter->encodeUri($to_encode); + } + } + /** * Decode a domain name, a email address or a list of one of both. * diff --git a/scripts/jobs/cron_tasks.inc.http.10.apache.php b/scripts/jobs/cron_tasks.inc.http.10.apache.php index d20a0fd5..4d6acb46 100644 --- a/scripts/jobs/cron_tasks.inc.http.10.apache.php +++ b/scripts/jobs/cron_tasks.inc.http.10.apache.php @@ -860,7 +860,7 @@ class apache extends HttpConfigBase $domain['documentroot'] = trim($domain['documentroot']); if (preg_match('/^https?\:\/\//', $domain['documentroot'])) { - $corrected_docroot = $this->idnaConvert->encode($domain['documentroot']); + $corrected_docroot = $this->idnaConvert->encode_uri($domain['documentroot']); // Get domain's redirect code $code = getDomainRedirectCode($domain['id']); @@ -881,7 +881,7 @@ class apache extends HttpConfigBase $vhost_content .= ' RewriteRule ^/(.*) ' . $corrected_docroot . '$1' . $modrew_red . "\n"; $vhost_content .= ' ' . "\n"; $vhost_content .= ' ' . "\n"; - $vhost_content .= ' Redirect ' . $code . ' / ' . $this->idnaConvert->encode($domain['documentroot']) . "\n"; + $vhost_content .= ' Redirect ' . $code . ' / ' . $corrected_docroot . "\n"; $vhost_content .= ' ' . "\n"; } else { diff --git a/scripts/jobs/cron_tasks.inc.http.20.lighttpd.php b/scripts/jobs/cron_tasks.inc.http.20.lighttpd.php index de8718a9..90b70cc0 100644 --- a/scripts/jobs/cron_tasks.inc.http.20.lighttpd.php +++ b/scripts/jobs/cron_tasks.inc.http.20.lighttpd.php @@ -430,7 +430,7 @@ class lighttpd extends HttpConfigBase if (preg_match('/^https?\:\/\//', $domain['documentroot'])) { $vhost_content .= ' url.redirect = (' . "\n"; - $vhost_content .= ' "^/(.*)$" => "' . $this->idnaConvert->encode($domain['documentroot']) . '$1"' . "\n"; + $vhost_content .= ' "^/(.*)$" => "' . $this->idnaConvert->encode_uri($domain['documentroot']) . '$1"' . "\n"; $vhost_content .= ' )' . "\n"; } else { diff --git a/scripts/jobs/cron_tasks.inc.http.30.nginx.php b/scripts/jobs/cron_tasks.inc.http.30.nginx.php index de6dd6b5..81263633 100644 --- a/scripts/jobs/cron_tasks.inc.http.30.nginx.php +++ b/scripts/jobs/cron_tasks.inc.http.30.nginx.php @@ -470,7 +470,7 @@ class nginx extends HttpConfigBase { // if the documentroot is an URL we just redirect if (preg_match('/^https?\:\/\//', $domain['documentroot'])) { - $uri = $this->idnaConvert->encode($domain['documentroot']); + $uri = $this->idnaConvert->encode_uri($domain['documentroot']); if (substr($uri, -1) == '/') { $uri = substr($uri, 0, -1); }