Skip to content

Commit 0e2d124

Browse files
committed
minor #46062 [HtmlSanitizer] Add HtmlSanitizerConfig::withMaxInputLength() (nicolas-grekas)
This PR was merged into the 6.1 branch. Discussion ---------- [HtmlSanitizer] Add HtmlSanitizerConfig::withMaxInputLength() | Q | A | ------------- | --- | Branch? | 6.1 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | Fix #symfony/symfony#44798 (review) | License | MIT | Doc PR | - Commits ------- 070f2cfc03 [HtmlSanitizer] Add HtmlSanitizerConfig::withMaxInputLength()
2 parents 1f20f61 + 0133e0c commit 0e2d124

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

DependencyInjection/Configuration.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2243,6 +2243,10 @@ private function addHtmlSanitizerSection(ArrayNodeDefinition $rootNode, callable
22432243
->info('Unregisters custom attribute sanitizers.')
22442244
->scalarPrototype()->end()
22452245
->end()
2246+
->integerNode('max_input_length')
2247+
->info('The maximum length allowed for the sanitized input.')
2248+
->defaultValue(0)
2249+
->end()
22462250
->end()
22472251
->end()
22482252
->end()

DependencyInjection/FrameworkExtension.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2734,6 +2734,10 @@ private function registerHtmlSanitizerConfiguration(array $config, ContainerBuil
27342734
$def->addMethodCall('withoutAttributeSanitizer', [new Reference($serviceName)], true);
27352735
}
27362736

2737+
if ($sanitizerConfig['max_input_length']) {
2738+
$def->addMethodCall('withMaxInputLength', [$sanitizerConfig['max_input_length']], true);
2739+
}
2740+
27372741
// Create the sanitizer and link its config
27382742
$sanitizerId = 'html_sanitizer.sanitizer.'.$sanitizerName;
27392743
$container->register($sanitizerId, HtmlSanitizer::class)->addArgument(new Reference($configId));

Resources/config/schema/symfony-1.0.xsd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,7 @@
850850
<xsd:attribute name="force-https-urls" type="xsd:boolean" />
851851
<xsd:attribute name="allow-relative-links" type="xsd:boolean" />
852852
<xsd:attribute name="allow-relative-medias" type="xsd:boolean" />
853+
<xsd:attribute name="max-input-length" type="xsd:positiveInteger" />
853854
</xsd:complexType>
854855

855856
<xsd:complexType name="element-option">

0 commit comments

Comments
 (0)