From bbc4c629b25855410c1e929cc8b09f145a30c456 Mon Sep 17 00:00:00 2001 From: "Amir E. Aharoni" Date: Wed, 1 Aug 2012 21:47:16 +0300 Subject: [PATCH] (Bug 30599) Filter problematic prefix characters Change-Id: Icf0058407c51a314583907a54257cb10fa4826e5 --- Interwiki_body.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Interwiki_body.php b/Interwiki_body.php index c0b07715..7f9c6e2b 100644 --- a/Interwiki_body.php +++ b/Interwiki_body.php @@ -189,8 +189,12 @@ class SpecialInterwiki extends SpecialPage { $prefix = $request->getVal( 'wpInterwikiPrefix' ); $do = $request->getVal( 'wpInterwikiAction' ); // Show an error if the prefix is invalid (only when adding one). - // Invalid characters are ':', '&', '=' and whitespace. - if ( preg_match( '/[\s:&=]/', $prefix ) && $do === 'add' ) { + // Invalid characters for a title should also be invalid for a prefix. + // Whitespace, ':', '&' and '=' are invalid, too. + // (Bug 30599). + global $wgLegalTitleChars; + $validPrefixChars = preg_replace( '/[ :&=]/', '', $wgLegalTitleChars ); + if ( preg_match( "/\s|[^$validPrefixChars]/", $prefix ) && $do === 'add' ) { $this->error( 'interwiki-badprefix', htmlspecialchars( $prefix ) ); $this->showForm( $do ); return;