そして一般的な構成浄水はiframe IDを表示します

プロジェクトアドレス

https://github.com/mewebstudio/Purifier

HTML清浄予防XSSの脆弱性にLaravelフレームワークのためのフィルタであります

インストール

composer require mews/purifier

コンフィギュレーションを生成します

php artisan vendor:publish --provider="Mews\Purifier\PurifierServiceProvider"

カスタム構成

config/purifier.php

'default' => [
    'HTML.Doctype'             => 'HTML 4.01 Transitional',
    'HTML.Allowed'             => 'div,b,strong,i,em,a[href|title],ul,ol,ol[start],li,p[style],br,span[style],img[width|height|alt|src],*[style|class],pre,hr,code,h1[id],h2,h3,h4,h5,h6,blockquote,del,table,thead,tbody,tr,th,td,iframe[width|height|src|frameborder|scrolling|allowfullscreen]',
    'CSS.AllowedProperties'    => 'font,font-size,font-weight,font-style,margin,width,height,font-family,text-decoration,padding-left,color,background-color,text-align',
    'AutoFormat.AutoParagraph' => true,
    'AutoFormat.RemoveEmpty'   => true,
    'Attr.EnableID' => true,
    'HTML.SafeIframe' => true,
    'URI.SafeIframeRegexp' => "%^(http://|https://|//)(www.youtube.com/embed/|player.bilibili.com)%",
],

設定手順

'Attr.EnableID' => true,id属性は、フィルターがしない
'HTML.SafeIframe' => true,のiframeタグをフィルタリングしない
'URI.SafeIframeRegexp' => "%^(http://|https://|//)(www.youtube.com/embed/|player.bilibili.com)%",許可されたアドレスはiframeを
赤い封筒アリペイ

リリース6元記事 ウォンの賞賛0 ビュー55

おすすめ

転載: blog.csdn.net/HelloMonkey564/article/details/105419424