replace router regexes with tags with a fixed chunk that takes any non-/ char. This'll let other code decide what's a valid tag.

This commit is contained in:
Brion Vibber 2011-02-23 16:32:56 -08:00
parent 8eca1b8dac
commit 1be2226019

View File

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