[Locale] Fixed implementation of quote parsing and replacement

This commit is contained in:
Jordi Boggiano 2011-02-16 19:16:55 +01:00 committed by Igor Wiedler
parent 47c1110166
commit bfbc8f63fa

View File

@ -80,7 +80,7 @@ class StubIntlDateFormatter
$specialCharsMatch = implode('|', array_map(function($char) { $specialCharsMatch = implode('|', array_map(function($char) {
return $char . '+'; return $char . '+';
}, $specialCharsArray)); }, $specialCharsArray));
$quoteMatch = "'(?>(?>[^']+|'{2}+)?)'|'{2}"; $quoteMatch = "'(?:[^']+|'')*'";
$regExp = "/($quoteMatch|$specialCharsMatch)/"; $regExp = "/($quoteMatch|$specialCharsMatch)/";
$callback = function($matches) use ($dateTime) { $callback = function($matches) use ($dateTime) {
@ -88,7 +88,10 @@ class StubIntlDateFormatter
$length = strlen($pattern); $length = strlen($pattern);
if ("'" === $pattern[0]) { if ("'" === $pattern[0]) {
return preg_replace("/'{2}/", "'", substr($pattern, 1, -1)); if (preg_match("/^'+$/", $matches[0])) {
return str_replace("''", "'", $matches[0]);
}
return str_replace("''", "'", substr($matches[0], 1, -1));
} }
switch ($pattern[0]) { switch ($pattern[0]) {