95 Commits

Author SHA1 Message Date
Fabien Potencier beea1a7c4a Add a test 2022-03-25 09:18:53 +01:00
Fabien Potencier 9c03ef0d21 Fix custom escapers when using multiple Twig environments 2022-03-25 08:56:44 +01:00
Christian Flothmann 1411c454c1 do not reuse internally generated variable names during parsing 2022-02-24 17:25:50 +01:00
Fabien Potencier 2eb3308055 Disallow non closures in sort filter when the sanbox mode is enabled 2022-02-04 07:52:21 +01:00
v.arsentev 7d0e5d6a1e The deprecated null value for the method round has been changed to zero. 2022-01-11 16:12:44 +01:00
Ruud Kamphuis e9cd55def5 Allow null for nl2br, striptags and format filters
Same as https://github.com/twigphp/Twig/pull/3617
2022-01-03 14:28:28 +01:00
Fabien Potencier 92bc110bcf Allow null when Twig expects a string 2022-01-02 16:05:53 +01:00
Jérôme TAMARELLE 4fcc6b1c47 Use faster hash algorithm (xxh128) on PHP 8.1 2021-12-15 06:29:16 +01:00
Nicolas Grekas 1d0bab9d63 Add explicit @return type next to #[ReturnTypeWillChange] 2021-08-10 18:49:26 +02:00
Alex Pott 98c2233e47 Twig2 PHP 8.1 beta compatibility 2021-07-28 09:49:43 +01:00
Fabien Potencier feeaba3fea Merge branch '1.x' into 2.x
* 1.x:
  Explicitly specify the encoding for mb_ord in JS escaper
2021-07-08 13:01:04 +02:00
Oleg Stepanischev da24c9340e Explicitly specify the encoding for mb_ord in JS escaper
Explicitly specify the encoding for mb_ord in JS escaper - fix
2021-07-08 12:58:33 +02:00
Fabien Potencier 7926399e0a Merge branch '1.x' into 2.x
* 1.x:
  Fix implicit flot to int casts
2021-06-06 18:31:25 +02:00
Alexander M. Turek de9cd76d7c Fix implicit flot to int casts 2021-06-06 00:32:22 +02:00
Fabien Potencier 66fa6d37f7 Merge branch '1.x' into 2.x
* 1.x:
  Move Drupal test file to tests/
  fix file permissions
  Bump version
  Prepare the 1.44.4 release
2021-05-18 13:10:20 +02:00
Fabien Potencier 2fa8bce914 Move Drupal test file to tests/ 2021-05-18 13:09:01 +02:00
Fabien Potencier ceb4de0448 Merge branch '1.x' into 2.x
* 1.x:
  Update CHANGELOG
  Revert "bug #3499 Fix: A template name cannot be an absolute path (mvorisek)"
2021-05-16 14:07:24 +02:00
Fabien Potencier 124f10c27e Revert "bug #3499 Fix: A template name cannot be an absolute path (mvorisek)"
This reverts commit 83f26e402b, reversing
changes made to f5d3c704df.
2021-05-16 14:06:26 +02:00
Fabien Potencier 157fa56829 Merge branch '1.x' into 2.x
* 1.x:
  Fix CS
  Migrate to the new PHP CS Fixer config file
2021-05-12 09:27:30 +02:00
Fabien Potencier 59f3e8e5dc Fix CS 2021-05-12 09:19:37 +02:00
Fabien Potencier 953974a7b3 Fix code for PHP 8.1 2021-04-10 10:14:28 +02:00
Fabien Potencier 02fe3a544c Merge branch '1.x' into 2.x
* 1.x:
  Fix: A template name cannot be an absolute path
2021-04-07 17:57:49 +02:00
Michael Voříšek 3a67fc7dc5 Fix: A template name cannot be an absolute path 2021-04-07 17:57:24 +02:00
Fabien Potencier c2a264a91d Merge branch '1.x' into 2.x
* 1.x:
  Enhancement: Introduce DOCtor-RST config + Sphinx build + GithubActions
  Enhancement: Use GithubActions instead of Travis for tests
  Fix `odd` not working for negative numbers
  Bump version to 1.44.2-DEV
  Prepare the 1.44.1 release
2020-11-05 13:31:01 +01:00
Harry Bournis 53a3ccd2d2 Fix odd not working for negative numbers 2020-11-05 11:55:45 +01:00
Fabien Potencier 497f027cd4 Merge branch '1.x' into 2.x
* 1.x:
  Fix "include(template_from_string())"
  Fix PHPUnit config
