summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEvan Prodromou <evan@prodromou.name>2008-09-17 07:27:30 -0400
committerEvan Prodromou <evan@prodromou.name>2008-09-17 07:27:30 -0400
commit7f8aaf46c8279c120c012d2b479e592bfa9611cf (patch)
treeaa7e29d7784563d88fc73b9185913e98bf4d6379 /lib
parent00eb929c6ba314abf431d92117bd3cee5a73b2ff (diff)
move rendering stuff that doesn't depend on notice to a separate function
darcs-hash:20080917112730-84dde-d8bf234bf2a0bf0aca17d653c3cdf57a76ad1a00.gz
Diffstat (limited to 'lib')
-rw-r--r--lib/util.php11
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;