wp_kses_check_attr_val()
wp_kses_check_attr_val( string $value, string $vless, s…
wp_kses_check_attr_val( string $value, string $vless, string $checkname, mixed $checkvalue )
对属性值执行不同的检查。
Performs different checks for attribute values.
目录锚点:#说明#参数#源码
说明(Description)
当前执行的检查是“maxlen”、“minlen”、“maxval”、“minval”和“valueless”。
参数(Parameters)
参数 | 类型 | 说明 |
---|---|---|
$value | (string) | 属性值。 |
$vless | (string) | 属性是否无值。使用“y”或“n”。 |
$checkname | (string) | $checkvalue正在检查的内容。 |
$checkvalue | (mixed) | 值应该传递什么约束。 |
源码(Source)
/** * Performs different checks for attribute values. * * The currently implemented checks are "maxlen", "minlen", "maxval", "minval" * and "valueless". * * @since 1.0.0 * * @param string $value Attribute value * @param string $vless Whether the value is valueless. Use 'y' or 'n' * @param string $checkname What $checkvalue is checking for. * @param mixed $checkvalue What constraint the value should pass * @return bool Whether check passes */ function wp_kses_check_attr_val($value, $vless, $checkname, $checkvalue) { $ok = true; switch (strtolower($checkname)) { case 'maxlen' : // The maxlen check makes sure that the attribute value has a length not // greater than the given value. This can be used to avoid Buffer Overflows // in WWW clients and various Internet servers. if (strlen($value) > $checkvalue) $ok = false; break; case 'minlen' : // The minlen check makes sure that the attribute value has a length not // smaller than the given value. if (strlen($value) < $checkvalue)="" $ok="false;" break;="" case="" 'maxval'="" :="" the="" maxval="" check="" does="" two="" things:="" it="" checks="" that="" the="" attribute="" value="" is="" an="" integer="" from="" 0="" and="" up,="" without="" an="" excessive="" amount="" of="" zeroes="" or="" whitespace="" (to="" avoid="" buffer="" overflows).="" it="" also="" checks="" that="" the="" attribute="" value="" is="" not="" greater="" than="" the="" given="" value.="" this="" check="" can="" be="" used="" to="" avoid="" denial="" of="" service="" attacks.="" if="" (!preg_match('/^s{0,6}[0-9]{1,6}s{0,6}$/',="" $value))="" $ok="false;" if="" ($value=""> $checkvalue) $ok = false; break; case 'minval' : // The minval check makes sure that the attribute value is a positive integer, // and that it is not smaller than the given value. if (!preg_match('/^s{0,6}[0-9]{1,6}s{0,6}$/', $value)) $ok = false; if ($value < $checkvalue)="" $ok="false;" break;="" case="" 'valueless'="" :="" the="" valueless="" check="" makes="" sure="" if="" the="" attribute="" has="" a="" value="" (like="">) or not (). If the given value // is a "y" or a "Y", the attribute must not have a value. // If the given value is an "n" or an "N", the attribute must have one. if (strtolower($checkvalue) != $vless) $ok = false; break; } // switch return $ok; }
更新版本 | 源码位置 | 使用 | 被使用 |
---|---|---|---|
1.0.0 | wp-includes/kses.php | 15 | 9 |
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。
还没有任何评论,赶紧来占个楼吧!