Commit Graph

112 Commits

Author SHA1 Message Date
Fabien Potencier 1d8243b73e Cleanup PHPUnit compatibility 2026-09-05 11:18:32 +02:00
Fabien Potencier 4b63bb1baa Remove unused PHPUnit Bridge dependency 2026-08-29 09:52:36 +02:00
Fabien Potencier 553980ccff Use PHPUnit attribute for Markdown data provider 2026-08-17 20:22:03 +02:00
Fabien Potencier 60d3b3452a Merge branch '3.x' into 4.x
* 3.x:
  Add support for tempest/markdown in markdown-extra
  Add the include_only function to render a template without access to the current context
  Clarify duplicate macro deprecation message
  Deduplicate template error handling

# Conflicts:
#	.gitignore
#	CHANGELOG
#	extra/markdown-extra/composer.json
#	src/Extension/CoreExtension.php
#	src/Parser.php
#	src/Template.php
#	tests/Fixtures/macros/duplicate_definition.legacy.test
2026-08-16 10:57:50 +02:00
Romain Monteil aa17f59877 Add support for tempest/markdown in markdown-extra 2026-08-12 13:02:21 +02:00
Fabien Potencier 5ca7debf6e Fix merge conflict resolution 2026-07-12 15:08:38 +02:00
Fabien Potencier 0b6e824ea8 Merge branch '3.x' into 4.x
* 3.x:
  Add void return type hint even in tests
  Run php-cs-fixer sequentially so the void_return src-only customiser is applied
  Fix CHANGELOG
  [Intl] Add format_list filter using PHP 8.5's IntlListFormatter

# Conflicts:
#	.github/workflows/ci.yml
#	CHANGELOG
#	extra/cssinliner-extra/Tests/LegacyFunctionsTest.php
#	extra/html-extra/Tests/CvaTest.php
#	extra/html-extra/Tests/HtmlAttrMergeTest.php
#	extra/html-extra/Tests/HtmlAttrTest.php
#	extra/html-extra/Tests/LegacyFunctionsTest.php
#	extra/inky-extra/Tests/LegacyFunctionsTest.php
#	extra/markdown-extra/Tests/FunctionalTest.php
#	extra/markdown-extra/Tests/LegacyFunctionsTest.php
#	extra/twig-extra-bundle/DependencyInjection/Compiler/MissingExtensionSuggestorPass.php
#	extra/twig-extra-bundle/DependencyInjection/TwigExtraExtension.php
#	extra/twig-extra-bundle/TwigExtraBundle.php
#	src/Extension/CoreExtension.php
#	src/Extension/EscaperExtension.php
#	src/Node/CheckSecurityCallNode.php
#	src/Node/Expression/FunctionExpression.php
#	src/Node/ModuleNode.php
#	src/Node/Node.php
#	src/Node/TypesNode.php
#	src/Resources/core.php
#	src/Resources/debug.php
#	src/Test/IntegrationTestCase.php
#	tests/CustomExtensionTest.php
#	tests/EnvironmentTest.php
#	tests/ExpressionParserTest.php
#	tests/Extension/CoreTest.php
#	tests/Extension/EscaperTest.php
#	tests/Extension/LegacyDebugFunctionsTest.php
#	tests/Extension/LegacyStringLoaderFunctionsTest.php
#	tests/Extension/SandboxStateChangeTest.php
#	tests/Extension/SandboxTest.php
#	tests/LexerTest.php
#	tests/Node/Expression/CallTest.php
#	tests/Node/Expression/ConditionalTest.php
#	tests/Node/NodeTest.php
#	tests/Resources/LegacyCoreTest.php
#	tests/TemplateTest.php
#	tests/Util/CallableArgumentsExtractorTest.php
2026-07-12 13:55:37 +02:00
Fabien Potencier 9c6d76b61c Add void return type hint even in tests 2026-07-12 13:43:08 +02:00
Fabien Potencier 04ace9dba0 Merge branch '3.x' into 4.x
* 3.x:
  Handle single-node child template bodies in cleanup
  Keep captured block definitions supported
  Clarify captured block deprecation wording
  Simplify correctness visitor checks
  Move extends validation into correctness visitor
  Fix correctness visitor regressions
  Fix test assertions that did not verify the intended behavior
  Address review: fix block-nesting checks in CorrectnessNodeVisitor
  Move the extends-in-block and extends-in-macro errors into the CorrectnessNodeVisitor
  Introduce a CorrectnessNodeVisitor to validate that templates are semantically correct
  Mark Markup as final
  Allow calling a macro with a dynamic name via the dot operator
  Add an allow-list for tests to the sandbox security policy
  Fix markdown_to_html mangling content that starts with a blank line

