X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FUtil%2FACLFormatter.php;h=4d7be6165cffb4c9d8258d4d17a2d765bd761c74;hb=3bca4fe2a64671d09e08346456cdfa6c12f996e9;hp=7719daf456bcfe42c93a21bb7d508b117b27000f;hpb=e80d68ba53776bed047d897f52db7e25b35a479d;p=friendica.git diff --git a/src/Util/ACLFormatter.php b/src/Util/ACLFormatter.php index 7719daf456..4d7be6165c 100644 --- a/src/Util/ACLFormatter.php +++ b/src/Util/ACLFormatter.php @@ -1,6 +1,6 @@ no ACL set) - if (!isset($acl_string)) { + if (empty($acl_string)) { return []; } // turn string array of angle-bracketed elements into numeric array // e.g. "<1><2><3>" => array(1,2,3); - preg_match_all('/<(' . Group::FOLLOWERS . '|'. Group::MUTUALS . '|[0-9]+)>/', $acl_string, $matches, PREG_PATTERN_ORDER); + preg_match_all('/<(' . Circle::FOLLOWERS . '|'. Circle::MUTUALS . '|[0-9]+)>/', $acl_string, $matches, PREG_PATTERN_ORDER); return $matches[1]; } @@ -55,7 +55,7 @@ final class ACLFormatter * @param string|null $acl_string * @return string */ - public function sanitize(string $acl_string = null) + public function sanitize(string $acl_string = null): string { if (empty($acl_string)) { return ''; @@ -84,9 +84,9 @@ final class ACLFormatter private function sanitizeItem(string &$item) { // The item is an ACL int value if (intval($item)) { - $item = '<' . intval(Strings::escapeTags(trim($item))) . '>'; + $item = '<' . intval($item) . '>'; // The item is a allowed ACL character - } elseif (in_array($item, [Group::FOLLOWERS, Group::MUTUALS])) { + } elseif (in_array($item, [Circle::FOLLOWERS, Circle::MUTUALS])) { $item = '<' . $item . '>'; // The item is already a ACL string } elseif (preg_match('/<\d+?>/', $item)) { @@ -107,10 +107,13 @@ final class ACLFormatter * * @return string */ - function toString($permissions) { + function toString($permissions): string + { $return = ''; if (is_array($permissions)) { $item = $permissions; + } elseif (empty($permissions)) { + return ''; } else { $item = explode(',', $permissions); }