diff --git a/wp-app.php b/wp-app.php index b35e0d87a..dee5cb04d 100644 --- a/wp-app.php +++ b/wp-app.php @@ -12,6 +12,7 @@ define('APP_REQUEST', true); require_once('./wp-config.php'); require_once(ABSPATH . WPINC . '/post-template.php'); require_once(ABSPATH . WPINC . '/atomlib.php'); +require_once(ABSPATH . WPINC . '/feed.php'); $_SERVER['PATH_INFO'] = preg_replace( '/.*\/wp-app\.php/', '', $_SERVER['REQUEST_URI'] ); @@ -784,7 +785,7 @@ EOD; ID); ?> -prep_content(get_the_title()); ?> + <?php echo $content ?> @@ -805,7 +806,7 @@ EOD; post_content ) ) : -list($content_type, $content) = $this->prep_content(get_the_content()); ?> +list($content_type, $content) = prep_atom_text_construct(get_the_content()); ?> @@ -813,37 +814,11 @@ list($content_type, $content) = $this->prep_content(get_the_content()); ?> -prep_content(get_the_excerpt()); ?> + ' . $data . '', true); - $code = xml_get_error_code($parser); - xml_parser_free($parser); - - if (!$code) { - if (strpos($data, '<') === false) { - return array('text', $data); - } else { - $data = "
$data
"; - return array('xhtml', $data); - } - } - - if (strpos($data, ']]>') == false) { - return array('html', ""); - } else { - return array('html', htmlspecialchars($data)); - } - } - function ok() { log_app('Status','200: OK'); header('Content-Type: text/plain'); diff --git a/wp-includes/feed-atom.php b/wp-includes/feed-atom.php index 0bb3c5e18..5f5570df1 100644 --- a/wp-includes/feed-atom.php +++ b/wp-includes/feed-atom.php @@ -30,15 +30,18 @@ $more = 1; - <![CDATA[<?php the_title_rss() ?>]]> + + <?php echo $content ?> - ]]> + + - ]]> + + diff --git a/wp-includes/feed.php b/wp-includes/feed.php index 8f9219c59..bb204ea20 100644 --- a/wp-includes/feed.php +++ b/wp-includes/feed.php @@ -250,4 +250,46 @@ function atom_enclosure() { } } +/** + * prep_atom_text_construct() - determine if given string of data is + * type text, html, or xhtml, per RFC 4287 section 3.1. + * + * In the case of WordPress, text is defined as containing no markup, + * xhtml is defined as "well formed", and html as tag soup (i.e., the rest). + * + * Container div tags are added to xhtml values, per section 3.1.1.3. + * + * @package WordPress + * @subpackage Feed + * + * @param string $data input string + * @return array $result array(type, value) + * @link http://www.atomenabled.org/developers/syndication/atom-format-spec.php#rfc.section.3.1 + */ +function prep_atom_text_construct($data) { + if (strpos($data, '<') === false && strpos($data, '&') === false) { + return array('text', $data); + } + + $parser = xml_parser_create(); + xml_parse($parser, '
' . $data . '
', true); + $code = xml_get_error_code($parser); + xml_parser_free($parser); + + if (!$code) { + if (strpos($data, '<') === false) { + return array('text', $data); + } else { + $data = "
$data
"; + return array('xhtml', $data); + } + } + + if (strpos($data, ']]>') == false) { + return array('html', ""); + } else { + return array('html', htmlspecialchars($data)); + } +} + ?>