1
0

Atom feeds became invalid, if entry has href or src attributes containing char represented by XML Entities normaly (like href="test.de?a=1&b=2")

This commit is contained in:
Grischa Brockhaus
2007-07-27 14:17:34 +00:00
parent 69a4aa1ab7
commit 0c94c97b34
2 changed files with 22 additions and 4 deletions

@ -3,6 +3,11 @@
Version 1.3 () Version 1.3 ()
------------------------------------------------------------------------ ------------------------------------------------------------------------
* Atom feeds became invalid, if entry has href or src attributes
containing char represented by XML Entities normaly
(like href="test.de?a=1&b=2")
(brockhaus)
* The recent entries sidebar plugin shiped with s9y listed entries * The recent entries sidebar plugin shiped with s9y listed entries
not accessable by the current user because of right restrictions. not accessable by the current user because of right restrictions.
(brockhaus) (brockhaus)
@ -22,8 +27,8 @@ Version 1.2 ()
* (beta4) Fix comment-RSS feeds * (beta4) Fix comment-RSS feeds
* (beta4) serendipity_plugin_comments now also supports Favatars in * (beta4) serendipity_plugin_comments now also supports Favatars and
combination with serendipity_event_gravatar instead of Pavatars in combination with serendipity_event_gravatar instead of
Gravatars only. (brockhaus) Gravatars only. (brockhaus)
* (beta4) Fix wrong event hook for entry manager to display toolbar * (beta4) Fix wrong event hook for entry manager to display toolbar

@ -64,8 +64,9 @@ function serendipity_printEntries_rss(&$entries, $version, $comments = false, $f
$ext = ''; $ext = '';
} }
$addData = array('from' => 'functions_entries:printEntries_rss'); $addData = array('from' => 'functions_entries:printEntries_rss','rss_options' => $options);
serendipity_plugin_api::hook_event('frontend_display', $entry, $addData); serendipity_plugin_api::hook_event('frontend_display', $entry, $addData);
// Do some relative -> absolute URI replacing magic. Replaces all HREF/SRC (<a>, <img>, ...) references to only the serendipitypath with the full baseURL URI // Do some relative -> absolute URI replacing magic. Replaces all HREF/SRC (<a>, <img>, ...) references to only the serendipitypath with the full baseURL URI
// garvin: Could impose some problems. Closely watch this one. // garvin: Could impose some problems. Closely watch this one.
$entry['body'] = preg_replace('@(href|src)=("|\')(' . preg_quote($serendipity['serendipityHTTPPath']) . ')(.*)("|\')(.*)>@imsU', '\1=\2' . $serendipity['baseURL'] . '\4\2\6>', $entry['body']); $entry['body'] = preg_replace('@(href|src)=("|\')(' . preg_quote($serendipity['serendipityHTTPPath']) . ')(.*)("|\')(.*)>@imsU', '\1=\2' . $serendipity['baseURL'] . '\4\2\6>', $entry['body']);
@ -132,10 +133,16 @@ function serendipity_printEntries_rss(&$entries, $version, $comments = false, $f
case 'atom0.3': case 'atom0.3':
$entry_hook = 'frontend_display:atom-0.3:per_entry'; $entry_hook = 'frontend_display:atom-0.3:per_entry';
$hrefPattern = '@(href|src)\s*?="(.*?)"@si';
$entry['feed_body'] = preg_replace_callback($hrefPattern, _hrefsrcEntityReplacer, $entry['feed_body']);
$entry['feed_ext'] = preg_replace_callback($hrefPattern, _hrefsrcEntityReplacer, $entry['feed_ext']);
break; break;
case 'atom1.0': case 'atom1.0':
$entry_hook = 'frontend_display:atom-1.0:per_entry'; $entry_hook = 'frontend_display:atom-1.0:per_entry';
$hrefPattern = '@(href|src)\s*?="(.*?)"@si';
$entry['feed_body'] = preg_replace_callback($hrefPattern, _hrefsrcEntityReplacer, $entry['feed_body']);
$entry['feed_ext'] = preg_replace_callback($hrefPattern, _hrefsrcEntityReplacer, $entry['feed_ext']);
break; break;
} }
@ -143,4 +150,10 @@ function serendipity_printEntries_rss(&$entries, $version, $comments = false, $f
$entry['per_entry_display_dat'] = $entry['display_dat']; $entry['per_entry_display_dat'] = $entry['display_dat'];
} }
} }
} }
function _hrefsrcEntityReplacer($treffer){
return $treffer[1] . '="' . htmlspecialchars($treffer[2]) . '"';
}