X-Git-Url: http://git.cyclocoop.org/%28?a=blobdiff_plain;f=includes%2FWebRequest.php;h=bbaa10fea30cd53e6348528c7e1e787a18c54039;hb=f9bb20657c6776a7543fbf33ead1c1e6fbad33de;hp=6593e49d8a219aa7d3250617778ed836f75b416c;hpb=1e8a3eff9fbc99841e1b294abbc4184db9c44083;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/WebRequest.php b/includes/WebRequest.php index 6593e49d8a..bbaa10fea3 100644 --- a/includes/WebRequest.php +++ b/includes/WebRequest.php @@ -39,7 +39,10 @@ use MediaWiki\Session\SessionManager; * @ingroup HTTP */ class WebRequest { - protected $data, $headers = []; + /** @var array */ + protected $data; + /** @var array */ + protected $headers = []; /** * Flag to make WebRequest::getHeader return an array of values. @@ -395,18 +398,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; } /**