From 9fb08fb5022c9eaf6368a9d3ac07bb1dcf856c20 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 5 Apr 2017 19:08:43 -0700 Subject: make legal_webbie() pluggable - * this should not be merged with federated projects unless the federation drivers make use of the hooks. --- include/text.php | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) (limited to 'include/text.php') diff --git a/include/text.php b/include/text.php index e02becf31..bbf0b5b98 100644 --- a/include/text.php +++ b/include/text.php @@ -2000,30 +2000,34 @@ function legal_webbie($s) { if(! strlen($s)) return ''; + // WARNING: This regex will not work in a federated environment. + // You will probably want something like + // preg_replace('/([^a-z0-9\_])/','',strtolower($s)); - // Has to start with a lowercase alphabetic character - not a number. - // This is so we can differentiate between something like channel=123 - // and channel=foo and lookup the first by numeric id and the second - // by nickname. + $r = preg_replace('/([^a-z0-9\-\_\.])/','',strtolower($s)); - $x = $s; - do { - $s = $x; - $x = preg_replace('/^([^a-z])(.*?)/',"$2",$s); - } while($x != $s); + $x = [ 'input' => $s, 'output' => $r ]; + call_hooks('legal_webbie',$x); + return $x['output']; - // Use the lowest common denominator rules (letters, numbers, and underscore) - // if the site configuration allows federation with other networks +} + +function legal_webbie_text() { + + // WARNING: This will not work in a federated environment. + + $s = t('a-z, 0-9, -, _, and . only'); + + $x = [ 'text' => $s ]; + call_hooks('legal_webbie_text',$x); + return $x['text']; - if(Zlib\System::get_server_role() === 'pro') { - return preg_replace('/([^a-z0-9\-\_\.])/','',$x); - } - else { - return preg_replace('/([^a-z0-9\_])/','',$x); - } } + + + function check_webbie($arr) { -- cgit v1.2.3