初始化

This commit is contained in:
2026-08-08 18:27:38 +08:00
parent efc150c937
commit 060eb79c09
336 changed files with 24613 additions and 15 deletions
+46
View File
@@ -0,0 +1,46 @@
<?php
/**
* HTMLPurifier 配置(mews/purifier ^3.4)。
*
* 文章正文为富文本(Quill 产出的 HTML),保存前统一经 Purifier 净化,
* 剥离 script/style/on* 等危险内容,仅保留排版与图片所需标签/属性。
*
* 使用:Purifier::clean($html, 'article')。'default' 作为兜底档。
* Cache.DefinitionImpl 置 null:关闭定义缓存,省去可写缓存目录,部署更省心。
*/
return [
'settings' => [
'default' => [
'HTML.Doctype' => 'HTML 4.01 Transitional',
'HTML.Allowed' => 'div,b,strong,i,em,u,a[href|title|target|rel],ul,ol,li,p,br,span,img[src|alt|width|height|class],blockquote,pre,code,table,thead,tbody,tr,th,td,h1,h2,h3,h4,h5,h6,hr,small,sub,sup',
'CSS.AllowedProperties' => 'text-align,float,margin,width,height,max-width,color,background-color,font-size,font-weight,font-style',
'AutoFormat.AutoParagraph' => false,
'AutoFormat.RemoveEmpty' => true,
'Attr.AllowedFrameTargets' => ['_blank'],
'Attr.AllowedRel' => ['nofollow', 'noopener', 'noreferrer'],
'HTML.TargetBlank' => true,
'URI.AllowedSchemes' => ['http', 'https', 'mailto', 'tel', 'data'],
'URI.MakeAbsolute' => false,
'Cache.DefinitionImpl' => null,
],
'article' => [
'HTML.Doctype' => 'HTML 4.01 Transitional',
// 后台富文本(Quill)会产出 classql-align-*/ql-size-*/ql-indent-* 等,
// 同时首页 Hero 默认内容也用 class 排版;故对常用块级/行内标签放开 class,
// 仅保留白名单标签与安全的 CSS 属性(style 仍受 CSS.AllowedProperties 约束)。
'HTML.Allowed' => 'div[class|style],b[style],strong[style],i[style],em[style],u[style],a[href|title|target|rel|class|style],ul[class|style],ol[class|style],li[class|style],p[class|style],br,span[class|style],img[src|alt|width|height|class|style],blockquote[class|style],pre[class|style],code[class|style],table[class|style],thead[class|style],tbody[class|style],tr[class|style],th[class|style],td[class|style],h1[class|style],h2[class|style],h3[class|style],h4[class|style],h5[class|style],h6[class|style],hr,small[class|style],sub,sup',
'CSS.AllowedProperties' => 'text-align,float,margin,margin-left,margin-right,padding,padding-left,width,height,max-width,color,background-color,font-size,font-weight,font-style',
'AutoFormat.AutoParagraph' => false,
'AutoFormat.RemoveEmpty' => false,
'Attr.AllowedFrameTargets' => ['_blank'],
'Attr.AllowedRel' => ['nofollow', 'noopener', 'noreferrer'],
'HTML.TargetBlank' => true,
'URI.AllowedSchemes' => ['http', 'https', 'mailto', 'tel', 'data'],
'URI.MakeAbsolute' => false,
'Cache.DefinitionImpl' => null,
],
],
'custom_definition' => [],
];