From: Max Semenik Date: Mon, 13 Nov 2017 23:48:03 +0000 (-0800) Subject: parser: Replace Sanitizer::armorLinksCallback() with a closure X-Git-Tag: 1.31.0-rc.0~762^2 X-Git-Url: http://git.cyclocoop.org/?a=commitdiff_plain;h=6af4e4a95f927b998ffd2056a86eb58c897a4966;p=lhc%2Fweb%2Fwiklou.git parser: Replace Sanitizer::armorLinksCallback() with a closure Used only once, small enough. Perfect candidate to not be exposed even as a private function. Change-Id: Ic020a596f709cb4f69c48ffe8138f9023a5c4062 --- diff --git a/includes/parser/Sanitizer.php b/includes/parser/Sanitizer.php index 8fee2c77c1..de7a6fa501 100644 --- a/includes/parser/Sanitizer.php +++ b/includes/parser/Sanitizer.php @@ -1171,7 +1171,9 @@ class Sanitizer { # Stupid hack $encValue = preg_replace_callback( '/((?i)' . wfUrlProtocols() . ')/', - [ self::class, 'armorLinksCallback' ], + function ( $matches ) { + return str_replace( ':', ':', $matches[1] ); + }, $encValue ); return $encValue; } @@ -1416,15 +1418,6 @@ class Sanitizer { return $html; } - /** - * Regex replace callback for armoring links against further processing. - * @param array $matches - * @return string - */ - private static function armorLinksCallback( $matches ) { - return str_replace( ':', ':', $matches[1] ); - } - /** * Return an associative array of attribute names and values from * a partial tag string. Attribute names are forced to lowercase,