aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Petry <vincent@nextcloud.com>2022-08-03 10:19:05 +0200
committerVincent Petry <vincent@nextcloud.com>2022-08-03 10:51:10 +0200
commit89cb450c8434f7a51f5fa88b68449d8be71b6c4e (patch)
tree7e6dec4752a866a16dbb1887632243d12b990512
parent9475cc02b218f7cab402ec0b2b370ed6c68650c1 (diff)
downloadnextcloud-server-89cb450c8434f7a51f5fa88b68449d8be71b6c4e.tar.gz
nextcloud-server-89cb450c8434f7a51f5fa88b68449d8be71b6c4e.zip
Detect leading spaces in config files
Because those will cause PHP to output to stdout and will cause unrelated error messages. Signed-off-by: Vincent Petry <vincent@nextcloud.com>
-rw-r--r--lib/private/Config.php8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/private/Config.php b/lib/private/Config.php
index b044d0731a3..37708357339 100644
--- a/lib/private/Config.php
+++ b/lib/private/Config.php
@@ -231,6 +231,14 @@ class Config {
unset($CONFIG);
include $file;
+ if (!defined('PHPUNIT_RUN') && headers_sent()) {
+ // syntax issues in the config file like leading spaces causing PHP to send output
+ $errorMessage = sprintf('Config file has leading content, please remove everything before "<?php" in %s', basename($file));
+ if (!defined('OC_CONSOLE')) {
+ print(\OCP\Util::sanitizeHTML($errorMessage));
+ }
+ throw new \Exception($errorMessage);
+ }
if (isset($CONFIG) && is_array($CONFIG)) {
$this->cache = array_merge($this->cache, $CONFIG);
}