Merge pull request #331 from nextcloud/enh/310/improve-domain-check

improve domain check
This commit is contained in:
Simon L 2022-03-09 12:40:22 +01:00 committed by GitHub
commit 866519be88
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -117,8 +117,8 @@ class ConfigurationManager
* @throws InvalidSettingConfigurationException
*/
public function SetDomain(string $domain) : void {
// Validate URL
if (!filter_var('http://' . $domain, FILTER_VALIDATE_URL)) {
// Validate domain
if (!filter_var($domain, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME)) {
throw new InvalidSettingConfigurationException("Domain is not in a valid format!");
}
@ -160,7 +160,7 @@ class ConfigurationManager
$response = str_replace("\n", "", $response);
if($response !== $instanceID) {
throw new InvalidSettingConfigurationException("Domain does not point to this server.");
throw new InvalidSettingConfigurationException("Domain does not point to this server or reverse proxy not configured correctly.");
}
// Write domain