From f0915858de8ca06ee63296b5259e84c5a2713f1b Mon Sep 17 00:00:00 2001 From: Adam Spragg Date: Mon, 4 Oct 2021 16:34:05 +0100 Subject: Ignore the URI query string when checking the path --- php/outlook.php | 8 +++++--- php/thunderbird.php | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/php/outlook.php b/php/outlook.php index f6edba6..a694e33 100644 --- a/php/outlook.php +++ b/php/outlook.php @@ -26,18 +26,20 @@ // https://[domain]/autodiscover/autodiscover.xml // https://autodiscover.[domain]/autodiscover/autodiscover.xml -if ($_SERVER['REQUEST_URI'] == "/autodiscover/autodiscover.xml" +$request_path = explode("?", $_SERVER['REQUEST_URI'])[0]; + +if ($request_path == "/autodiscover/autodiscover.xml" && preg_match('/^autodiscover\.(.*)$/', $_SERVER['HTTP_HOST'], $matches)) { $domain = $matches[1]; } -else if ($_SERVER['REQUEST_URI'] == "/autodiscover/autodiscover.xml") { +else if ($request_path == "/autodiscover/autodiscover.xml") { $domain = $_SERVER['HTTP_HOST']; } else { http_response_code(500); header('Content-Type: text/plain'); - echo "Unable to determine email domain from //".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; + echo "Unable to determine email domain from //".$_SERVER['HTTP_HOST'].$request_path; exit(1); } diff --git a/php/thunderbird.php b/php/thunderbird.php index cc35f09..68e90f9 100644 --- a/php/thunderbird.php +++ b/php/thunderbird.php @@ -27,18 +27,20 @@ // http://autoconfig.[domain]/mail/config-v1.1.xml // http://[domain]/.well-known/autoconfig/mail/config-v1.1.xml -if ($_SERVER['REQUEST_URI'] == "/mail/config-v1.1.xml" +$request_path = explode("?", $_SERVER['REQUEST_URI'])[0]; + +if ($request_path == "/mail/config-v1.1.xml" && preg_match('/^autoconfig\.(.*)$/', $_SERVER['HTTP_HOST'], $matches)) { $domain = $matches[1]; } -else if ($_SERVER['REQUEST_URI'] == "/.well-known/autoconfig/mail/config-v1.1.xml") { +else if ($request_path == "/.well-known/autoconfig/mail/config-v1.1.xml") { $domain = $_SERVER['HTTP_HOST']; } else { http_response_code(500); header('Content-Type: text/plain'); - echo "Unable to determine email domain from //".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; + echo "Unable to determine email domain from //".$_SERVER['HTTP_HOST'].$request_path; exit(1); } -- cgit v1.2.1