From 0125f293245a55a46af202e49bfa98bb983d2c57 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Sun, 20 Sep 2009 21:39:57 -0700 Subject: [PATCH 01/13] Don't trigger E_NOTICE when looking for commands in the notice input explode() only returns one item if there was no space, leading to an E_NOTICE about an undefined array index in the list($a,$b) pattern. --- lib/commandinterpreter.php | 42 ++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/lib/commandinterpreter.php b/lib/commandinterpreter.php index 6e4340e5dc..60fc4c3c44 100644 --- a/lib/commandinterpreter.php +++ b/lib/commandinterpreter.php @@ -28,7 +28,7 @@ class CommandInterpreter # XXX: localise $text = preg_replace('/\s+/', ' ', trim($text)); - list($cmd, $arg) = explode(' ', $text, 2); + list($cmd, $arg) = $this->split_arg($text); # We try to support all the same commands as Twitter, see # http://getsatisfaction.com/twitter/topics/what_are_the_twitter_commands @@ -43,7 +43,7 @@ class CommandInterpreter return new HelpCommand($user); case 'on': if ($arg) { - list($other, $extra) = explode(' ', $arg, 2); + list($other, $extra) = $this->split_arg($arg); if ($extra) { return null; } else { @@ -54,7 +54,7 @@ class CommandInterpreter } case 'off': if ($arg) { - list($other, $extra) = explode(' ', $arg, 2); + list($other, $extra) = $this->split_arg($arg); if ($extra) { return null; } else { @@ -74,7 +74,7 @@ class CommandInterpreter if (!$arg) { return null; } - list($other, $extra) = explode(' ', $arg, 2); + list($other, $extra) = $this->split_arg($arg); if ($extra) { return null; } else { @@ -84,7 +84,7 @@ class CommandInterpreter if (!$arg) { return null; } - list($other, $extra) = explode(' ', $arg, 2); + list($other, $extra) = $this->split_arg($arg); if ($extra) { return null; } else { @@ -95,7 +95,7 @@ class CommandInterpreter if (!$arg) { return null; } - list($other, $extra) = explode(' ', $arg, 2); + list($other, $extra) = $this->split_arg($arg); if ($extra) { return null; } else { @@ -106,7 +106,7 @@ class CommandInterpreter if (!$arg) { return null; } - list($other, $extra) = explode(' ', $arg, 2); + list($other, $extra) = $this->split_arg($arg); if ($extra) { return null; } else { @@ -117,7 +117,7 @@ class CommandInterpreter if (!$arg) { return null; } - list($other, $extra) = explode(' ', $arg, 2); + list($other, $extra) = $this->split_arg($arg); if ($extra) { return null; } else { @@ -128,7 +128,7 @@ class CommandInterpreter if (!$arg) { return null; } - list($other, $extra) = explode(' ', $arg, 2); + list($other, $extra) = $this->split_arg($arg); if (!$extra) { return null; } else { @@ -138,7 +138,7 @@ class CommandInterpreter if (!$arg) { return null; } - list($other, $extra) = explode(' ', $arg, 2); + list($other, $extra) = $this->split_arg($arg); if ($extra) { return null; } else { @@ -148,7 +148,7 @@ class CommandInterpreter if (!$arg) { return null; } - list($other, $extra) = explode(' ', $arg, 2); + list($other, $extra) = $this->split_arg($arg); if ($extra) { return null; } else { @@ -158,7 +158,7 @@ class CommandInterpreter if (!$arg) { return null; } - list($other, $extra) = explode(' ', $arg, 2); + list($other, $extra) = $this->split_arg($arg); if ($extra) { return null; } else { @@ -173,7 +173,7 @@ class CommandInterpreter if (!$arg) { return null; } - list($other, $extra) = explode(' ', $arg, 2); + list($other, $extra) = $this->split_arg($arg); if ($extra) { return null; } else { @@ -183,7 +183,7 @@ class CommandInterpreter if (!$arg) { return null; } - list($word, $extra) = explode(' ', $arg, 2); + list($word, $extra) = $this->split_arg($arg); if ($extra) { return null; } else if ($word == 'off') { @@ -195,7 +195,7 @@ class CommandInterpreter if (!$arg) { return null; } - list($word, $extra) = explode(' ', $arg, 2); + list($word, $extra) = $this->split_arg($arg); if ($extra) { return null; } else if ($word == 'all') { @@ -213,5 +213,17 @@ class CommandInterpreter return false; } } + + /** + * Split arguments without triggering a PHP notice warning + */ + function split_arg($text) + { + $pieces = explode(' ', $text, 2); + if (count($pieces) == 1) { + $pieces[] = null; + } + return $pieces; + } } From 3c89d31b1883e478d69a121905e5a9a400a17622 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Sun, 20 Sep 2009 22:30:10 -0700 Subject: [PATCH 02/13] Fixes for posting shortened URLs or uploads * If no shortener plugin is enabled, fall back to using the long URL instead of trying to load nonexistent ur1.ca plugin and throwing 'Class does not exist' * Fix bad call to call_user_func_array() in callback_helper() which broke all shortening --- lib/util.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/util.php b/lib/util.php index b74dc619c1..d9ff8b863b 100644 --- a/lib/util.php +++ b/lib/util.php @@ -493,7 +493,7 @@ function callback_helper($matches, $callback, $notice_id) { }while($original_url!=$url); if(empty($notice_id)){ - $result = call_user_func_array($callback,$url); + $result = call_user_func_array($callback, array($url)); }else{ $result = call_user_func_array($callback, array(array($url,$notice_id)) ); } @@ -1374,10 +1374,14 @@ function common_shorten_url($long_url) $svc = $user->urlshorteningservice; } global $_shorteners; - if(! $_shorteners[$svc]){ + if (!isset($_shorteners[$svc])) { //the user selected service doesn't exist, so default to ur1.ca $svc = 'ur1.ca'; } + if (!isset($_shorteners[$svc])) { + // no shortener plugins installed. + return $long_url; + } $reflectionObj = new ReflectionClass($_shorteners[$svc]['callInfo'][0]); $short_url_service = $reflectionObj->newInstanceArgs($_shorteners[$svc]['callInfo'][1]); From 5b91223ce4ece508b25397dc00e1d04ef2e1bc28 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 21 Sep 2009 14:14:55 -0400 Subject: [PATCH 03/13] add a hook at point of enqueuing notices --- EVENTS.txt | 7 +++++++ lib/util.php | 15 ++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/EVENTS.txt b/EVENTS.txt index 121ae175d0..64c3c08c7c 100644 --- a/EVENTS.txt +++ b/EVENTS.txt @@ -254,3 +254,10 @@ StartApiRss: after the rss element is started StartApiAtom: after the element is started - $action: action object being shown +StartEnqueueNotice: about to add a notice to the queues (good place to add a new transport) +- $notice: the notice being added +- &$transports: modifiable list of transports (as strings) to queue for + +EndEnqueueNotice: after adding a notice to the queues +- $notice: the notice being added +- $transports: modifiable list of transports to use diff --git a/lib/util.php b/lib/util.php index d9ff8b863b..eb247562dc 100644 --- a/lib/util.php +++ b/lib/util.php @@ -915,11 +915,16 @@ function common_enqueue_notice($notice) } } - $qm = QueueManager::get(); + if (Event::handle('StartEnqueueNotice', array($notice, &$transports))) { - foreach ($transports as $transport) - { - $qm->enqueue($notice, $transport); + $qm = QueueManager::get(); + + foreach ($transports as $transport) + { + $qm->enqueue($notice, $transport); + } + + Event::handle('EndEnqueueNotice', array($notice, $transports)); } return true; @@ -1384,7 +1389,7 @@ function common_shorten_url($long_url) } $reflectionObj = new ReflectionClass($_shorteners[$svc]['callInfo'][0]); - $short_url_service = $reflectionObj->newInstanceArgs($_shorteners[$svc]['callInfo'][1]); + $short_url_service = $reflectionObj->newInstanceArgs($_shorteners[$svc]['callInfo'][1]); $short_url = $short_url_service->shorten($long_url); if(substr($short_url,0,7)=='http://'){ From eb41d9e5da6a9d1e9b31ca017b5534eb6bd25b32 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 21 Sep 2009 14:23:35 -0400 Subject: [PATCH 04/13] add a hook for the unqueuemanager --- EVENTS.txt | 4 ++++ lib/unqueuemanager.php | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/EVENTS.txt b/EVENTS.txt index 64c3c08c7c..56f91f87a4 100644 --- a/EVENTS.txt +++ b/EVENTS.txt @@ -261,3 +261,7 @@ StartEnqueueNotice: about to add a notice to the queues (good place to add a new EndEnqueueNotice: after adding a notice to the queues - $notice: the notice being added - $transports: modifiable list of transports to use + +UnqueueHandleNotice: Handle a notice when no queue manager is available +- $notice: the notice to handle +- $queue: the "queue" that is being executed \ No newline at end of file diff --git a/lib/unqueuemanager.php b/lib/unqueuemanager.php index c5dc29d386..269ecdeaa0 100644 --- a/lib/unqueuemanager.php +++ b/lib/unqueuemanager.php @@ -73,7 +73,9 @@ class UnQueueManager jabber_broadcast_notice($notice); break; default: - throw ServerException("UnQueueManager: Unknown queue: $type"); + if (Event::handle('UnqueueHandleNotice', array(&$notice, $queue))) { + throw ServerException("UnQueueManager: Unknown queue: $queue"); + } } } From 6a088afd4be4076a31e8713ed96ac62060bf7278 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 21 Sep 2009 14:29:43 -0400 Subject: [PATCH 05/13] you can add a daemon to getvaliddaemons --- EVENTS.txt | 5 ++++- scripts/getvaliddaemons.php | 29 ++++++++++++++++++++--------- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/EVENTS.txt b/EVENTS.txt index 56f91f87a4..d3b58ffb01 100644 --- a/EVENTS.txt +++ b/EVENTS.txt @@ -264,4 +264,7 @@ EndEnqueueNotice: after adding a notice to the queues UnqueueHandleNotice: Handle a notice when no queue manager is available - $notice: the notice to handle -- $queue: the "queue" that is being executed \ No newline at end of file +- $queue: the "queue" that is being executed + +GetValidDaemons: Just before determining which daemons to run +- &$daemons: modifiable list of daemon scripts to run, filenames relative to scripts/ diff --git a/scripts/getvaliddaemons.php b/scripts/getvaliddaemons.php index 8f48e8e6f0..92edacfd3c 100755 --- a/scripts/getvaliddaemons.php +++ b/scripts/getvaliddaemons.php @@ -35,20 +35,31 @@ ENDOFHELP; require_once INSTALLDIR.'/scripts/commandline.inc'; +$daemons = array(); + if(common_config('xmpp','enabled')) { - echo "xmppdaemon.php jabberqueuehandler.php publicqueuehandler.php "; - echo "xmppconfirmhandler.php "; + $daemons[] = 'xmppdaemon.php'; + $daemons[] = 'jabberqueuehandler.php'; + $daemons[] = 'publicqueuehandler.php'; + $daemons[] = 'xmppconfirmhandler.php'; } if(common_config('twitterbridge','enabled')) { - echo "twitterstatusfetcher.php "; + $daemons[] = 'twitterstatusfetcher.php'; } -echo "ombqueuehandler.php "; +$daemons[] = 'ombqueuehandler.php'; if (common_config('twitter', 'enabled')) { - echo "twitterqueuehandler.php "; - echo "synctwitterfriends.php "; + $daemons[] = 'twitterqueuehandler.php'; + $daemons[] = 'synctwitterfriends.php'; } -echo "facebookqueuehandler.php "; -echo "pingqueuehandler.php "; +$daemons[] = 'facebookqueuehandler.php'; +$daemons[] = 'pingqueuehandler.php'; if (common_config('sms', 'enabled')) { - echo "smsqueuehandler.php "; + $daemons[] = 'smsqueuehandler.php'; +} + +if (Event::handle('GetValidDaemons', array(&$daemons))) { + foreach ($daemons as $daemon) { + print $daemon . ' '; + } + print "\n"; } From 98924a80d776107a734b44027dda18094b1f093f Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 21 Sep 2009 14:39:22 -0400 Subject: [PATCH 06/13] 'easy' way to handle notices at queue time --- EVENTS.txt | 3 ++ lib/unqueuemanager.php | 3 ++ lib/util.php | 3 +- scripts/pluginqueuehandler.php | 58 ++++++++++++++++++++++++++++++++++ 4 files changed, 66 insertions(+), 1 deletion(-) create mode 100755 scripts/pluginqueuehandler.php diff --git a/EVENTS.txt b/EVENTS.txt index d3b58ffb01..2b16d43c07 100644 --- a/EVENTS.txt +++ b/EVENTS.txt @@ -268,3 +268,6 @@ UnqueueHandleNotice: Handle a notice when no queue manager is available GetValidDaemons: Just before determining which daemons to run - &$daemons: modifiable list of daemon scripts to run, filenames relative to scripts/ + +HandleQueuedNotice: Handle a queued notice at queue time (or immediately if no queue) +- &$notice: notice to handle diff --git a/lib/unqueuemanager.php b/lib/unqueuemanager.php index 269ecdeaa0..6cfe5bcbd3 100644 --- a/lib/unqueuemanager.php +++ b/lib/unqueuemanager.php @@ -72,6 +72,9 @@ class UnQueueManager require_once(INSTALLDIR.'/lib/jabber.php'); jabber_broadcast_notice($notice); break; + case 'plugin': + Event::handle('HandleQueuedNotice', array(&$notice)); + break; default: if (Event::handle('UnqueueHandleNotice', array(&$notice, $queue))) { throw ServerException("UnQueueManager: Unknown queue: $queue"); diff --git a/lib/util.php b/lib/util.php index eb247562dc..37744fc5b7 100644 --- a/lib/util.php +++ b/lib/util.php @@ -897,7 +897,8 @@ function common_enqueue_notice($notice) 'twitter', 'facebook', 'ping'); - static $allTransports = array('sms'); + + static $allTransports = array('sms', 'plugin'); $transports = $allTransports; diff --git a/scripts/pluginqueuehandler.php b/scripts/pluginqueuehandler.php new file mode 100755 index 0000000000..ae807db6af --- /dev/null +++ b/scripts/pluginqueuehandler.php @@ -0,0 +1,58 @@ +#!/usr/bin/env php +. + */ + +define('INSTALLDIR', realpath(dirname(__FILE__) . '/..')); + +$shortoptions = 'i::'; +$longoptions = array('id::'); + +$helptext = <<runOnce(); From f6c70ea327a83f77acbca14bca32f262e6b3a098 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 21 Sep 2009 14:42:20 -0400 Subject: [PATCH 07/13] have to provide full path for daemons --- scripts/getvaliddaemons.php | 22 +++++++++++----------- scripts/startdaemons.sh | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/scripts/getvaliddaemons.php b/scripts/getvaliddaemons.php index 92edacfd3c..684799a0ee 100755 --- a/scripts/getvaliddaemons.php +++ b/scripts/getvaliddaemons.php @@ -38,23 +38,23 @@ require_once INSTALLDIR.'/scripts/commandline.inc'; $daemons = array(); if(common_config('xmpp','enabled')) { - $daemons[] = 'xmppdaemon.php'; - $daemons[] = 'jabberqueuehandler.php'; - $daemons[] = 'publicqueuehandler.php'; - $daemons[] = 'xmppconfirmhandler.php'; + $daemons[] = INSTALLDIR.'/scripts/xmppdaemon.php'; + $daemons[] = INSTALLDIR.'/scripts/jabberqueuehandler.php'; + $daemons[] = INSTALLDIR.'/scripts/publicqueuehandler.php'; + $daemons[] = INSTALLDIR.'/scripts/xmppconfirmhandler.php'; } if(common_config('twitterbridge','enabled')) { - $daemons[] = 'twitterstatusfetcher.php'; + $daemons[] = INSTALLDIR.'/scripts/twitterstatusfetcher.php'; } -$daemons[] = 'ombqueuehandler.php'; +$daemons[] = INSTALLDIR.'/scripts/ombqueuehandler.php'; if (common_config('twitter', 'enabled')) { - $daemons[] = 'twitterqueuehandler.php'; - $daemons[] = 'synctwitterfriends.php'; + $daemons[] = INSTALLDIR.'/scripts/twitterqueuehandler.php'; + $daemons[] = INSTALLDIR.'/scripts/synctwitterfriends.php'; } -$daemons[] = 'facebookqueuehandler.php'; -$daemons[] = 'pingqueuehandler.php'; +$daemons[] = INSTALLDIR.'/scripts/facebookqueuehandler.php'; +$daemons[] = INSTALLDIR.'/scripts/pingqueuehandler.php'; if (common_config('sms', 'enabled')) { - $daemons[] = 'smsqueuehandler.php'; + $daemons[] = INSTALLDIR.'/scripts/smsqueuehandler.php'; } if (Event::handle('GetValidDaemons', array(&$daemons))) { diff --git a/scripts/startdaemons.sh b/scripts/startdaemons.sh index 298162673c..5fb75414d3 100755 --- a/scripts/startdaemons.sh +++ b/scripts/startdaemons.sh @@ -40,7 +40,7 @@ DAEMONS=`php $DIR/getvaliddaemons.php $ARGSG` for f in $DAEMONS; do printf "Starting $f..."; - php $DIR/$f $ARGSD + php $f $ARGSD printf "DONE.\n" done From fe4751de50f2c26953dca79ab51543f8adb12353 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 21 Sep 2009 14:44:16 -0400 Subject: [PATCH 08/13] add the plugin daemon --- scripts/getvaliddaemons.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/scripts/getvaliddaemons.php b/scripts/getvaliddaemons.php index 684799a0ee..6dd0197129 100755 --- a/scripts/getvaliddaemons.php +++ b/scripts/getvaliddaemons.php @@ -37,22 +37,27 @@ require_once INSTALLDIR.'/scripts/commandline.inc'; $daemons = array(); +$daemons[] = INSTALLDIR.'/scripts/pluginqueuehandler.php'; +$daemons[] = INSTALLDIR.'/scripts/ombqueuehandler.php'; +$daemons[] = INSTALLDIR.'/scripts/facebookqueuehandler.php'; +$daemons[] = INSTALLDIR.'/scripts/pingqueuehandler.php'; + if(common_config('xmpp','enabled')) { $daemons[] = INSTALLDIR.'/scripts/xmppdaemon.php'; $daemons[] = INSTALLDIR.'/scripts/jabberqueuehandler.php'; $daemons[] = INSTALLDIR.'/scripts/publicqueuehandler.php'; $daemons[] = INSTALLDIR.'/scripts/xmppconfirmhandler.php'; } + if(common_config('twitterbridge','enabled')) { $daemons[] = INSTALLDIR.'/scripts/twitterstatusfetcher.php'; } -$daemons[] = INSTALLDIR.'/scripts/ombqueuehandler.php'; + if (common_config('twitter', 'enabled')) { $daemons[] = INSTALLDIR.'/scripts/twitterqueuehandler.php'; $daemons[] = INSTALLDIR.'/scripts/synctwitterfriends.php'; } -$daemons[] = INSTALLDIR.'/scripts/facebookqueuehandler.php'; -$daemons[] = INSTALLDIR.'/scripts/pingqueuehandler.php'; + if (common_config('sms', 'enabled')) { $daemons[] = INSTALLDIR.'/scripts/smsqueuehandler.php'; } From 3bdf8423c408734ebb5ba614360e8b9048ff0039 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Mon, 21 Sep 2009 16:29:22 -0400 Subject: [PATCH 09/13] Fix typo is default hub url --- plugins/PubSubHubBub/PubSubHubBubPlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/PubSubHubBub/PubSubHubBubPlugin.php b/plugins/PubSubHubBub/PubSubHubBubPlugin.php index 013a234d73..d7061ac0ed 100644 --- a/plugins/PubSubHubBub/PubSubHubBubPlugin.php +++ b/plugins/PubSubHubBub/PubSubHubBubPlugin.php @@ -31,7 +31,7 @@ if (!defined('STATUSNET')) { exit(1); } -define('DEFAULT_HUB','http://2pubsubhubbub.appspot.com'); +define('DEFAULT_HUB','http://pubsubhubbub.appspot.com'); require_once(INSTALLDIR.'/plugins/PubSubHubBub/publisher.php'); From 5cccbe987f9003ec4c40dbdcce254fe04069b107 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Mon, 21 Sep 2009 16:33:15 -0400 Subject: [PATCH 10/13] Use new queue handler event --- plugins/PubSubHubBub/PubSubHubBubPlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/PubSubHubBub/PubSubHubBubPlugin.php b/plugins/PubSubHubBub/PubSubHubBubPlugin.php index d7061ac0ed..e1e82e352c 100644 --- a/plugins/PubSubHubBub/PubSubHubBubPlugin.php +++ b/plugins/PubSubHubBub/PubSubHubBubPlugin.php @@ -59,7 +59,7 @@ class PubSubHubBubPlugin extends Plugin $action->element('atom:link',array('rel'=>'hub','href'=>$this->hub),null); } - function onEndNoticeSave($notice){ + function onHandleQueuedNotice($notice){ $publisher = new Publisher($this->hub); $feeds = array(); From ebb52efeb48212626d41a79b9d7e4f505323d074 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Mon, 21 Sep 2009 22:48:19 -0400 Subject: [PATCH 11/13] Make link href the long url so users can tell where links are going --- lib/util.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/util.php b/lib/util.php index 37744fc5b7..018b7cad51 100644 --- a/lib/util.php +++ b/lib/util.php @@ -536,7 +536,7 @@ function common_linkify($url) { throw new ServerException("Can't linkify url '$url'"); } - $attrs = array('href' => $canon, 'rel' => 'external'); + $attrs = array('href' => $longurl, 'rel' => 'external'); $is_attachment = false; $attachment_id = null; From f3c8fcccc1c90b6741a15963f3c6429a906bc97c Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Tue, 22 Sep 2009 11:12:55 -0400 Subject: [PATCH 12/13] Link hrefs are the short url, and title is the long url --- lib/util.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/util.php b/lib/util.php index 018b7cad51..bd15a56220 100644 --- a/lib/util.php +++ b/lib/util.php @@ -536,7 +536,7 @@ function common_linkify($url) { throw new ServerException("Can't linkify url '$url'"); } - $attrs = array('href' => $longurl, 'rel' => 'external'); + $attrs = array('href' => $canon, 'title' => $longurl, 'rel' => 'external'); $is_attachment = false; $attachment_id = null; From 2cabfba767ba0d92d34a6ea4e4cf91c7325f3e95 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Tue, 22 Sep 2009 19:34:10 -0400 Subject: [PATCH 13/13] Allow some punctuation instead of just spaces before @user, !group, and #tag --- lib/util.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/util.php b/lib/util.php index bd15a56220..441dcf68e3 100644 --- a/lib/util.php +++ b/lib/util.php @@ -391,10 +391,10 @@ 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('/(^|[\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_at_hash_link($id, '\\2')", $r); - $r = preg_replace('/(^|\s)!([A-Za-z0-9]{1,64})/e', "'\\1!'.common_group_link($id, '\\2')", $r); + $r = preg_replace('/(^|[\s\.\,\:\;]+)@#([A-Za-z0-9]{1,64})/e', "'\\1@#'.common_at_hash_link($id, '\\2')", $r); + $r = preg_replace('/(^|[\s\.\,\:\;]+)!([A-Za-z0-9]{1,64})/e', "'\\1!'.common_group_link($id, '\\2')", $r); return $r; }