ImportSourceRestApi: ignore empty custom headers

fixes #2232
This commit is contained in:
Thomas Gelf 2020-11-28 17:21:21 +01:00
parent b8db745a61
commit 9d6e23a845
1 changed files with 2 additions and 2 deletions

View File

@ -90,11 +90,11 @@ class ImportSourceRestApi extends ImportSourceHook
$headers = [];
$text = $this->getSetting('headers', '');
foreach (preg_split("~\r?\n~", $text) as $header) {
foreach (preg_split('~\r?\n~', $text, -1, PREG_SPLIT_NO_EMPTY) as $header) {
$header = trim($header);
$parts = preg_split('~\s*:\s*~', $header, 2);
if (count($parts) < 2) {
throw new InvalidPropertyException('Could not parse header: %s', $header);
throw new InvalidPropertyException('Could not parse header: "%s"', $header);
}
$headers[$parts[0]] = $parts[1];