搭建轻舟一期门户、后台和统一登录。
让分类、会员和示例工具共用同一账号,本地即可跑通登录与授权。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Support;
|
||||
|
||||
class HtmlSanitizer
|
||||
{
|
||||
public static function clean(?string $html): string
|
||||
{
|
||||
$html = strip_tags((string) $html, '<p><br><strong><em><ul><ol><li><a><h2><h3><code>');
|
||||
$html = preg_replace('/\son\w+\s*=\s*("[^"]*"|\'[^\']*\'|[^\s>]+)/i', '', $html) ?? '';
|
||||
$html = preg_replace_callback('/<a\b([^>]*)>/i', function (array $matches) {
|
||||
$attrs = $matches[1];
|
||||
if (! preg_match('/href\s*=\s*("|\')(https?:\/\/[^"\']+)\1/i', $attrs, $href)) {
|
||||
return '<a>';
|
||||
}
|
||||
|
||||
return '<a href="'.htmlspecialchars($href[2], ENT_QUOTES).'" rel="noopener noreferrer">';
|
||||
}, $html) ?? '';
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user