@@ -931,6 +931,75 @@ the HTML sanitizer: ``src``, ``href``, ``lowsrc``, ``background`` and ``ping``.
931931 ->allowRelativeMedias()
932932 );
933933
934+ Configure max input length
935+ ~~~~~~~~~~~~~~~~~~~~~
936+
937+ Using this option, you can change the default max input length of ``20000 `` characters.
938+ Any input longer than this value will be truncated.
939+
940+ .. configuration-block ::
941+
942+ .. code-block :: yaml
943+
944+ # config/packages/html_sanitizer.yaml
945+ framework :
946+ html_sanitizer :
947+ sanitizers :
948+ app.post_sanitizer :
949+ # ...
950+
951+ # specifies the max input length. Inputs longer than this value will be
952+ # truncated (default: 20000)
953+ max_input_length : 20000
954+
955+ .. code-block :: xml
956+
957+ <!-- config/packages/html_sanitizer.xml -->
958+ <?xml version =" 1.0" encoding =" UTF-8" ?>
959+ <container xmlns =" http://symfony.com/schema/dic/services"
960+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
961+ xmlns : framework =" http://symfony.com/schema/dic/symfony"
962+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
963+ https://symfony.com/schema/dic/services/services-1.0.xsd
964+ http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
965+
966+ <framework : config >
967+ <framework : html-sanitizer >
968+ <framework : sanitizer name =" app.post_sanitizer" >
969+ <!-- specifies the max input length. Inputs longer than this value will be
970+ 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+ // specifies the max input length. Inputs longer than this value will be
986+ // truncated (default: 20000)
987+ ->withMaxInputLength(20000)
988+ ;
989+ };
990+
991+ .. code-block :: php-standalone
992+
993+ use Symfony\Component\HtmlSanitizer\HtmlSanitizer;
994+ use Symfony\Component\HtmlSanitizer\HtmlSanitizerConfig;
995+
996+ $postSanitizer = new HtmlSanitizer(
997+ (new HtmlSanitizerConfig())
998+ // specifies the max input length. Inputs longer than this value will be
999+ // truncated (default: 20000)
1000+ ->withMaxInputLength(20000)
1001+ );
1002+
9341003 Custom Attribute Sanitizers
9351004~~~~~~~~~~~~~~~~~~~~~~~~~~~
9361005
0 commit comments