X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FWebRequest.php;h=defe07eaeeda9652c39faff291a32cda1f3beb68;hb=529fc12d2ad2032337594389448fdb5b55802830;hp=6593e49d8a219aa7d3250617778ed836f75b416c;hpb=2e0cf0891444367942677692cf8efde87f19c3ef;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/WebRequest.php b/includes/WebRequest.php index 6593e49d8a..defe07eaee 100644 --- a/includes/WebRequest.php +++ b/includes/WebRequest.php @@ -395,18 +395,25 @@ class WebRequest { # https://www.php.net/variables.external#language.variables.external.dot-in-names # Work around PHP *feature* to avoid *bugs* elsewhere. $name = strtr( $name, '.', '_' ); - if ( isset( $arr[$name] ) ) { - $data = $arr[$name]; + + if ( !isset( $arr[$name] ) ) { + return $default; + } + + $data = $arr[$name]; + # Optimisation: Skip UTF-8 normalization and legacy transcoding for simple ASCII strings. + $isAsciiStr = ( is_string( $data ) && preg_match( '/[^\x20-\x7E]/', $data ) === 0 ); + if ( !$isAsciiStr ) { if ( isset( $_GET[$name] ) && is_string( $data ) ) { # Check for alternate/legacy character encoding. - $contLang = MediaWikiServices::getInstance()->getContentLanguage(); - $data = $contLang->checkTitleEncoding( $data ); + $data = MediaWikiServices::getInstance() + ->getContentLanguage() + ->checkTitleEncoding( $data ); } $data = $this->normalizeUnicode( $data ); - return $data; - } else { - return $default; } + + return $data; } /**