• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP tln_sanitize函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中tln_sanitize函数的典型用法代码示例。如果您正苦于以下问题:PHP tln_sanitize函数的具体用法?PHP tln_sanitize怎么用?PHP tln_sanitize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了tln_sanitize函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: HTMLFilter

function HTMLFilter($body, $trans_image_path, $block_external_images = false)
{
    $tag_list = array(false, "object", "meta", "html", "head", "base", "link", "frame", "iframe", "plaintext", "marquee");
    $rm_tags_with_content = array("script", "applet", "embed", "title", "frameset", "xmp", "xml");
    $self_closing_tags = array("img", "br", "hr", "input", "outbind");
    $force_tag_closing = true;
    $rm_attnames = array("/.*/" => array("/^on.*/i", "/^dynsrc/i", "/^data.*/i", "/^lowsrc.*/i"));
    $bad_attvals = array("/.*/" => array("/^src|background/i" => array(array("/^([\\'\"])\\s*\\S+script\\s*:.*([\\'\"])/si", "/^([\\'\"])\\s*mocha\\s*:*.*([\\'\"])/si", "/^([\\'\"])\\s*about\\s*:.*([\\'\"])/si"), array("\\1{$trans_image_path}\\2", "\\1{$trans_image_path}\\2", "\\1{$trans_image_path}\\2", "\\1{$trans_image_path}\\2")), "/^href|action/i" => array(array("/^([\\'\"])\\s*\\S+script\\s*:.*([\\'\"])/si", "/^([\\'\"])\\s*mocha\\s*:*.*([\\'\"])/si", "/^([\\'\"])\\s*about\\s*:.*([\\'\"])/si"), array("\\1#\\1", "\\1#\\1", "\\1#\\1", "\\1#\\1")), "/^style/i" => array(array("/expression/i", "/binding/i", "/behaviou*r/i", "/include-source/i", "/position\\s*:\\s*absolute/i", "/url\\s*\\(\\s*([\\'\"])\\s*\\S+script\\s*:.*([\\'\"])\\s*\\)/si", "/url\\s*\\(\\s*([\\'\"])\\s*mocha\\s*:.*([\\'\"])\\s*\\)/si", "/url\\s*\\(\\s*([\\'\"])\\s*about\\s*:.*([\\'\"])\\s*\\)/si", "/(.*)\\s*:\\s*url\\s*\\(\\s*([\\'\"]*)\\s*\\S+script\\s*:.*([\\'\"]*)\\s*\\)/si"), array("idiocy", "idiocy", "idiocy", "idiocy", "", "url(\\1#\\1)", "url(\\1#\\1)", "url(\\1#\\1)", "url(\\1#\\1)", "url(\\1#\\1)", "\\1:url(\\2#\\3)"))));
    if ($block_external_images) {
        array_push($bad_attvals['/.*/']['/^src|background/i'][0], '/^([\'\\"])\\s*https*:.*([\'\\"])/si');
        array_push($bad_attvals['/.*/']['/^src|background/i'][1], "\\1{$trans_image_path}\\1");
        array_push($bad_attvals['/.*/']['/^style/i'][0], '/url\\(([\'\\"])\\s*https*:.*([\'\\"])\\)/si');
        array_push($bad_attvals['/.*/']['/^style/i'][1], "url(\\1{$trans_image_path}\\1)");
    }
    $add_attr_to_tag = array("/^a\$/i" => array('target' => '"_blank"'));
    $trusted = tln_sanitize($body, $tag_list, $rm_tags_with_content, $self_closing_tags, $force_tag_closing, $rm_attnames, $bad_attvals, $add_attr_to_tag);
    return $trusted;
}
开发者ID:bailey-ann,项目名称:stringtools,代码行数:18,代码来源:htmlfilter.php


示例2: HTMLFilter

function HTMLFilter($body, $trans_image_path, $block_external_images = false)
{
    $tag_list = [false, 'object', 'meta', 'html', 'head', 'base', 'link', 'frame', 'iframe', 'plaintext', 'marquee'];
    $rm_tags_with_content = ['script', 'applet', 'embed', 'title', 'frameset', 'xmp', 'xml'];
    $self_closing_tags = ['img', 'br', 'hr', 'input', 'outbind'];
    $force_tag_closing = true;
    $rm_attnames = ['/.*/' => ['/^on.*/i', '/^dynsrc/i', '/^data.*/i', '/^lowsrc.*/i']];
    $bad_attvals = ['/.*/' => ['/^src|background/i' => [['/^([\'"])\\s*\\S+script\\s*:.*([\'"])/si', '/^([\'"])\\s*mocha\\s*:*.*([\'"])/si', '/^([\'"])\\s*about\\s*:.*([\'"])/si'], ["\\1{$trans_image_path}\\2", "\\1{$trans_image_path}\\2", "\\1{$trans_image_path}\\2", "\\1{$trans_image_path}\\2"]], '/^href|action/i' => [['/^([\'"])\\s*\\S+script\\s*:.*([\'"])/si', '/^([\'"])\\s*mocha\\s*:*.*([\'"])/si', '/^([\'"])\\s*about\\s*:.*([\'"])/si'], ['\\1#\\1', '\\1#\\1', '\\1#\\1', '\\1#\\1']], '/^style/i' => [['/expression/i', '/binding/i', '/behaviou*r/i', '/include-source/i', '/position\\s*:\\s*absolute/i', '/url\\s*\\(\\s*([\'"])\\s*\\S+script\\s*:.*([\'"])\\s*\\)/si', '/url\\s*\\(\\s*([\'"])\\s*mocha\\s*:.*([\'"])\\s*\\)/si', '/url\\s*\\(\\s*([\'"])\\s*about\\s*:.*([\'"])\\s*\\)/si', '/(.*)\\s*:\\s*url\\s*\\(\\s*([\'"]*)\\s*\\S+script\\s*:.*([\'"]*)\\s*\\)/si'], ['idiocy', 'idiocy', 'idiocy', 'idiocy', '', 'url(\\1#\\1)', 'url(\\1#\\1)', 'url(\\1#\\1)', 'url(\\1#\\1)', 'url(\\1#\\1)', '\\1:url(\\2#\\3)']]]];
    if ($block_external_images) {
        array_push($bad_attvals['/.*/']['/^src|background/i'][0], '/^([\'\\"])\\s*https*:.*([\'\\"])/si');
        array_push($bad_attvals['/.*/']['/^src|background/i'][1], "\\1{$trans_image_path}\\1");
        array_push($bad_attvals['/.*/']['/^style/i'][0], '/url\\(([\'\\"])\\s*https*:.*([\'\\"])\\)/si');
        array_push($bad_attvals['/.*/']['/^style/i'][1], "url(\\1{$trans_image_path}\\1)");
    }
    $add_attr_to_tag = ['/^a$/i' => ['target' => '"_blank"']];
    $trusted = tln_sanitize($body, $tag_list, $rm_tags_with_content, $self_closing_tags, $force_tag_closing, $rm_attnames, $bad_attvals, $add_attr_to_tag);
    return $trusted;
}
开发者ID:ahmedash95,项目名称:Lily,代码行数:18,代码来源:htmlfilter.php



注:本文中的tln_sanitize函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP tln_unspace函数代码示例发布时间:2022-05-23
下一篇:
PHP tln_defang函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap