From fd6e9ef2d481209b01fa6e1bb1c863b8257f0272 Mon Sep 17 00:00:00 2001 From: Max Semenik Date: Thu, 29 Jun 2017 17:13:12 -0700 Subject: Human-readable section ID support It adds the ability to replace the current section ID escaping schema (.C0.DE) with a HTML5-compliant escaping schema that is displayed as Unicode in many modern browsers. See the linked bug for discussion of various options that were considered before the implementation. A few remarks: * Because Sanitizer::escapeId() is used in a bunch of places without escaping, I'm deprecating it without altering its behavior. * The bug described in comments for Parser::guessLegacySectionNameFromWikiText() is still there in some Edge versions that display mojibake. Bug: T152540 Change-Id: Id304010a0342efbb7ef2d56c5b8b244f2e4fb2c5 --- includes/htmlform/HTMLFormField.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'includes/htmlform/HTMLFormField.php') diff --git a/includes/htmlform/HTMLFormField.php b/includes/htmlform/HTMLFormField.php index 7cb83e21cd75..77ddc1a1b5ec 100644 --- a/includes/htmlform/HTMLFormField.php +++ b/includes/htmlform/HTMLFormField.php @@ -416,8 +416,8 @@ abstract class HTMLFormField { $this->mDir = $params['dir']; } - $validName = Sanitizer::escapeId( $this->mName ); - $validName = str_replace( [ '.5B', '.5D' ], [ '[', ']' ], $validName ); + $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__ ); } @@ -430,7 +430,7 @@ abstract class HTMLFormField { if ( isset( $params['id'] ) ) { $id = $params['id']; - $validId = Sanitizer::escapeId( $id ); + $validId = urlencode( $id ); if ( $id != $validId ) { throw new MWException( "Invalid id '$id' passed to " . __METHOD__ ); -- cgit v1.2.3