Merge branch 'unicode-tag' into 0.9.x

This commit is contained in:
Brion Vibber 2011-02-25 10:17:03 -08:00
commit 0291c6f7cd
3 changed files with 13 additions and 11 deletions

View File

@ -153,7 +153,7 @@ class Notice extends Memcached_DataObject
function saveTags()
{
/* extract all #hastags */
$count = preg_match_all('/(?:^|\s)#([\pL\pN_\-\.]{1,64})/', strtolower($this->content), $match);
$count = preg_match_all('/(?:^|\s)#([\pL\pN_\-\.]{1,64})/u', strtolower($this->content), $match);
if (!$count) {
return true;
}

View File

@ -116,6 +116,8 @@ class Router
static $bare = array('requesttoken', 'accesstoken', 'userauthorization',
'postnotice', 'updateprofile', 'finishremotesubscribe');
const REGEX_TAG = '[^\/]+'; // [\pL\pN_\-\.]{1,64} better if we can do unicode regexes
static function get()
{
if (!Router::$inst) {
@ -348,14 +350,14 @@ class Router
$m->connect('tag', array('action' => 'publictagcloud'));
$m->connect('tag/:tag/rss',
array('action' => 'tagrss'),
array('tag' => '[\pL\pN_\-\.]{1,64}'));
array('tag' => self::REGEX_TAG));
$m->connect('tag/:tag',
array('action' => 'tag'),
array('tag' => '[\pL\pN_\-\.]{1,64}'));
array('tag' => self::REGEX_TAG));
$m->connect('peopletag/:tag',
array('action' => 'peopletag'),
array('tag' => '[a-zA-Z0-9]+'));
array('tag' => self::REGEX_TAG));
// groups
@ -812,7 +814,7 @@ class Router
$m->connect($a.'/:tag',
array('action' => $a,
'nickname' => $nickname),
array('tag' => '[a-zA-Z0-9]+'));
array('tag' => self::REGEX_TAG));
}
foreach (array('rss', 'groups') as $a) {
@ -839,12 +841,12 @@ class Router
$m->connect('tag/:tag/rss',
array('action' => 'userrss',
'nickname' => $nickname),
array('tag' => '[\pL\pN_\-\.]{1,64}'));
array('tag' => self::REGEX_TAG));
$m->connect('tag/:tag',
array('action' => 'showstream',
'nickname' => $nickname),
array('tag' => '[\pL\pN_\-\.]{1,64}'));
array('tag' => self::REGEX_TAG));
$m->connect('rsd.xml',
array('action' => 'rsd',
@ -875,7 +877,7 @@ class Router
foreach (array('subscriptions', 'subscribers') as $a) {
$m->connect(':nickname/'.$a.'/:tag',
array('action' => $a),
array('tag' => '[a-zA-Z0-9]+',
array('tag' => self::REGEX_TAG,
'nickname' => Nickname::DISPLAY_FMT));
}
@ -903,12 +905,12 @@ class Router
$m->connect(':nickname/tag/:tag/rss',
array('action' => 'userrss'),
array('nickname' => Nickname::DISPLAY_FMT),
array('tag' => '[\pL\pN_\-\.]{1,64}'));
array('tag' => self::REGEX_TAG));
$m->connect(':nickname/tag/:tag',
array('action' => 'showstream'),
array('nickname' => Nickname::DISPLAY_FMT),
array('tag' => '[\pL\pN_\-\.]{1,64}'));
array('tag' => self::REGEX_TAG));
$m->connect(':nickname/rsd.xml',
array('action' => 'rsd'),

View File

@ -787,7 +787,7 @@ function common_render_text($text)
$r = preg_replace('/[\x{0}-\x{8}\x{b}-\x{c}\x{e}-\x{19}]/', '', $r);
$r = common_replace_urls_callback($r, 'common_linkify');
$r = preg_replace('/(^|\&quot\;|\'|\(|\[|\{|\s+)#([\pL\pN_\-\.]{1,64})/e', "'\\1#'.common_tag_link('\\2')", $r);
$r = preg_replace('/(^|\&quot\;|\'|\(|\[|\{|\s+)#([\pL\pN_\-\.]{1,64})/ue', "'\\1#'.common_tag_link('\\2')", $r);
// XXX: machine tags
return $r;
}