aboutsummaryrefslogtreecommitdiffstats
path: root/include/text.php
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-04-05 19:08:43 -0700
committerzotlabs <mike@macgirvin.com>2017-04-05 19:08:43 -0700
commit9fb08fb5022c9eaf6368a9d3ac07bb1dcf856c20 (patch)
treec83aec69b20bcee45b022dd343faa1155835a5c1 /include/text.php
parent6710a77c26b9f5d621ad839cadeefb08fa066aa2 (diff)
downloadvolse-hubzilla-9fb08fb5022c9eaf6368a9d3ac07bb1dcf856c20.tar.gz
volse-hubzilla-9fb08fb5022c9eaf6368a9d3ac07bb1dcf856c20.tar.bz2
volse-hubzilla-9fb08fb5022c9eaf6368a9d3ac07bb1dcf856c20.zip
make legal_webbie() pluggable - * this should not be merged with federated projects unless the federation drivers make use of the hooks.
Diffstat (limited to 'include/text.php')
-rw-r--r--include/text.php38
1 files changed, 21 insertions, 17 deletions
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) {