diff --git a/CHANGELOG b/CHANGELOG index ac90bc51a..7811d957f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -288,7 +288,7 @@ * 1.42.4 (2019-XX-XX) - * n/a + * added supported for exponential numbers * 1.42.3 (2019-08-24) diff --git a/src/Environment.php b/src/Environment.php index 610259868..f011cfa20 100644 --- a/src/Environment.php +++ b/src/Environment.php @@ -435,7 +435,7 @@ class Environment * * This method should not be used as a generic way to load templates. * - * @param string $template The template name + * @param string $template The template source * @param string $name An optional name of the template to be used in error messages * * @return TemplateWrapper A template instance representing the given template name diff --git a/src/Lexer.php b/src/Lexer.php index 8bcd0f875..45c729023 100644 --- a/src/Lexer.php +++ b/src/Lexer.php @@ -44,7 +44,7 @@ class Lexer const STATE_INTERPOLATION = 4; const REGEX_NAME = '/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/A'; - const REGEX_NUMBER = '/[0-9]+(?:\.[0-9]+)?/A'; + const REGEX_NUMBER = '/[0-9]+(?:\.[0-9]+)?([Ee][\+\-][0-9]+)?/A'; const REGEX_STRING = '/"([^#"\\\\]*(?:\\\\.[^#"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\'/As'; const REGEX_DQ_STRING_DELIM = '/"/A'; const REGEX_DQ_STRING_PART = '/[^#"\\\\]*(?:(?:\\\\.|#(?!\{))[^#"\\\\]*)*/As'; diff --git a/tests/Fixtures/expressions/exponential_numbers.test b/tests/Fixtures/expressions/exponential_numbers.test new file mode 100644 index 000000000..f403110bc --- /dev/null +++ b/tests/Fixtures/expressions/exponential_numbers.test @@ -0,0 +1,8 @@ +--TEST-- +Twig manages exponentiel numbers correctly +--TEMPLATE-- +{{ 1.99E+3 }} +--DATA-- +return [] +--EXPECT-- +1990