From 788526c2d1a4a9e32722c0a26b4a5027f00aa9bb Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Thu, 31 Jul 2014 14:04:00 -0400 Subject: [PATCH] Improve hidden field validation Hidden fields are supposed to be ignored during validation; more completely ensure this by checking in HTMLForm::trySubmit before calling validate. Also, more properly handle HTMLCheckFields in the isHidden check by casting their booleans to strings. Bug: 68132 Change-Id: I84f8239c299727b773015643048eed4684417733 --- includes/htmlform/HTMLForm.php | 3 +++ includes/htmlform/HTMLFormField.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/includes/htmlform/HTMLForm.php b/includes/htmlform/HTMLForm.php index 6cf8d0a7eb..59e577b7ab 100644 --- a/includes/htmlform/HTMLForm.php +++ b/includes/htmlform/HTMLForm.php @@ -467,6 +467,9 @@ class HTMLForm extends ContextSource { if ( !empty( $field->mParams['nodata'] ) ) { continue; } + if ( $field->isHidden( $this->mFieldData ) ) { + continue; + } if ( $field->validate( $this->mFieldData[$fieldname], $this->mFieldData ) diff --git a/includes/htmlform/HTMLFormField.php b/includes/htmlform/HTMLFormField.php index 7e4b15b051..7db5ebcefb 100644 --- a/includes/htmlform/HTMLFormField.php +++ b/includes/htmlform/HTMLFormField.php @@ -113,7 +113,7 @@ abstract class HTMLFormField { } $data = $data[$key]; } - $testValue = $data; + $testValue = (string)$data; break; } -- 2.20.1