浏览代码

[Locale] Fixed implementation of quote parsing and replacement

Jordi Boggiano 14 年之前
父节点
当前提交
bfbc8f63fa
共有 1 个文件被更改,包括 5 次插入2 次删除
  1. 5 2
      src/Symfony/Component/Locale/Stub/StubIntlDateFormatter.php

+ 5 - 2
src/Symfony/Component/Locale/Stub/StubIntlDateFormatter.php

@@ -80,7 +80,7 @@ class StubIntlDateFormatter
         $specialCharsMatch = implode('|', array_map(function($char) {
             return $char . '+';
         }, $specialCharsArray));
-        $quoteMatch = "'(?>(?>[^']+|'{2}+)?)'|'{2}";
+        $quoteMatch = "'(?:[^']+|'')*'";
         $regExp = "/($quoteMatch|$specialCharsMatch)/";
 
         $callback = function($matches) use ($dateTime) {
@@ -88,7 +88,10 @@ class StubIntlDateFormatter
             $length = strlen($pattern);
 
             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]) {