Skip to content

Commit e28c719

Browse files
authored
Merge pull request #31518 from nextcloud/backport/31430/stable23
[stable23] Validate `overwrite.cli.url` to be a url in setup check
2 parents 5f64492 + 6e1c064 commit e28c719

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

apps/settings/lib/Controller/CheckSetupController.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -614,15 +614,14 @@ protected function hasWorkingFileLocking(): bool {
614614
}
615615

616616
protected function getSuggestedOverwriteCliURL(): string {
617-
$suggestedOverwriteCliUrl = '';
618-
if ($this->config->getSystemValue('overwrite.cli.url', '') === '') {
619-
$suggestedOverwriteCliUrl = $this->request->getServerProtocol() . '://' . $this->request->getInsecureServerHost() . \OC::$WEBROOT;
620-
if (!$this->config->getSystemValue('config_is_read_only', false)) {
621-
// Set the overwrite URL when it was not set yet.
622-
$this->config->setSystemValue('overwrite.cli.url', $suggestedOverwriteCliUrl);
623-
$suggestedOverwriteCliUrl = '';
624-
}
617+
$currentOverwriteCliUrl = $this->config->getSystemValue('overwrite.cli.url', '');
618+
$suggestedOverwriteCliUrl = $this->request->getServerProtocol() . '://' . $this->request->getInsecureServerHost() . \OC::$WEBROOT;
619+
620+
// Check correctness by checking if it is a valid URL
621+
if (filter_var($currentOverwriteCliUrl, FILTER_VALIDATE_URL)) {
622+
$suggestedOverwriteCliUrl = '';
625623
}
624+
626625
return $suggestedOverwriteCliUrl;
627626
}
628627

core/js/setupchecks.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@
225225
}
226226
if (data.suggestedOverwriteCliURL !== '') {
227227
messages.push({
228-
msg: t('core', 'If your installation is not installed at the root of the domain and uses system cron, there can be issues with the URL generation. To avoid these problems, please set the "overwrite.cli.url" option in your config.php file to the webroot path of your installation (suggestion: "{suggestedOverwriteCliURL}")', {suggestedOverwriteCliURL: data.suggestedOverwriteCliURL}),
228+
msg: t('core', 'Please make sure to set the "overwrite.cli.url" option in your config.php file to the URL that your users mainly use to access this Nextcloud. Suggestion: "{suggestedOverwriteCliURL}". Otherwise there might be problems with the URL generation via cron. (It is possible though that the suggested URL is not the URL that your users mainly use to access this Nextcloud. Best is to double check this in any case.)', {suggestedOverwriteCliURL: data.suggestedOverwriteCliURL}),
229229
type: OC.SetupChecks.MESSAGE_TYPE_WARNING
230230
});
231231
}

0 commit comments

Comments
 (0)