From 6bec8747c5f05e8fc72bcf1ea414027fdca4a1a4 Mon Sep 17 00:00:00 2001 From: Maks3w Date: Sat, 4 Jan 2014 17:50:21 +0100 Subject: [PATCH] Fix uses of trim as callback trim function cannot be used as callback argument of array_walk since the second argument of the callback (array index) conflicts with the second argument of trim (characters to trim) dealing in unexpected behaviors. --- library/Zend/Http/Header/ContentType.php | 8 +++++++- library/Zend/Mail/Header/AbstractAddressList.php | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/library/Zend/Http/Header/ContentType.php b/library/Zend/Http/Header/ContentType.php index 44a61ecd477..df67954956b 100644 --- a/library/Zend/Http/Header/ContentType.php +++ b/library/Zend/Http/Header/ContentType.php @@ -248,7 +248,13 @@ protected function assembleValue() protected function splitMediaTypesFromString($criteria) { $mediaTypes = explode(',', $criteria); - array_walk($mediaTypes, 'trim'); + array_walk( + $mediaTypes, + function (&$value) { + $value = trim($value); + } + ); + return $mediaTypes; } diff --git a/library/Zend/Mail/Header/AbstractAddressList.php b/library/Zend/Mail/Header/AbstractAddressList.php index 4ccd38bba3f..87f76c7734c 100644 --- a/library/Zend/Mail/Header/AbstractAddressList.php +++ b/library/Zend/Mail/Header/AbstractAddressList.php @@ -58,7 +58,12 @@ public static function fromString($headerLine) // split value on "," $fieldValue = str_replace(Headers::FOLDING, ' ', $fieldValue); $values = explode(',', $fieldValue); - array_walk($values, 'trim'); + array_walk( + $values, + function (&$value) { + $value = trim($value); + } + ); $addressList = $header->getAddressList(); foreach ($values as $address) {