Explorar o código

[Locale] added parsing of dates with regExp metachars

Eriksen Costa %!s(int64=14) %!d(string=hai) anos
pai
achega
b7e9b35ca9

+ 1 - 1
src/Symfony/Component/Locale/Stub/DateFormat/FullTransformer.php

@@ -113,7 +113,7 @@ class FullTransformer
                 $captureName = str_repeat($transformerIndex, $length);
                 return "(?P<$captureName>" . $transformer->getReverseMatchingRegExp($length) . ')';
             }
-        }, $pattern);
+        }, preg_quote($pattern, '/'));
 
         return $reverseMatchingRegExp;
     }

+ 4 - 1
tests/Symfony/Tests/Component/Locale/Stub/StubIntlDateFormatterTest.php

@@ -530,7 +530,10 @@ class StubIntlDateFormatterTest extends LocaleTestCase
             array('y-M-d HH:mm:ss zzzz', '1970-1-1 00:00:00 GMT+04:00', -14400),
 
             // a previous timezoned parsing should not change the timezone for the next parsing
-            array('y-M-d HH:mm:ss', '1970-1-1 00:00:00', 0)
+            array('y-M-d HH:mm:ss', '1970-1-1 00:00:00', 0),
+
+            // regExp metachars in the pattern string
+            array('y[M-d', '1970[1-1', 0),
         );
     }