From: Evan Prodromou Date: Wed, 17 Sep 2008 11:27:30 +0000 (-0400) Subject: move rendering stuff that doesn't depend on notice to a separate function X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=7f8aaf46c8279c120c012d2b479e592bfa9611cf;p=quix0rs-gnu-social.git move rendering stuff that doesn't depend on notice to a separate function darcs-hash:20080917112730-84dde-d8bf234bf2a0bf0aca17d653c3cdf57a76ad1a00.gz --- diff --git a/lib/util.php b/lib/util.php index 51dcbe9394..ac2f9af360 100644 --- a/lib/util.php +++ b/lib/util.php @@ -686,13 +686,18 @@ function common_canonical_email($email) { define('URL_REGEX', '^|[ \t\r\n])((ftp|http|https|gopher|mailto|news|nntp|telnet|wais|file|prospero|aim|webcal):(([A-Za-z0-9$_.+!*(),;/?:@&~=-])|%[A-Fa-f0-9]{2}){2,}(#([a-zA-Z0-9][a-zA-Z0-9$_.+!*(),;/?:@&~=%-]*))?([A-Za-z0-9$_+!*();/?:~-]))'); function common_render_content($text, $notice) { + $r = common_render_text($text); + $id = $notice->profile_id; + $r = preg_replace('/(^|\s+)@([A-Za-z0-9]{1,64})/e', "'\\1@'.common_at_link($id, '\\2')", $r); + $r = preg_replace('/^T ([A-Z0-9]{1,64}) /e', "'T '.common_at_link($id, '\\1').' '", $r); + return $r; +} + +function common_render_text($text) { $r = htmlspecialchars($text); $r = preg_replace('/[\x{0}-\x{8}\x{b}-\x{c}\x{e}-\x{19}]/', '', $r); - $id = $notice->profile_id; $r = preg_replace('@https?://[^)\]>\s]+@', '\0', $r); - $r = preg_replace('/(^|\s+)@([A-Za-z0-9]{1,64})/e', "'\\1@'.common_at_link($id, '\\2')", $r); - $r = preg_replace('/^T ([A-Z0-9]{1,64}) /e', "'T '.common_at_link($id, '\\1').' '", $r); $r = preg_replace('/(^|\s+)#([A-Za-z0-9_\-\.]{1,64})/e', "'\\1#'.common_tag_link('\\2')", $r); # XXX: machine tags return $r;