From e377910ccf826b448203513bf63bd5721bbd1375 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 1 Dec 2016 13:48:58 +0200 Subject: Fix #4927 --- system/core/Output.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'system') diff --git a/system/core/Output.php b/system/core/Output.php index cf6510ff1..57c78ab19 100644 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -311,11 +311,12 @@ class CI_Output { return NULL; } - for ($i = 0, $c = count($headers); $i < $c; $i++) + // Count backwards, in order to get the last matching header + for ($c = count($headers) - 1; $c > -1; $c--) { - if (strncasecmp($header, $headers[$i], $l = self::strlen($header)) === 0) + if (strncasecmp($header, $headers[$c], $l = self::strlen($header)) === 0) { - return trim(self::substr($headers[$i], $l+1)); + return trim(self::substr($headers[$c], $l+1)); } } -- cgit v1.2.3-24-g4f1b