当前位置: 首页>>代码示例>>PHP>>正文


PHP kses_decode_entities函数代码示例

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


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

示例1: kses_bad_protocol_once2

function kses_bad_protocol_once2($string, $allowed_protocols)
{
    $string2 = preg_replace('/\\s/', '', $string);
    $string2 = kses_decode_entities($string2);
    $string2 = kses_no_null($string2);
    $string2 = strtolower($string2);
    $allowed = false;
    foreach ($allowed_protocols as $one_protocol) {
        if (strtolower($one_protocol) == $string2) {
            $allowed = true;
            break;
        }
    }
    if ($allowed) {
        return "{$string2}:";
    } else {
        return '';
    }
}
开发者ID:maexlich,项目名称:boinc-igemathome,代码行数:19,代码来源:kses.php

示例2: cleanAttributes2

/**
 * This function takes a string with an html tag and strips out any unallowed
 * protocols e.g. javascript:
 *
 * It calls ancillary functions in kses which are prefixed by kses
 *
 * @global object
 * @global string
 * @param array $htmlArray An array from {@link cleanAttributes()}, containing in its 1st
 *              element the html to be cleared
 * @return string
 */
function cleanAttributes2($htmlArray)
{
    global $CFG, $ALLOWED_PROTOCOLS;
    require_once $CFG->libdir . '/kses.php';
    $htmlTag = $htmlArray[1];
    if (substr($htmlTag, 0, 1) != '<') {
        return '&gt;';
        //a single character ">" detected
    }
    if (!preg_match('%^<\\s*(/\\s*)?([a-zA-Z0-9]+)([^>]*)>?$%', $htmlTag, $matches)) {
        return '';
        // It's seriously malformed
    }
    $slash = trim($matches[1]);
    //trailing xhtml slash
    $elem = $matches[2];
    //the element name
    $attrlist = $matches[3];
    // the list of attributes as a string
    $attrArray = kses_hair($attrlist, $ALLOWED_PROTOCOLS);
    $attStr = '';
    foreach ($attrArray as $arreach) {
        $arreach['name'] = strtolower($arreach['name']);
        if ($arreach['name'] == 'style') {
            $value = $arreach['value'];
            while (true) {
                $prevvalue = $value;
                $value = kses_no_null($value);
                $value = preg_replace("/\\/\\*.*\\*\\//Us", '', $value);
                $value = kses_decode_entities($value);
                $value = preg_replace('/(&#[0-9]+)(;?)/', "\\1;", $value);
                $value = preg_replace('/(&#x[0-9a-fA-F]+)(;?)/', "\\1;", $value);
                if ($value === $prevvalue) {
                    $arreach['value'] = $value;
                    break;
                }
            }
            $arreach['value'] = preg_replace("/j\\s*a\\s*v\\s*a\\s*s\\s*c\\s*r\\s*i\\s*p\\s*t/i", "Xjavascript", $arreach['value']);
            $arreach['value'] = preg_replace("/v\\s*b\\s*s\\s*c\\s*r\\s*i\\s*p\\s*t/i", "Xvbscript", $arreach['value']);
            $arreach['value'] = preg_replace("/e\\s*x\\s*p\\s*r\\s*e\\s*s\\s*s\\s*i\\s*o\\s*n/i", "Xexpression", $arreach['value']);
            $arreach['value'] = preg_replace("/b\\s*i\\s*n\\s*d\\s*i\\s*n\\s*g/i", "Xbinding", $arreach['value']);
        } else {
            if ($arreach['name'] == 'href') {
                //Adobe Acrobat Reader XSS protection
                $arreach['value'] = preg_replace('/(\\.(pdf|fdf|xfdf|xdp|xfd)[^#]*)#.*$/i', '$1', $arreach['value']);
            }
        }
        $attStr .= ' ' . $arreach['name'] . '="' . $arreach['value'] . '"';
    }
    $xhtml_slash = '';
    if (preg_match('%/\\s*$%', $attrlist)) {
        $xhtml_slash = ' /';
    }
    return '<' . $slash . $elem . $attStr . $xhtml_slash . '>';
}
开发者ID:hatone,项目名称:moodle,代码行数:67,代码来源:weblib.php

示例3: kses_bad_protocol_once2

function kses_bad_protocol_once2($matches)
{
    //Zenphoto:preg_replace with the "e" modifier is deprecated, this is the callback
    global $_allowed_protocols;
    $allowed_protocols = $_allowed_protocols;
    $string2 = kses_decode_entities($matches[1]);
    $string2 = preg_replace('/\\s/', '', $string2);
    $string2 = kses_no_null($string2);
    $string2 = preg_replace('/\\xad+/', '', $string2);
    # deals with Opera "feature"
    $string2 = strtolower($string2);
    $allowed = false;
    foreach ($allowed_protocols as $one_protocol) {
        if (strtolower($one_protocol) == $string2) {
            $allowed = true;
            break;
        }
    }
    if ($allowed) {
        return "{$string2}:";
    } else {
        return '';
    }
}
开发者ID:molajo,项目名称:fieldhandler,代码行数:24,代码来源:kses.php

示例4: kses_bad_protocol_once2

function kses_bad_protocol_once2($matches)
{
    ###############################################################################
    # This function processes URL protocols, checks to see if they're in the white-
    # list or not, and returns different data depending on the answer.
    ###############################################################################
    //update// preg_replace with the "e" modifier is deprecated, this is the callback
    global $_allowed_protocols;
    $allowed_protocols = $_allowed_protocols;
    $string2 = kses_decode_entities($matches[1]);
    $string2 = preg_replace('/\\s/', '', $string2);
    $string2 = kses_no_null($string2);
    $string2 = preg_replace('/\\xad+/', '', $string2);
    # deals with Opera "feature"
    $string2 = strtolower($string2);
    $allowed = false;
    foreach ($allowed_protocols as $one_protocol) {
        if (strtolower($one_protocol) == $string2) {
            $allowed = true;
            break;
        }
    }
    if ($allowed) {
        return "{$string2}:";
    } else {
        return '';
    }
}
开发者ID:ariep,项目名称:ZenPhoto20-DEV,代码行数:28,代码来源:lib-kses.php


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