From 8b83c68f4c7681eac471d7a87b350a4103df2c27 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Fri, 12 Sep 2008 05:40:55 +0000 Subject: [PATCH] Fixed ConfirmedPasswordField validation for min password length git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@62331 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- forms/ConfirmedPasswordField.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/forms/ConfirmedPasswordField.php b/forms/ConfirmedPasswordField.php index 6370d7dc5..a4192a796 100644 --- a/forms/ConfirmedPasswordField.php +++ b/forms/ConfirmedPasswordField.php @@ -179,16 +179,16 @@ class ConfirmedPasswordField extends FormField { if(($this->minLength || $this->maxLength)) { if($this->minLength && $this->maxLength) { - $limit = "{$this->minLength},{$this->maxLength}"; + $limit = "{{$this->minLength},{$this->maxLength}}"; $errorMsg = sprintf(_t('ConfirmedPasswordField.BETWEEN', 'Passwords must be %s to %s characters long.'), $this->minLength, $this->maxLength); } elseif($this->minLength) { - $limit = "{$this->minLength}"; + $limit = "{{$this->minLength}}.*"; $errorMsg = sprintf(_t('ConfirmedPasswordField.ATLEAST', 'Passwords must be at least %s characters long.'), $this->minLength); } elseif($this->maxLength) { - $limit = "0,{$this->maxLength}"; + $limit = "{0,{$this->maxLength}}"; $errorMsg = sprintf(_t('ConfirmedPasswordField.MAXIMUM', 'Passwords must be at most %s characters long.'), $this->maxLength); } - $limitRegex = '/^.{' . $limit . '}$/'; + $limitRegex = '/^.' . $limit . '$/'; $jsTests .= " if(passEl.value && !passEl.value.match({$limitRegex})) { validationError(confEl, \"{$errorMsg}\", \"error\"); @@ -279,16 +279,16 @@ JS; // lengths if(($this->minLength || $this->maxLength)) { if($this->minLength && $this->maxLength) { - $limit = "{$this->minLength},{$this->maxLength}"; + $limit = "{{$this->minLength},{$this->maxLength}}"; $errorMsg = sprintf(_t('ConfirmedPasswordField.BETWEEN', 'Passwords must be %s to %s characters long.'), $this->minLength, $this->maxLength); } elseif($this->minLength) { - $limit = "{$this->minLength}"; + $limit = "{{$this->minLength}}.*"; $errorMsg = sprintf(_t('ConfirmedPasswordField.ATLEAST', 'Passwords must be at least %s characters long.'), $this->minLength); } elseif($this->maxLength) { - $limit = "0,{$this->maxLength}"; + $limit = "{0,{$this->maxLength}}"; $errorMsg = sprintf(_t('ConfirmedPasswordField.MAXIMUM', 'Passwords must be at most %s characters long.'), $this->maxLength); } - $limitRegex = '/^.{' . $limit . '}$/'; + $limitRegex = '/^.' . $limit . '$/'; if(!empty($value) && !preg_match($limitRegex,$value)) { $validator->validationError('Password', $errorMsg, "validation",