X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FUtil%2FStrings.php;h=2405fbababcfdbcd8d6788f4ed28040c6b954c4f;hb=359ad6ff5ab4c178591af01e35b5f8bb40380b84;hp=7b8d999d3a6a577572ed73a07d54ec076e7d1999;hpb=ce56cabd9f986c28f48c5af6eb74763453f1aa6c;p=friendica.git diff --git a/src/Util/Strings.php b/src/Util/Strings.php index 7b8d999d3a..2405fbabab 100644 --- a/src/Util/Strings.php +++ b/src/Util/Strings.php @@ -1,6 +1,6 @@ ?«»“”‘’.] # Domain can\'t start with a . - [^/\s\xA0`!()\[\]{};:\'",<>?«»“”‘’]+ # Domain can\'t end with a . + [^/\s\xA0`!()\[\]{};:\'",<>?«»“”‘’.] # Domain can\'t start with a . + [^/\s\xA0`!()\[\]{};:\'",<>?«»“”‘’]+ # Domain can\'t end with a . \. [^/\s\xA0`!()\[\]{};:\'".,<>?«»“”‘’]+/? # Followed by a slash ) - (?: # One or more: - [^\s\xA0()<>]+ # Run of non-space, non-()<> - | # or - \(([^\s\xA0()<>]+|(\([^\s()<>]+\)))*\) # balanced parens, up to 2 levels - | # or - [^\s\xA0`!()\[\]{};:\'".,<>?«»“”‘’] # not a space or one of these punct chars - )* -)@xiu'; + (?: # One or more: + [^\s\xA0()<>]+ # Run of non-space, non-()<> + | # or + \(([^\s\xA0()<>]+|(\([^\s()<>]+\)))*\) # balanced parens, up to 2 levels + | # or + [^\s\xA0`!()\[\]{};:\'".,<>?«»“”‘’] # not a space or one of these punct chars + )*'; } /** @@ -488,7 +499,7 @@ class Strings $blocks = []; - $text = preg_replace_callback($regex, + $return = preg_replace_callback($regex, function ($matches) use ($executionId, &$blocks) { $return = '«block-' . $executionId . '-' . count($blocks) . '»'; @@ -499,7 +510,11 @@ class Strings $text ); - $text = $callback($text) ?? ''; + if (is_null($return)) { + Logger::notice('Received null value from preg_replace_callback', ['text' => $text, 'regex' => $regex, 'blocks' => $blocks, 'executionId' => $executionId, 'callstack' => System::callstack(10)]); + } + + $text = $callback($return ?? $text) ?? ''; // Restore code blocks $text = preg_replace_callback('/«block-' . $executionId . '-([0-9]+)»/iU', @@ -525,16 +540,16 @@ class Strings */ public static function getBytesFromShorthand(string $shorthand): int { - $shorthand = trim($shorthand); + $shorthand = trim($shorthand); - if (is_numeric($shorthand)) + if (is_numeric($shorthand)) { return $shorthand; + } - $last = strtolower($shorthand[strlen($shorthand)-1]); - $shorthand = substr($shorthand, 0, -1); // necessary since PHP 7.1; otherwise optional + $last = strtolower($shorthand[strlen($shorthand)-1]); + $shorthand = substr($shorthand, 0, -1); switch($last) { - // The 'G' modifier is available since PHP 5.1.0 case 'g': $shorthand *= 1024; case 'm':