Skip to content

Commit 7f2506d

Browse files
committed
Merge branch '6.2' into 6.3
* 6.2: Apply suggestions from code review Update HTML Sanitizer doc for `max_input_length` option Fix bug return type of closure fix missing 'private' declaration
2 parents 8497373 + e39cbf6 commit 7f2506d

File tree

3 files changed

+70
-2
lines changed

3 files changed

+70
-2
lines changed

form/use_empty_data.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ The closure must accept a ``FormInterface`` instance as the first argument::
9494
public function configureOptions(OptionsResolver $resolver): void
9595
{
9696
$resolver->setDefaults([
97-
'empty_data' => function (FormInterface $form) {
97+
'empty_data' => function (FormInterface $form): Blog {
9898
return new Blog($form->get('title')->getData());
9999
},
100100
]);

html_sanitizer.rst

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,73 @@ the HTML sanitizer: ``src``, ``href``, ``lowsrc``, ``background`` and ``ping``.
931931
->allowRelativeMedias()
932932
);
933933
934+
Max Input Length
935+
~~~~~~~~~~~~~~~~
936+
937+
In order to prevent `DoS attacks`_, by default the HTML sanitizer limits the
938+
input length to ``20000`` characters (as measured by ``strlen($input)``). All
939+
the contents exceeding that length will be truncated. Use this option to
940+
increase or decrease this limit:
941+
942+
.. configuration-block::
943+
944+
.. code-block:: yaml
945+
946+
# config/packages/html_sanitizer.yaml
947+
framework:
948+
html_sanitizer:
949+
sanitizers:
950+
app.post_sanitizer:
951+
# ...
952+
953+
# inputs longer (in characters) than this value will be truncated
954+
max_input_length: 30000 # default: 20000
955+
956+
.. code-block:: xml
957+
958+
<!-- config/packages/html_sanitizer.xml -->
959+
<?xml version="1.0" encoding="UTF-8" ?>
960+
<container xmlns="http://symfony.com/schema/dic/services"
961+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
962+
xmlns:framework="http://symfony.com/schema/dic/symfony"
963+
xsi:schemaLocation="http://symfony.com/schema/dic/services
964+
https://symfony.com/schema/dic/services/services-1.0.xsd
965+
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
966+
967+
<framework:config>
968+
<framework:html-sanitizer>
969+
<framework:sanitizer name="app.post_sanitizer">
970+
<!-- inputs longer (in characters) than this value will be truncated (default: 20000) -->
971+
<framework:max-input-length>20000</framework:max-input-length>
972+
</framework:sanitizer>
973+
</framework:html-sanitizer>
974+
</framework:config>
975+
</container>
976+
977+
.. code-block:: php
978+
979+
// config/packages/framework.php
980+
use Symfony\Config\FrameworkConfig;
981+
982+
return static function (FrameworkConfig $framework) {
983+
$framework->htmlSanitizer()
984+
->sanitizer('app.post_sanitizer')
985+
// inputs longer (in characters) than this value will be truncated (default: 20000)
986+
->withMaxInputLength(20000)
987+
;
988+
};
989+
990+
.. code-block:: php-standalone
991+
992+
use Symfony\Component\HtmlSanitizer\HtmlSanitizer;
993+
use Symfony\Component\HtmlSanitizer\HtmlSanitizerConfig;
994+
995+
$postSanitizer = new HtmlSanitizer(
996+
(new HtmlSanitizerConfig())
997+
// inputs longer (in characters) than this value will be truncated (default: 20000)
998+
->withMaxInputLength(20000)
999+
);
1000+
9341001
Custom Attribute Sanitizers
9351002
~~~~~~~~~~~~~~~~~~~~~~~~~~~
9361003

@@ -1013,3 +1080,4 @@ to enable it for an HTML sanitizer:
10131080
10141081
.. _`HTML Sanitizer W3C Standard Proposal`: https://wicg.github.io/sanitizer-api/
10151082
.. _`W3C Standard Proposal`: https://wicg.github.io/sanitizer-api/
1083+
.. _`DoS attacks`: https://en.wikipedia.org/wiki/Denial-of-service_attack

security/access_denied_handler.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ unauthenticated user tries to access a protected resource::
3434
class AuthenticationEntryPoint implements AuthenticationEntryPointInterface
3535
{
3636
public function __construct(
37-
UrlGeneratorInterface $urlGenerator,
37+
private UrlGeneratorInterface $urlGenerator,
3838
) {
3939
}
4040

0 commit comments

Comments
 (0)