wp_check_jsonp_callback

函数


wp_check_jsonp_callback ( $callback )
参数
  • (string)
    $callback
    Supplied JSONP callback function name.
    Required:
返回值
  • (bool) Whether the callback function name is valid.
定义位置
  • wp-includes/functions.php
    , line 4505
引入
4.6.0
弃用

Checks that a JSONP callback is a valid JavaScript callback name.

Only allows alphanumeric characters and the dot character in callback
function names. This helps to mitigate XSS attacks caused by directly
outputting user input.

function wp_check_jsonp_callback( $callback ) {
	if ( ! is_string( $callback ) ) {
		return false;
	}

	preg_replace( '/[^w.]/', '', $callback, -1, $illegal_char_count );

	return 0 === $illegal_char_count;
}
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。