Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf4612fb

Browse files
javiereguiluzweaverryan
authored andcommitted
minor#18029 [HtmlSanitizer] Fix API usage on PHP config files (alexandre-daubois)
This PR was merged into the 6.2 branch.Discussion----------[HtmlSanitizer] Fix API usage on PHP config filesFixes#18024Commits-------2c8a35d [HtmlSanitizer] Fix API usage on PHP config files
1 parentd54ec53 commitf4612fb

File tree

1 file changed

+10
-22
lines changed

1 file changed

+10
-22
lines changed

‎html_sanitizer.rst‎

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -364,16 +364,13 @@ attributes from the `W3C Standard Proposal`_ are allowed.
364364
$framework->htmlSanitizer()
365365
->sanitizer('app.post_sanitizer')
366366
// allow the <article> element and 2 attributes
367-
->allowElement('article')
368-
->attribute('class')
369-
->attribute('data-attr')
367+
->allowElement('article', ['class', 'data-attr'])
370368
371369
// allow the <img> element and preserve the src attribute
372-
->allowElement('img')
373-
->attribute('src')
370+
->allowElement('img', 'src')
374371
375372
// allow the <h1> element with all safe attributes
376-
->allowElement('h1', '*')
373+
->allowElement('h1')
377374
;
378375
};
379376
@@ -528,12 +525,10 @@ on all elements allowed *before this setting*.
528525
$framework->htmlSanitizer()
529526
->sanitizer('app.post_sanitizer')
530527
// allow "src' on <iframe> elements
531-
->allowAttribute('src')
532-
->element('iframe')
528+
->allowAttribute('src', ['iframe'])
533529
534530
// allow "data-attr" on all elements currently allowed
535-
->allowAttribute('data-attr')
536-
->element('*')
531+
->allowAttribute('data-attr', '*')
537532
;
538533
};
539534
@@ -620,12 +615,10 @@ This option allows you to disallow attributes that were allowed before.
620615
->element('*')
621616
622617
// ...except for the <section> element
623-
->dropAttriute('data-attr')
624-
->element('section')
618+
->dropAttribute('data-attr', ['section'])
625619
626620
// disallows "style' on any allowed element
627621
->dropAttribute('style')
628-
->element('*')
629622
;
630623
};
631624
@@ -640,7 +633,7 @@ This option allows you to disallow attributes that were allowed before.
640633
->allowAttribute('data-attr')
641634
642635
// ...except for the <section> element
643-
->dropAttriute('data-attr', ['section'])
636+
->dropAttribute('data-attr', ['section'])
644637
645638
// disallows "style' on any allowed element
646639
->dropAttribute('style')
@@ -695,8 +688,7 @@ element (even if the original one didn't contain a ``rel`` attribute):
695688
return static function (FrameworkConfig $framework) {
696689
$framework->htmlSanitizer()
697690
->sanitizer('app.post_sanitizer')
698-
->forceAttribute('a')
699-
->attribute('rel', 'noopener noreferrer')
691+
->forceAttribute('a', 'rel', 'noopener noreferrer')
700692
;
701693
};
702694
@@ -791,9 +783,7 @@ URLs of ``<a>`` elements:
791783
792784
// specifies the allowed URL schemes. If the URL has a different scheme, the
793785
// attribute will be dropped
794-
->allowedLinkScheme('http')
795-
->allowedLinkScheme('https')
796-
->allowedLinkScheme('mailto')
786+
->allowedLinkSchemes(['http', 'https', 'mailto'])
797787
798788
// specifies the allowed hosts, the attribute will be dropped if the
799789
// URL contains a different host
@@ -907,9 +897,7 @@ the HTML sanitizer: ``src``, ``href``, ``lowsrc``, ``background`` and ``ping``.
907897
908898
// specifies the allowed URL schemes. If the URL has a different scheme, the
909899
// attribute will be dropped
910-
->allowedMediaScheme('http')
911-
->allowedMediaScheme('https')
912-
->allowedMediaScheme('mailto')
900+
->allowedMediaSchemes(['http', 'https', 'mailto'])
913901
914902
// specifies the allowed hosts, the attribute will be dropped if the URL
915903
// contains a different host

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp