Ticket #5181: prep_content.2.patch
| File prep_content.2.patch, 5.2 KB (added by rubys, 5 years ago) |
|---|
-
wp-includes/feed-atom.php
30 30 <uri><?php the_author_url()?></uri> 31 31 <?php endif; ?> 32 32 </author> 33 <title type="<?php html_type_rss(); ?>"><![CDATA[<?php the_title_rss() ?>]]></title> 33 <?php list($content_type, $content) = prep_atom_text_construct(get_the_title()); ?> 34 <title type="<?php echo $content_type ?>"><?php echo $content ?></title> 34 35 <link rel="alternate" type="text/html" href="<?php the_permalink_rss() ?>" /> 35 36 <id><?php the_guid(); ?></id> 36 37 <updated><?php echo get_post_modified_time('Y-m-d\TH:i:s\Z', true); ?></updated> 37 38 <published><?php echo get_post_time('Y-m-d\TH:i:s\Z', true); ?></published> 38 39 <?php the_category_rss('atom') ?> 39 <summary type="<?php html_type_rss(); ?>"><![CDATA[<?php the_excerpt_rss(); ?>]]></summary> 40 <?php list($content_type, $content) = prep_atom_text_construct(get_the_excerpt()); ?> 41 <summary type="<?php echo $content_type ?>"><?php echo $content ?></summary> 40 42 <?php if ( !get_option('rss_use_excerpt') ) : ?> 41 <content type="<?php html_type_rss(); ?>" xml:base="<?php the_permalink_rss() ?>"><![CDATA[<?php the_content('', 0, '') ?>]]></content> 43 <?php list($content_type, $content) = prep_atom_text_construct(get_the_content()); ?> 44 <content type="<?php echo $content_type ?>" xml:base="<?php the_permalink_rss()?>"><?php echo $content ?></content> 42 45 <?php endif; ?> 43 46 <?php atom_enclosure(); ?> 44 47 <?php do_action('atom_entry'); ?> -
wp-includes/feed.php
250 250 } 251 251 } 252 252 253 function prep_atom_text_construct($data) { 254 if (strpos($data, '<') === false && strpos($data, '&') === false) { 255 return array('text', $data); 256 } 257 258 $parser = xml_parser_create(); 259 xml_parse($parser, '<div>' . $data . '</div>', true); 260 $code = xml_get_error_code($parser); 261 xml_parser_free($parser); 262 263 if (!$code) { 264 if (strpos($data, '<') === false) { 265 return array('text', $data); 266 } else { 267 $data = "<div xmlns='http://www.w3.org/1999/xhtml'>$data</div>"; 268 return array('xhtml', $data); 269 } 270 } 271 272 if (strpos($data, ']]>') == false) { 273 return array('html', "<![CDATA[$data]]>"); 274 } else { 275 return array('html', htmlspecialchars($data)); 276 } 277 } 278 253 279 ?> -
wp-app.php
12 12 require_once('./wp-config.php'); 13 13 require_once(ABSPATH . WPINC . '/post-template.php'); 14 14 require_once(ABSPATH . WPINC . '/atomlib.php'); 15 require_once(ABSPATH . WPINC . '/feed.php'); 15 16 16 17 $_SERVER['PATH_INFO'] = preg_replace( '/.*\/wp-app\.php/', '', $_SERVER['REQUEST_URI'] ); 17 18 … … 784 785 <entry xmlns="<?php echo $this->ATOM_NS ?>" 785 786 xmlns:app="<?php echo $this->ATOMPUB_NS ?>" xml:lang="<?php echo get_option('rss_language'); ?>"> 786 787 <id><?php the_guid($GLOBALS['post']->ID); ?></id> 787 <?php list($content_type, $content) = $this->prep_content(get_the_title()); ?>788 <?php list($content_type, $content) = prep_atom_text_construct(get_the_title()); ?> 788 789 <title type="<?php echo $content_type ?>"><?php echo $content ?></title> 789 790 <updated><?php echo get_post_modified_time('Y-m-d\TH:i:s\Z', true); ?></updated> 790 791 <published><?php echo get_post_time('Y-m-d\TH:i:s\Z', true); ?></published> … … 805 806 <?php } else { ?> 806 807 <link href="<?php the_permalink_rss() ?>" /> 807 808 <?php if ( strlen( $GLOBALS['post']->post_content ) ) : 808 list($content_type, $content) = $this->prep_content(get_the_content()); ?>809 list($content_type, $content) = prep_atom_text_construct(get_the_content()); ?> 809 810 <content type="<?php echo $content_type ?>"><?php echo $content ?></content> 810 811 <?php endif; ?> 811 812 <?php } ?> … … 813 814 <?php foreach(get_the_category() as $category) { ?> 814 815 <category scheme="<?php bloginfo_rss('home') ?>" term="<?php echo $category->name?>" /> 815 816 <?php } ?> 816 <?php list($content_type, $content) = $this->prep_content(get_the_excerpt()); ?>817 <?php list($content_type, $content) = prep_atom_text_construct(get_the_excerpt()); ?> 817 818 <summary type="<?php echo $content_type ?>"><?php echo $content ?></summary> 818 819 </entry> 819 820 <?php } 820 821 821 function prep_content($data) {822 if (strpos($data, '<') === false && strpos($data, '&') === false) {823 return array('text', $data);824 }825 826 $parser = xml_parser_create();827 xml_parse($parser, '<div>' . $data . '</div>', true);828 $code = xml_get_error_code($parser);829 xml_parser_free($parser);830 831 if (!$code) {832 if (strpos($data, '<') === false) {833 return array('text', $data);834 } else {835 $data = "<div xmlns='http://www.w3.org/1999/xhtml'>$data</div>";836 return array('xhtml', $data);837 }838 }839 840 if (strpos($data, ']]>') == false) {841 return array('html', "<![CDATA[$data]]>");842 } else {843 return array('html', htmlspecialchars($data));844 }845 }846 847 822 function ok() { 848 823 log_app('Status','200: OK'); 849 824 header('Content-Type: text/plain');