# Conflicts:
#	CHANGELOG
#	doc/deprecated.rst
#	doc/sandbox.rst
#	src/ExpressionParser/Infix/DotExpressionParser.php
#	src/Extension/CoreExtension.php
#	src/Markup.php
#	src/Node/CheckSecurityNode.php
#	src/Node/Expression/Filter/DefaultFilter.php
#	src/Node/Expression/NullCoalesceExpression.php
#	src/Node/IfNode.php
#	src/NodeVisitor/SandboxNodeVisitor.php
#	src/Parser.php
#	src/Sandbox/SecurityPolicy.php
#	tests/Extension/SandboxTest.php
#	tests/ParserTest.php
2026-06-11 07:57:54 +02:00
Fabien Potencier 113aec62e7 Fix markdown_to_html mangling content that starts with a blank line 2026-06-05 21:47:22 +02:00
Fabien Potencier 8dd0383353 Merge branch '3.x' into 4.x
* 3.x: (23 commits)
  Bump version
  Prepare the 3.26.0 release
  Update CHANGELOG
  Document that the sandbox doesn't protect against resource exhaustion
  Document template_from_string caveats when used in a sandboxed env
  Pre-escape HTML input on the `spaceless` filter
  Add docs on Markup about the goal of this class in the context of a sandbox
  Fix sandbox bypass in the "column" filter
  Fix sandbox `__toString` bypasses
  Validate macro name in MacroReferenceExpression constructor
  Fix sandbox bypass: PHP code injection via _self / import macro reference
  Fix deprecations in tests
  Fix sandbox bypass in the `{% sandbox %}` tag when including a preloaded template
  Encode single quotes as \x27 in Compiler::string()
  Fix sandbox bypass: PHP code injection via {% use %} template name
  Fix unbounded memoisation of `IntlDateFormatter` / `NumberFormatter`
  Fix deprecation
  [Profiler] Escape template and profile names in HtmlDumper
  Bump version
  Fix sandbox bypass: propagate sandbox state to checkArrow for source-policy sandboxing
  ...

# Conflicts:
#	CHANGELOG
#	doc/filters/spaceless.rst
#	extra/cssinliner-extra/CssInlinerExtension.php
#	extra/inky-extra/InkyExtension.php
#	extra/markdown-extra/MarkdownExtension.php
#	src/Environment.php
#	src/ExpressionParser/Infix/DotExpressionParser.php
#	src/Extension/CoreExtension.php
#	src/Node/Expression/FilterExpression.php
#	src/Node/Expression/FunctionExpression.php
#	src/Node/Expression/TestExpression.php
#	src/Node/ModuleNode.php
#	src/NodeVisitor/SandboxNodeVisitor.php
#	src/Resources/core.php
#	src/TokenParser/SandboxTokenParser.php
#	tests/Extension/SandboxTest.php
2026-05-21 13:58:45 +02:00
Nicolas Grekas 84982072c7 Fix XSS by adjusting is_safe annotation on HTML-emitting filters
The `html_to_markdown` filter emits plain Markdown text, so the
`is_safe` annotation is dropped entirely and autoescape now handles
its output according to the surrounding context.

The `markdown_to_html` and `inline_css` filters emit HTML, not text
safe in every escaping context, so `is_safe => ['all']` produced
unescaped HTML when their output was interpolated into a JS, CSS or
URL context. The annotation is now `is_safe => ['html']`.
2026-05-15 15:14:02 +02:00
Fabien Potencier 0facb551b0 Merge branch '3.x' into 4.x
* 3.x:
  Fix CS
2026-02-07 09:12:05 +01:00
Fabien Potencier 861215c507 Fix CS 2026-02-07 09:07:38 +01:00
Fabien Potencier 9ac4a2dd9c Merge branch '3.x' into 4.x
* 3.x:
  Fix tiny typo in CI workflow label
  Fix typo
  Fix opcache preload warning for unlinked anonymous class
  Bump version
  Prepare the 3.22.2 release
  Add .gitignore & .gitattributes to all .gitattributes
