From 9d6e23a8452638e166b26119fdf5aa148b1a582a Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Sat, 28 Nov 2020 17:21:21 +0100 Subject: [PATCH] ImportSourceRestApi: ignore empty custom headers fixes #2232 --- library/Director/Import/ImportSourceRestApi.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/Director/Import/ImportSourceRestApi.php b/library/Director/Import/ImportSourceRestApi.php index b906ed86..30bf929d 100644 --- a/library/Director/Import/ImportSourceRestApi.php +++ b/library/Director/Import/ImportSourceRestApi.php @@ -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];