WP_SimplePie_Sanitize_KSES

Core class used to implement SimpliePie feed sanitization.

Defined (1)

The class is defined in the following location(s).

/wp-includes/class-feed.php  
  1. class WP_SimplePie_Sanitize_KSES extends SimplePie_Sanitize { 
  2.  
  3. /** 
  4. * WordPress SimplePie sanitization using KSES. 
  5. * Sanitizes the incoming data, to ensure that it matches the type of data expected, using KSES. 
  6. * @since 3.5.0 
  7. * @access public 
  8. * @param mixed $data The data that needs to be sanitized. 
  9. * @param integer $type The type of data that it's supposed to be. 
  10. * @param string $base Optional. The `xml:base` value to use when converting relative 
  11. * URLs to absolute ones. Default empty. 
  12. * @return mixed Sanitized data. 
  13. */ 
  14. public function sanitize( $data, $type, $base = '' ) { 
  15. $data = trim( $data ); 
  16. if ( $type & SIMPLEPIE_CONSTRUCT_MAYBE_HTML ) { 
  17. 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)) { 
  18. $type |= SIMPLEPIE_CONSTRUCT_HTML; 
  19. else { 
  20. $type |= SIMPLEPIE_CONSTRUCT_TEXT; 
  21. if ( $type & SIMPLEPIE_CONSTRUCT_BASE64 ) { 
  22. $data = base64_decode( $data ); 
  23. if ( $type & ( SIMPLEPIE_CONSTRUCT_HTML | SIMPLEPIE_CONSTRUCT_XHTML ) ) { 
  24. $data = wp_kses_post( $data ); 
  25. if ( $this->output_encoding !== 'UTF-8' ) { 
  26. $data = $this->registry->call( 'Misc', 'change_encoding', array( $data, 'UTF-8', $this->output_encoding ) ); 
  27. return $data; 
  28. } else { 
  29. return parent::sanitize( $data, $type, $base );