2026-01-07 16:24:12 +01:00
jmsche ff327e4163 Add .gitignore & .gitattributes to all .gitattributes 2025-12-02 15:45:16 +01:00
Fabien Potencier b03de9de05 Merge branch '3.x' into 4.x
* 3.x:
  Update CHANGELOG
  Fix accessing arrays with stringable objects as key
  Update inky_to_html.rst: Updating link
  Update replace.rst
  [Doc] Tweaks in the escaping article
  Compile 'index' with repr (not string) in EmbedNode
  Introduce registerUndefinedTestCallback
  Fix intl test
  Bump minimum Commonmark requirement
  Support two words test guard
  Bump version
  Improve documentation examples for `enum` and `enum_cases`
  Avoid errors when failing to guess the template info for an error
  Add note to format_datetime explaining how to install required extensions
  Fix compatibility layer
2025-10-29 11:55:46 -04:00
Fabien Potencier 8f970764e6 Bump minimum Commonmark requirement 2025-09-15 07:57:37 +02:00
Fabien Potencier 4ad55ff4c9 Merge branch '3.x' into 4.x
* 3.x:
  Fix wrong rounding_mode values
  #4677: Add use statements for classes referenced in the getOperators @psalm-return doc
  Update LeagueMarkdown.php
2025-08-17 19:19:20 +02:00
Fabien Potencier e05e818761 bug #4653 Allow usage of other Markdown converters than CommonMark in LeagueMarkdown (xJuvi)
This PR was merged into the 3.x branch.

Discussion
----------

Allow usage of other Markdown converters than CommonMark in LeagueMarkdown

Since the `CommonMarkConverter` from `League\CommonMark` doesn't allow customizing the `Environment` class at construct-time, this simple change allows providing an instance the parent class, so we can both inject a config to the converter AND a custom list of extensions (like `CommonMarkCoreExtension`) via the constructor.

This PR fixes #3581

Commits
-------

81e66e96bf Update LeagueMarkdown.php
2025-08-02 15:26:08 +02:00
Nicolas Grekas c649c1658b Merge branch '3.x' into 4.x
* 3.x:
  CS fixes
  Enable Fabbot as a GHA
2025-07-29 10:27:55 +02:00
Nicolas Grekas 85a4817128 CS fixes 2025-07-29 10:07:07 +02:00
Hannes 81e66e96bf Update LeagueMarkdown.php 2025-06-17 23:57:57 +02:00
Fabien Potencier dc6356268b Bump min PHP version to 8.1 2025-01-31 21:45:36 +01:00
Fabien Potencier 28246c5d4e Merge branch '3.x' into 4.x
* 3.x:
  Fixing minor typo in Update inline_css.rst
  Ignore static properties when using the dot operator
  Fix CS
  Fix constant() behavior when used with ??
  Finish the work
  fix indentation
  Apply suggestions from code review
  typo
  fix merge
  docs and changelog
  typehint instead of checkArrow
  checkArrow, typehints
  invoke filter
2025-01-24 11:32:17 +01:00
Fabien Potencier 76062c8d51 Fix CS 2025-01-19 16:54:05 +01:00
Fabien Potencier f087bd6aed Fix composer.json order 2024-12-02 17:36:43 +01:00
Fabien Potencier b9e3ccd7a3 Merge branch '3.x' into 4.x
* 3.x:
  fix version numbers for deprecations
  Require "erusev/parsedown": "dev-master as 1.x-dev"
  Support underscores in number literals
  Remove deprecate usage of AssignNameExpression in For Node
  Update coding standards
2024-12-02 17:35:59 +01:00
Nicolas Grekas 5287da57cc Require "erusev/parsedown": "dev-master as 1.x-dev" 2024-12-02 09:57:02 +01:00
Alexander M. Turek f2053bbea0 PHPUnit 11 2024-09-04 12:11:51 +02:00
Fabien Potencier a789eca738 Merge branch '3.x' into 4.x
* 3.x:
  Validate the input of CoreExtension::map()
  Rename AbstractTest to ProfilerTestCase
  Make data providers static
  Prepare IntegrationTestCase for static data providers
