From 527ddacd2084d5112ba849d55ed8532d133cbd97 Mon Sep 17 00:00:00 2001 From: Mic Date: Thu, 2 Jun 2016 22:27:48 +0200 Subject: Fixed bug #69374 IntlDateFormatter formatObject returns wrong utf8 value Relying on invariant strings is a mistake. Not only UTF-8, but also many charsets are not single byte. Actual date formats can be mixed with arbitrary strings, and this can bring erroneous results in the out. Thus, instead it is more convenient to say, that a format string can consist either on UTF-8 or on pure ASCII as its subset. This is what is currently being done in other classes like Formatter, etc. as well. --- ext/intl/dateformat/dateformat_format_object.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'ext/intl/dateformat') diff --git a/ext/intl/dateformat/dateformat_format_object.cpp b/ext/intl/dateformat/dateformat_format_object.cpp index 3be76332a8..accb27e63d 100644 --- a/ext/intl/dateformat/dateformat_format_object.cpp +++ b/ext/intl/dateformat/dateformat_format_object.cpp @@ -188,11 +188,11 @@ U_CFUNC PHP_FUNCTION(datefmt_format_object) } if (pattern) { - df = new SimpleDateFormat( - UnicodeString(Z_STRVAL_P(format), Z_STRLEN_P(format), - UnicodeString::kInvariant), - Locale::createFromName(locale_str), - status); + StringPiece sp(Z_STRVAL_P(format)); + df = new SimpleDateFormat( + UnicodeString::fromUTF8(sp), + Locale::createFromName(locale_str), + status); if (U_FAILURE(status)) { intl_error_set(NULL, status, -- cgit v1.2.1 From 0112b64a346ef1c4b8b21b1cef712a587eee9aa7 Mon Sep 17 00:00:00 2001 From: Mic Date: Thu, 2 Jun 2016 22:37:44 +0200 Subject: Fixed bug #69398 IntlDateFormatter formatObject returns wrong value when time style is NONE --- ext/intl/dateformat/dateformat_format_object.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'ext/intl/dateformat') diff --git a/ext/intl/dateformat/dateformat_format_object.cpp b/ext/intl/dateformat/dateformat_format_object.cpp index accb27e63d..e96ebe8243 100644 --- a/ext/intl/dateformat/dateformat_format_object.cpp +++ b/ext/intl/dateformat/dateformat_format_object.cpp @@ -146,7 +146,9 @@ U_CFUNC PHP_FUNCTION(datefmt_format_object) } //there's no support for relative time in ICU yet - timeStyle = (DateFormat::EStyle)(timeStyle & ~DateFormat::kRelative); + if (timeStyle != DateFormat::NONE) { + timeStyle = (DateFormat::EStyle)(timeStyle & ~DateFormat::kRelative); + } zend_class_entry *instance_ce = Z_OBJCE_P(object); if (instanceof_function(instance_ce, Calendar_ce_ptr)) { -- cgit v1.2.1