diff options
author | Brion Vibber <brion@pobox.com> | 2010-12-09 16:43:35 -0800 |
---|---|---|
committer | Brion Vibber <brion@pobox.com> | 2010-12-09 16:43:35 -0800 |
commit | d55f606cf8c7c73397258fdfd492b195b987b707 (patch) | |
tree | 3ff9e0d156dcb5e47b185c7740b1f7b635bad3e2 /lib/nickname.php | |
parent | f947fe5d0ca7d2ee59c1a81cddccac0846394d85 (diff) |
Tweaking nickname format regexes: added one that explicitly allows numbers, to be used in router setup.
Diffstat (limited to 'lib/nickname.php')
-rw-r--r-- | lib/nickname.php | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/lib/nickname.php b/lib/nickname.php index a0c9378cd..562f1e205 100644 --- a/lib/nickname.php +++ b/lib/nickname.php @@ -20,7 +20,25 @@ class Nickname { /** - * Regex fragment for pulling an arbitrarily-formated nickname. + * Regex fragment for pulling a formated nickname *OR* ID number. + * Suitable for router def of 'id' parameters on API actions. + * + * Not guaranteed to be valid after normalization; run the string through + * Nickname::normalize() to get the canonical form, or Nickname::isValid() + * if you just need to check if it's properly formatted. + * + * This, DISPLAY_FMT, and CANONICAL_FMT replace the old NICKNAME_FMT, + * but be aware that these should not be enclosed in []s. + * + * @fixme would prefer to define in reference to the other constants + */ + const INPUT_FMT = '(?:[0-9]+|[0-9a-zA-Z_]{1,64})'; + + /** + * Regex fragment for acceptable user-formatted variant of a nickname. + * This includes some chars such as underscore which will be removed + * from the normalized canonical form, but still must fit within + * field length limits. * * Not guaranteed to be valid after normalization; run the string through * Nickname::normalize() to get the canonical form, or Nickname::isValid() @@ -29,7 +47,7 @@ class Nickname * This and CANONICAL_FMT replace the old NICKNAME_FMT, but be aware * that these should not be enclosed in []s. */ - const DISPLAY_FMT = '[0-9a-zA-Z_]+'; + const DISPLAY_FMT = '[0-9a-zA-Z_]{1,64}'; /** * Regex fragment for checking a canonical nickname. |