2024-09-03 22:20:28 +02:00
Fabien Potencier 722a5fb027 feature #4266 Prepare IntegrationTestCase for static data providers (derrabus)
This PR was merged into the 3.x branch.

Discussion
----------

Prepare IntegrationTestCase for static data providers

Data providers need to be static in PHPUnit 11. Because of this, I'd like to declare the two methods we use as data providers in `IntegrationTestCase` as static in 4.0. This PR prepares that change:

* The non-static `getFixturesDir()` method is replaced with a static `getFixturesDirectory()`.
* Both methods `getTests()` and `getLegacyTests()` are marked as final, so we can declare them static in the next major.

This however means that we're delaying PHPUnit 11 compatibility of integration tests to Twig 4.0. If that's too late for us, we could deprecate the whole `IntegrationTestCase` in favor of a compatible replacement. That's a bigger change, but I would work on it if you think it's worth it.

Commits
-------

18f42038 Prepare IntegrationTestCase for static data providers
2024-09-03 22:17:35 +02:00
Alexander M. Turek 6ddb76bb76 Make data providers static 2024-09-03 16:32:00 +02:00
Alexander M. Turek 18f4203827 Prepare IntegrationTestCase for static data providers 2024-09-03 15:08:40 +02:00
Fabien Potencier 06ac86e3dd Merge branch '3.x' into 4.x
* 3.x:
  Fix tests
  Allow extra extensions to use Twig 4
2024-09-01 23:00:16 +02:00
Fabien Potencier 976cea0403 Fix tests 2024-09-01 22:54:59 +02:00
Fabien Potencier 031c7bda4d Allow extra extensions to use Twig 4 2024-09-01 22:39:12 +02:00
Simon André 470965fcc2 Add missing return types in 4.0 2024-08-17 23:10:07 +02:00
Fabien Potencier c070cd719c Drop support for 8.0 2024-08-10 12:32:24 +02:00
Fabien Potencier 0131c230c7 Merge branch '3.x' into 4.x
* 3.x:
  Fix CS
2024-08-07 19:34:39 +02:00
Fabien Potencier f5e10e10f1 Fix CS 2024-08-07 19:34:09 +02:00
Fabien Potencier 8b47fc319a Use first class callable syntax 2024-07-14 14:01:33 +02:00
Fabien Potencier 67cb9a06fe Merge branch '3.x' into 4.x
* 3.x:
  Update PHPUnit config
  Optimize sprintf() calls for PHP 8.4
2024-06-21 08:27:27 +02:00
Fabien Potencier b78dee8682 Update PHPUnit config 2024-06-21 08:22:31 +02:00
Fabien Potencier b80f74af9a Merge branch '3.x' into 4.x
* 3.x:
  Bump version
  Prepare the 3.10.0 release
  Update CHANGELOG
  Fix markup
  Revert "minor #4042 Auto-close PRs on subtree-splits (kbond)"
  Fix typo
2024-05-11 09:45:46 +02:00
Fabien Potencier 761aa56a6f Revert "minor #4042 Auto-close PRs on subtree-splits (kbond)"
This reverts commit 12625c0c05, reversing
changes made to ad934312cd.
2024-05-11 09:35:57 +02:00
Fabien Potencier 9a11ee1c64 Merge branch '3.x' into 4.x
* 3.x:
  Bump version to 3.9.4-DEV
  Fix a warning
  Use ::class everywhere
  Auto-close PRs on subtree-splits
  Bump version
  Prepare the 3.9.3 release
  Update CHANGELOG
  Ensure Lexer:: is always initialized
  fix: #4033 add missing unwrap call when a TemplateWrapper instance can be present
  change extended DI extension class
  fix: #4029 when use_yield is true CaptureNode use iterator_to_array preserveKeys argument to false
2024-04-24 08:25:00 +02:00
Kevin Bond b212f1bb2f Auto-close PRs on subtree-splits 2024-04-19 08:34:22 +02:00
Fabien Potencier ae7e6cc9a3 Merge branch '3.x' into 4.x
* 3.x:
  Fix CS
  Remove redundant "$thing instanceof \Countable" check
  Update PHPUnit schema
  fix TwigExtraBundle tests with Symfony 6.0/6.1
2024-02-10 10:03:27 +01:00
Fabien Potencier f7f11ea410 Fix CS 2024-02-10 09:52:03 +01:00