X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fhtmlform%2FHTMLFormField.php;h=3f1c590908436935d3113b280cd2eb42df0e8810;hb=ee58c7b17014f3c97408364c073268272c59693f;hp=3a3146bc22c32f3ad736e7e2e365e5f5ad3354f4;hpb=8151aebc686e1aaaa8acea7e087c011915646f18;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/htmlform/HTMLFormField.php b/includes/htmlform/HTMLFormField.php index 3a3146bc22..3f1c590908 100644 --- a/includes/htmlform/HTMLFormField.php +++ b/includes/htmlform/HTMLFormField.php @@ -357,7 +357,7 @@ abstract class HTMLFormField { * (wpFormIdentifier). * * @param WebRequest $request - * @return boolean + * @return bool */ protected function isSubmitAttempt( WebRequest $request ) { return $request->getCheck( 'wpEditToken' ) || $request->getCheck( 'wpFormIdentifier' ); @@ -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__ ); @@ -976,7 +976,7 @@ abstract class HTMLFormField { } /** - * Returns the attributes required for the tooltip and accesskey. + * Returns the attributes required for the tooltip and accesskey, for Html::element() etc. * * @return array Attributes */ @@ -988,6 +988,22 @@ abstract class HTMLFormField { return Linker::tooltipAndAccesskeyAttribs( $this->mParams['tooltip'] ); } + /** + * Returns the attributes required for the tooltip and accesskey, for OOUI widgets' config. + * + * @return array Attributes + */ + public function getTooltipAndAccessKeyOOUI() { + if ( empty( $this->mParams['tooltip'] ) ) { + return []; + } + + return [ + 'title' => Linker::titleAttrib( $this->mParams['tooltip'] ), + 'accessKey' => Linker::accesskey( $this->mParams['tooltip'] ), + ]; + } + /** * Returns the given attributes from the parameters * @@ -1145,6 +1161,9 @@ abstract class HTMLFormField { * @since 1.18 */ protected static function formatErrors( $errors ) { + // Note: If you change the logic in this method, change + // htmlform.Checker.js to match. + if ( is_array( $errors ) && count( $errors ) === 1 ) { $errors = array_shift( $errors ); } @@ -1199,7 +1218,7 @@ abstract class HTMLFormField { * Whether this field requires the user agent to have JavaScript enabled for the client-side HTML5 * form validation to work correctly. * - * @return boolean + * @return bool * @since 1.29 */ public function needsJSForHtml5FormValidation() {