htmlform: Remove HTMLFormField restrictions on 'name' and 'id'

The restrictions were introduced in r53480 (724411c7ca, 2009),
which makes it clear that this was just about HTML correctness,
and in HTML5 there are fewer requirements.

This code was last touched in commit fd6e9ef2d4 (2017), where it was
suggested in code review that it "can probably be removed":
https://gerrit.wikimedia.org/r/c/mediawiki/core/+/362326/comment/6e71af52_900abad4/

Bug: T126962
Change-Id: I54c1f28ec9112cd4a161a79e76c2224f91f134b9
This commit is contained in:
Bartosz Dziewoński 2021-10-07 23:42:58 +02:00 committed by Krinkle
parent 58652c0e3d
commit 2990c003e3

View file

@ -434,12 +434,6 @@ abstract class HTMLFormField {
$this->mDir = $params['dir'];
}
$validName = urlencode( $this->mName );
$validName = str_replace( [ '%5B', '%5D' ], [ '[', ']' ], $validName );
if ( $this->mName != $validName && !isset( $params['nodata'] ) ) {
throw new MWException( "Invalid name '{$this->mName}' passed to " . __METHOD__ );
}
$this->mID = "mw-input-{$this->mName}";
if ( isset( $params['default'] ) ) {
@ -447,14 +441,7 @@ abstract class HTMLFormField {
}
if ( isset( $params['id'] ) ) {
$id = $params['id'];
$validId = urlencode( $id );
if ( $id != $validId ) {
throw new MWException( "Invalid id '$id' passed to " . __METHOD__ );
}
$this->mID = $id;
$this->mID = $params['id'];
}
if ( isset( $params['cssclass'] ) ) {