diff options
author | Evan Prodromou <evan@prodromou.name> | 2008-09-17 07:27:30 -0400 |
---|---|---|
committer | Evan Prodromou <evan@prodromou.name> | 2008-09-17 07:27:30 -0400 |
commit | 7f8aaf46c8279c120c012d2b479e592bfa9611cf (patch) | |
tree | aa7e29d7784563d88fc73b9185913e98bf4d6379 /lib/util.php | |
parent | 00eb929c6ba314abf431d92117bd3cee5a73b2ff (diff) |
move rendering stuff that doesn't depend on notice to a separate function
darcs-hash:20080917112730-84dde-d8bf234bf2a0bf0aca17d653c3cdf57a76ad1a00.gz
Diffstat (limited to 'lib/util.php')
-rw-r--r-- | lib/util.php | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/util.php b/lib/util.php index 51dcbe939..ac2f9af36 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]+@', '<a href="\0" class="extlink">\0</a>', $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; |