wp_kses_js_entities()
云策文档标注
概述
wp_kses_js_entities() 函数用于移除早期 Netscape 4 版本中的 HTML JavaScript 实体,以防止特定安全漏洞。该函数在 WordPress 4.7.0 中已被弃用,因为该漏洞仅影响旧浏览器,且正则表达式处理已被移除以提高性能。
关键要点
- 函数 wp_kses_js_entities() 移除早期 Netscape 4 中的 HTML JavaScript 实体,以解决特定安全漏洞。
- 该漏洞从未影响其他浏览器,在现代网络中可视为安全。
- 函数在 WordPress 4.7.0 中被弃用,正则表达式处理已被移除,现在仅直接返回输入内容。
- 参数 $content 为必需字符串,函数返回字符串类型。
- 相关函数 _deprecated_function() 用于标记弃用并通知使用情况。
代码示例
function wp_kses_js_entities( $content ) {
_deprecated_function( __FUNCTION__, '4.7.0' );
return preg_replace( '%&s*{[^}]*(}s*;?|$)%', '', $content );
}注意事项
- 该函数已弃用,建议开发者避免在新代码中使用,并检查现有代码以更新或移除相关调用。
- 正则表达式处理已被移除,函数现在仅传递输入,不再执行实际清理操作。
原文内容
Removes the HTML JavaScript entities found in early versions of Netscape 4.
Description
Previously, this function was pulled in from the original import of kses and removed a specific vulnerability only existent in early version of Netscape 4. However, this vulnerability never affected any other browsers and can be considered safe for the modern web.
The regular expression which sanitized this vulnerability has been removed in consideration of the performance and energy demands it placed, now merely passing through its input to the return.
Parameters
$contentstringrequired
Source
function wp_kses_js_entities( $content ) {
_deprecated_function( __FUNCTION__, '4.7.0' );
return preg_replace( '%&s*{[^}]*(}s*;?|$)%', '', $content );
}