@@ -208,6 +208,7 @@ function h($text, $tags = null) {
208
208
$ text = preg_replace ('/\r?\n/ ' ,'' ,$ text );
209
209
//br
210
210
$ text = preg_replace ('/<br(\s\/)? ' .'>/i ' ,'[br] ' ,$ text );
211
+ $ text = preg_replace ('/<p(\s\/)? ' .'>/i ' ,'[br] ' ,$ text );
211
212
$ text = preg_replace ('/(\[br\]\s*){10,}/i ' ,'[br] ' ,$ text );
212
213
//过滤危险的属性,如:过滤on事件lang js
213
214
while (preg_match ('/(<[^><]+)( lang|on|action|background|codebase|dynsrc|lowsrc)[^><]+/i ' ,$ text ,$ mat )){
@@ -221,7 +222,7 @@ function h($text, $tags = null) {
221
222
}
222
223
//允许的HTML标签
223
224
$ text = preg_replace ('/<( ' .$ tags .')( [^><\[\]]*)>/i ' ,'[\1\2] ' ,$ text );
224
- $ text = preg_replace ('/<\/( ' .$ tags .')>/Ui ' ,'[/\1] ' ,$ text );
225
+ $ text = preg_replace ('/<\/( ' .$ tags .')>/Ui ' ,'[/\1] ' ,$ text );
225
226
//过滤多余html
226
227
$ text = preg_replace ('/<\/?(html|head|meta|link|base|basefont|body|bgsound|title|style|script|form|iframe|frame|frameset|applet|id|ilayer|layer|name|script|style|xml)[^><]*>/i ' ,'' ,$ text );
227
228
//过滤合法的html标签
@@ -484,4 +485,4 @@ function auto_charset($fContents, $from='gbk', $to='utf-8') {
484
485
else {
485
486
return $ fContents ;
486
487
}
487
- }
488
+ }
0 commit comments