Преглед на файлове

Cast int and float to string when creating headers

With the ZF2015-04 patch, we were no longer allowing non-string, non-stringable
objects as header values. This broke a number of other classes, however, which
required integer and/or float values (e.g., to set a Content-Length header).
This patch casts those types to strings before attempting to set them as header
values.
Matthew Weier O'Phinney преди 10 години
родител
ревизия
7d8e6c6cf5
променени са 1 файла, в които са добавени 5 реда и са изтрити 0 реда
  1. 5 0
      library/Zend/Http/Client.php

+ 5 - 0
library/Zend/Http/Client.php

@@ -1592,6 +1592,11 @@ class Zend_Http_Client
             return;
         }
 
+        // Cast integers and floats to strings for purposes of header representation.
+        if (is_int($value) || is_float($value)) {
+            $value = (string) $value;
+        }
+
         if (! is_string($value) && (! is_object($value) || ! method_exists($value, '__toString'))) {
             require_once 'Zend/Http/Exception.php';
             throw new Zend_Http_Exception('Invalid header value detected');