web/wp-includes/class-feed.php
changeset 204 09a1c134465b
parent 194 32102edaa81b
equal deleted inserted replaced
203:f507feede89a 204:09a1c134465b
    83 				$this->headers = wp_remote_retrieve_headers( $res );
    83 				$this->headers = wp_remote_retrieve_headers( $res );
    84 				$this->body = wp_remote_retrieve_body( $res );
    84 				$this->body = wp_remote_retrieve_body( $res );
    85 				$this->status_code = wp_remote_retrieve_response_code( $res );
    85 				$this->status_code = wp_remote_retrieve_response_code( $res );
    86 			}
    86 			}
    87 		} else {
    87 		} else {
    88 			if ( ! $this->body = file_get_contents($url) ) {
    88 			if ( ! file_exists($url) || ( ! $this->body = file_get_contents($url) ) ) {
    89 				$this->error = 'file_get_contents could not read the file';
    89 				$this->error = 'file_get_contents could not read the file';
    90 				$this->success = false;
    90 				$this->success = false;
    91 			}
    91 			}
    92 		}
    92 		}
    93 	}
    93 	}
    94 }
    94 }
       
    95 
       
    96 /**
       
    97  * WordPress SimplePie Sanitization Class
       
    98  *
       
    99  * Extension of the SimplePie_Sanitize class to use KSES, because
       
   100  * we cannot universally count on DOMDocument being available
       
   101  *
       
   102  * @package WordPress
       
   103  * @since 3.5.0
       
   104  */
       
   105 class WP_SimplePie_Sanitize_KSES extends SimplePie_Sanitize {
       
   106 	public function sanitize( $data, $type, $base = '' ) {
       
   107 		$data = trim( $data );
       
   108 		if ( $type & SIMPLEPIE_CONSTRUCT_MAYBE_HTML ) {
       
   109 			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)) {
       
   110 				$type |= SIMPLEPIE_CONSTRUCT_HTML;
       
   111 			}
       
   112 			else {
       
   113 				$type |= SIMPLEPIE_CONSTRUCT_TEXT;
       
   114 			}
       
   115 		}
       
   116 		if ( $type & SIMPLEPIE_CONSTRUCT_BASE64 ) {
       
   117 			$data = base64_decode( $data );
       
   118 		}
       
   119 		if ( $type & ( SIMPLEPIE_CONSTRUCT_HTML | SIMPLEPIE_CONSTRUCT_XHTML ) ) {
       
   120 			$data = wp_kses_post( $data );
       
   121 			if ( $this->output_encoding !== 'UTF-8' ) {
       
   122 				$data = $this->registry->call( 'Misc', 'change_encoding', array( $data, 'UTF-8', $this->output_encoding ) );
       
   123 			}
       
   124 			return $data;
       
   125 		} else {
       
   126 			return parent::sanitize( $data, $type, $base );
       
   127 		}
       
   128 	}
       
   129 }