[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Feed API: WP_SimplePie_Sanitize_KSES class 4 * 5 * @package WordPress 6 * @subpackage Feed 7 * @since 4.7.0 8 */ 9 10 /** 11 * Core class used to implement SimplePie feed sanitization. 12 * 13 * Extends the SimplePie\Sanitize class to use KSES, because 14 * we cannot universally count on DOMDocument being available. 15 * 16 * @since 3.5.0 17 */ 18 #[AllowDynamicProperties] 19 class WP_SimplePie_Sanitize_KSES extends SimplePie\Sanitize { 20 21 /** 22 * WordPress SimplePie sanitization using KSES. 23 * 24 * Sanitizes the incoming data, to ensure that it matches the type of data expected, using KSES. 25 * 26 * @since 3.5.0 27 * 28 * @param mixed $data The data that needs to be sanitized. 29 * @param int $type The type of data that it's supposed to be. 30 * @param string $base Optional. The `xml:base` value to use when converting relative 31 * URLs to absolute ones. Default empty. 32 * @return mixed Sanitized data. 33 */ 34 public function sanitize( $data, $type, $base = '' ) { 35 $data = trim( $data ); 36 if ( $type & SimplePie\SimplePie::CONSTRUCT_MAYBE_HTML ) { 37 if ( preg_match( '/(&(#(x[0-9a-fA-F]+|[0-9]+)|[a-zA-Z0-9]+)|<\/[A-Za-z][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E]*' . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . '>)/', $data ) ) { 38 $type |= SimplePie\SimplePie::CONSTRUCT_HTML; 39 } else { 40 $type |= SimplePie\SimplePie::CONSTRUCT_TEXT; 41 } 42 } 43 if ( $type & SimplePie\SimplePie::CONSTRUCT_BASE64 ) { 44 $data = base64_decode( $data ); 45 } 46 if ( $type & ( SimplePie\SimplePie::CONSTRUCT_HTML | \SimplePie\SimplePie::CONSTRUCT_XHTML ) ) { 47 $data = wp_kses_post( $data ); 48 if ( 'UTF-8' !== $this->output_encoding ) { 49 $data = $this->registry->call( 'Misc', 'change_encoding', array( $data, 'UTF-8', $this->output_encoding ) ); 50 } 51 return $data; 52 } else { 53 return parent::sanitize( $data, $type, $base ); 54 } 55 } 56 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Sat Dec 21 08:20:01 2024 | Cross-referenced by PHPXref |