Skip to content

Commit

Permalink
Detect leading spaces in config files
Browse files Browse the repository at this point in the history
Because those will cause PHP to output to stdout and will cause
unrelated error messages.

Signed-off-by: Vincent Petry <[email protected]>
  • Loading branch information
PVince81 committed Aug 3, 2022
1 parent 9475cc0 commit fcffdb7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/private/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,14 @@ private function readData() {

unset($CONFIG);
include $file;
if (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);
}
Expand Down

0 comments on commit fcffdb7

Please sign in to comment.