فهرست منبع

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');