Ampersands in Code ..
Posted: Mon May 18, 2015 7:25 am
Code: Select all
&
Code: Select all
<div class="serendipity_commentBody clearfix content">
<p class="whiteline"><img src="http://www.deimeke.net/dirk/blog/index.php?/plugin/cachedAvatar_cd250bbdfe737a04fbabc18a74ee997e_3138b2d6a8060d847599d293f0486b10_e009b4c6ab13f11bd3b76f11c0070bc4" alt="*" title="Florian Bruhin" class="comment_avatar avatar_right" height="40" width="40"/>Hm, das Kommentarsystem scheint offensichtlich ampersands (zumindest in code-Blöcken) kaputt zu machen.
</p><p class="whiteline">foo & bar
</p><p class="break"><div class="bb-code-title">CODE:</div><div class="bb-code">foo & bar</div></p>
</div>
Code: Select all
{$comment.body|replace:"&":"&"
Code: Select all
/**
* Fix double encoded entities by htmlspeciachars() for ISO-8859-1 charsets
* and some other cases
*
* @param string
* @access public
* @return string
*/
function serendipity_smarty_fixUTFEntity($string) {
return preg_replace('/&#(x[a-f0-9]{1,4}|[0-9]{1,5});/', '&#$1;', str_replace('&','&',$string));
}
Code: Select all
$serendipity['smarty']->registerPlugin('modifier', 'serendipity_fixUTFEntity', 'serendipity_smarty_fixUTFEntity');
Code: Select all
{$comment.title|escape|serendipity_fixUTFEntity}
{$comment.fullBody|strip|serendipity_fixUTFEntity|truncate:120} for summary comments
{$comment.fullBody|serendipity_fixUTFEntity}