Zend Framework

Zend_Locale_Format::_parseDate fails when iconv internal encoding is not UTF-8

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.8.4
  • Fix Version/s: 1.10.0
  • Component/s: Zend_Locale
  • Labels:
    None

Description

Zend_Locale_Format::_parseDate assumes that iconv internal encoding is UTF-8 and performs operations against UTF-8 data from Zend_Locale. If the internal character encoding is something other than UTF-8, it fails.

The below patch fixes the failure, but isn't entirely complete; the function will still fail some of the iconv operations if $date is not a valid UTF-8 string. It should be converted to UTF-8 at the beginning of the function, but I don't have an idea on how best to accomplish this.

Patch:

--- Format.php  (revision 16719)
+++ Format.php  (working copy)
@@ -665,6 +667,9 @@
         $number = $date; // working copy
         $result['date_format'] = $format; // save the format used to normalize $number (convenience)
         $result['locale'] = $options['locale']; // save the locale used to normalize $number (convenience)
+
+        $oldEncoding = iconv_get_encoding('internal_encoding');
+        iconv_set_encoding('internal_encoding', 'UTF-8');

         $day   = iconv_strpos($format, 'd');
         $month = iconv_strpos($format, 'M');
@@ -925,6 +930,7 @@
             }
         }

+        iconv_set_encoding('internal_encoding', $oldEncoding);
         return $result;
     }

Issue Links

Activity

Hide
Thomas Weidner added a comment -

Fixed with r17783

Show
Thomas Weidner added a comment - Fixed with r17783

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: