Browse Source

! Fields that are regex-validated can't be left empty as per http://www.simplemachines.org/community/index.php?topic=499992.0 (thanks @emanuele45 for the fix)

Signed-off-by: Peter Spicer <[email protected]>
Peter Spicer 10 years ago
parent
commit
04d0730450
2 changed files with 2 additions and 2 deletions
  1. 1 1
      Sources/Profile-Modify.php
  2. 1 1
      Sources/Register.php

+ 1 - 1
Sources/Profile-Modify.php

@@ -1248,7 +1248,7 @@ function makeCustomFieldChanges($memID, $area, $sanitize = true)
 				{
 					$value = (int) $value;
 				}
-				elseif (substr($row['mask'], 0, 5) == 'regex' && preg_match(substr($row['mask'], 5), $value) === 0)
+				elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0)
 					$value = '';
 			}
 		}

+ 1 - 1
Sources/Register.php

@@ -458,7 +458,7 @@ function Register2($verifiedOpenID = false)
 					$custom_field_errors[] = array('custom_field_invalid_email', array($row['field_name']));
 				elseif ($row['mask'] == 'number' && preg_match('~[^\d]~', $value))
 					$custom_field_errors[] = array('custom_field_not_number', array($row['field_name']));
-				elseif (substr($row['mask'], 0, 5) == 'regex' && preg_match(substr($row['mask'], 5), $value) === 0)
+				elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) != '' && preg_match(substr($row['mask'], 5), $value) === 0)
 					$custom_field_errors[] = array('custom_field_inproper_format', array($row['field_name']));
 			}
 		}