2020-10-27 15:14:55 +01:00
Fabien Potencier df9c9f2165 Fix "include(template_from_string())" 2020-10-27 13:39:31 +01:00
Fabien Potencier 53650c55c1 Merge branch '1.x' into 2.x
* 1.x:
  Fix PHP 8 support
2020-10-21 14:27:01 +02:00
Fabien Potencier b1c9faa33e Fix PHP 8 support 2020-10-21 14:08:16 +02:00
Fabien Potencier 2ffab581fe Merge branch '1.x' into 2.x
* 1.x:
  Fix PHP 8 support
2020-10-21 13:43:35 +02:00
Fabien Potencier d46aeb0724 Fix PHP 8 support 2020-10-21 13:43:26 +02:00
Fabien Potencier ab6695b580 Merge branch '1.x' into 2.x
* 1.x:
  Fix sandbox support when using include(template_from_string())
  Add test to verify that filter is not working when template_from_string is used.
  In |filter(), |map(), and |reduce(), throw a RuntimeError instead of a TypeError
2020-08-23 17:55:14 +02:00
Fabien Potencier c7be1bb3c4 Fix sandbox support when using include(template_from_string()) 2020-08-23 17:48:34 +02:00
Bozhidar Hristov 04431228af Add test to verify that filter is not working when template_from_string is used. 2020-08-23 17:46:12 +02:00
Fabien Potencier 54eff0d96e bug #3341 In |filter(), |map(), and |reduce(), throw a RuntimeError instead of a TypeError (thijzert)
This PR was squashed before being merged into the 1.x branch.

Discussion
----------

In |filter(), |map(), and |reduce(), throw a RuntimeError instead of a TypeError

If a template accidentally performs `|filter(...)` on a variable that isn't traversable (e.g. `null`), the calling code will encouter the raw `TypeError` that results from Twig trying to construct an `IteratorIterator` on that variable. This means that context information (e.g., in which exact template the error occurred, and on which line) is discarded, which makes it very difficult to debug your templates.

This commit adds code to throw a `RuntimeError` if Twig encounters a situation where there's no valid way to filter an array.

Commits
-------

567b1e2a In |filter(), |map(), and |reduce(), throw a RuntimeError instead of a TypeError
2020-08-23 16:40:19 +02:00
Thijs van Dijk 567b1e2a06 In |filter(), |map(), and |reduce(), throw a RuntimeError instead of a TypeError 2020-08-23 16:40:13 +02:00
Fabien Potencier 03491db322 Merge branch '1.x' into 2.x
* 1.x:
  Remove tests that do not make sense
2020-08-23 14:46:45 +02:00
Fabien Potencier 80a4a1f31e Remove tests that do not make sense 2020-08-23 14:46:38 +02:00
Fabien Potencier 9bf49d5ccf Merge branch '1.x' into 2.x
* 1.x:
  Update CHANGELOG
  Fix previous merge
  Make round brackets optional for one argument tests like sameas
2020-08-23 14:22:09 +02:00
Andreas 1ee72d9e15 Make round brackets optional for one argument tests like sameas 2020-08-23 14:16:31 +02:00
Fabien Potencier 77dcff7186 Merge branch '1.x' into 2.x
* 1.x:
  Bump version
  Tweak docs
  Update CHANGELOG
  Support object init from variable
2020-08-23 14:01:18 +02:00
Fabien Potencier b0ce4f64ba Update CHANGELOG 2020-08-23 13:56:44 +02:00
Jérôme TAMARELLE 133edb3696 Support object init from variable
{a} is a shortcut for {a:a}
From ECMAScript 2015 syntax https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Object_initializer
2020-08-23 13:54:49 +02:00
Fabien Potencier 81612a5c7d Merge branch '1.x' into 2.x
* 1.x:
  Fix CS
2020-08-23 13:49:18 +02:00
Fabien Potencier bde54e11b8 Fix CS 2020-08-23 13:48:32 +02:00
Fabien Potencier f787c032ab Migrate more tests 2020-08-23 12:47:51 +02:00
Fabien Potencier e5882d9fb4 Update phpunit assertion 2020-08-23 12:22:59 +02:00
Fabien Potencier 38bd74d03a Merge branch '1.x' into 2.x
* 1.x:
  Add a test
  fix typo in ApplyTokenParser PHP doc
  Fixes #3351
2020-08-05 16:53:59 +02:00
Fabien Potencier 94aa9bf305 Add a test 2020-08-05 16:53:34 +02:00
Jérôme TAMARELLE 9a83f7edf6 Fix compatibility with PHPUnit 10 2020-07-29 03:03:03 +02:00