return $text;
}
- $text = preg_replace_callback('/<code>(.*?)<\/code>/ism', 'self::encode', $text);
+ $text = preg_replace_callback('/<(pre)>(.*?)<\/pre>/ism', 'self::encode', $text);
+ $text = preg_replace_callback('/<(code)>(.*?)<\/code>/ism', 'self::encode', $text);
if ($no_images) {
$cleaned = ['texts' => [], 'icons' => []];
$text = preg_replace_callback('/<(3+)/', 'self::pregHeart', $text);
$text = self::strOrigReplace($smilies['texts'], $smilies['icons'], $text);
- $text = preg_replace_callback('/<code>(.*?)<\/code>/ism', 'self::decode', $text);
+ $text = preg_replace_callback('/<(code)>(.*?)<\/code>/ism', 'self::decode', $text);
+ $text = preg_replace_callback('/<(pre)>(.*?)<\/pre>/ism', 'self::decode', $text);
return $text;
}
*/
private static function encode($m)
{
- return '<code>' . Strings::base64UrlEncode($m[1]) . '</code>';
+ return '<' . $m[1] . '>' . Strings::base64UrlEncode($m[2]) . '</' . $m[1] . '>';
}
/**
*/
private static function decode($m)
{
- return '<code>' . Strings::base64UrlDecode($m[1]) . '</code>';
+ return '<' . $m[1] . '>' . Strings::base64UrlDecode($m[2]) . '</' . $m[1] . '>';
}
* @return string HTML Output
*
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
- * @todo : Rework because it doesn't work correctly
*/
private static function pregHeart($x)
{
if (strlen($x[1]) == 1) {
return $x[0];
}
+
$t = '';
for ($cnt = 0; $cnt < strlen($x[1]); $cnt ++) {
- $t .= '<img class="smiley" src="' . System::baseUrl() . '/images/smiley-heart.gif" alt="<3" />';
+ $t .= '❤';
}
+
$r = str_replace($x[0], $t, $x[0]);
return $r;
}