Index: trunk/extensions/RSS/RSSHooks.php |
— | — | @@ -29,7 +29,7 @@ |
30 | 30 | } else { |
31 | 31 | $timeout = $wgRSSCacheAge; |
32 | 32 | } |
33 | | - $parser->disableCache(); |
| 33 | + |
34 | 34 | $parser->getOutput()->updateCacheExpiry( $timeout ); |
35 | 35 | |
36 | 36 | $rss = new RSSParser( $input, $args ); |
Index: trunk/extensions/RSS/RSSParser.php |
— | — | @@ -254,33 +254,26 @@ |
255 | 255 | * @param $frame the frame param to pass to recursiveTagParse() |
256 | 256 | */ |
257 | 257 | protected function renderItem( $item, $parser, $frame ) { |
258 | | - $parts = explode( '|', $this->itemTemplate ); |
259 | | - |
260 | | - $output = ''; |
261 | | - if ( count( $parts ) > 1 && isset( $parser ) && isset( $frame ) ) { |
| 258 | + $output = ""; |
| 259 | + if ( isset( $parser ) && isset( $frame ) ) { |
262 | 260 | $rendered = array(); |
263 | 261 | foreach ( $this->displayFields as $field ) { |
264 | 262 | if ( isset($item[$field] ) ) { |
265 | | - $item[$field] = $this->highlightTerms( wfEscapeWikiText( $item[$field] ) ); |
| 263 | + $item[$field] = $this->highlightTerms( $item[$field] ); |
266 | 264 | } |
267 | 265 | } |
268 | 266 | |
269 | | - foreach ( $parts as $part ) { |
270 | | - $bits = explode( '=', $part ); |
271 | | - $left = null; |
272 | | - |
273 | | - if ( count( $bits ) == 2 ) { |
274 | | - $left = trim( $bits[0] ); |
275 | | - } |
276 | | - |
277 | | - if ( isset( $item[$left] ) ) { |
278 | | - $leftValue = str_replace( '{{{' . $left . '}}}', $item[$left], $bits[1] ); |
279 | | - $rendered[] = "$left = $leftValue"; |
280 | | - } else { |
281 | | - $rendered[] = $part; |
282 | | - } |
| 267 | + $rendered = $this->itemTemplate; |
| 268 | + // $info will only be an XML element name, so we're safe |
| 269 | + // using it. $item[$info] is handled by the XML parser -- |
| 270 | + // and that means bad RSS with stuff like |
| 271 | + // <description><script>alert("hi")</script></description> will find its |
| 272 | + // rogue <script> tags neutered. |
| 273 | + foreach ( array_keys( $item ) as $info ) { |
| 274 | + $rendered = str_replace( '{{{' . $info . '}}}', wfEscapeWikiText( $item[$info] ), |
| 275 | + $rendered ); |
283 | 276 | } |
284 | | - $output .= $parser->recursiveTagParse( implode( ' | ', $rendered ), $frame ); |
| 277 | + $output .= $parser->recursiveTagParse( $rendered, $frame ); |
285 | 278 | } |
286 | 279 | return $output; |
287 | 280 | } |
— | — | @@ -421,7 +414,7 @@ |
422 | 415 | $styleStart = "<span style='font-weight: bold; background: none repeat scroll 0%% 0%% rgb(%s); color: %s;'>"; |
423 | 416 | $styleEnd = '</span>'; |
424 | 417 | |
425 | | - # bg colors cribbed from Google's highlighting of search teerms |
| 418 | + # bg colors cribbed from Google's highlighting of search terms |
426 | 419 | $bgcolor = array( '255, 255, 102', '160, 255, 255', '153, 255, 153', |
427 | 420 | '255, 153, 153', '255, 102, 255', '136, 0, 0', '0, 170, 0', '136, 104, 0', |
428 | 421 | '0, 70, 153', '153, 0, 153' ); |