Automattic\WooCommerce\Internal\Logging

RemoteLogger::sanitize_request_uri()privateWC 1.0

Sanitize the request URI to only allow certain query parameters.

Метод класса: RemoteLogger{}

Возвращает

Строку. The sanitized request URI.

Использование

// private - только в коде основоного (родительского) класса
$result = $this->sanitize_request_uri( $request_uri );
$request_uri(строка) (обязательный)
The request URI to sanitize.

Код RemoteLogger::sanitize_request_uri() WC 9.3.3

private function sanitize_request_uri( $request_uri ) {
	$default_whitelist = array(
		'path',
		'page',
		'step',
		'task',
		'tab',
		'section',
		'status',
		'post_type',
		'taxonomy',
		'action',
	);

	/**
	 * Filter to allow other plugins to whitelist request_uri query parameter values for unmasked remote logging.
	 *
	 * @since 9.4.0
	 *
	 * @param string   $default_whitelist The default whitelist of query parameters.
	 */
	$whitelist = apply_filters( 'woocommerce_remote_logger_request_uri_whitelist', $default_whitelist );

	$parsed_url = wp_parse_url( $request_uri );
	if ( ! isset( $parsed_url['query'] ) ) {
		return $request_uri;
	}

	parse_str( $parsed_url['query'], $query_params );

	foreach ( $query_params as $key => &$value ) {
		if ( ! in_array( $key, $whitelist, true ) ) {
			$value = 'xxxxxx';
		}
	}

	$parsed_url['query'] = http_build_query( $query_params );
	return $this->build_url( $parsed_url );
}