2
0
Эх сурвалжийг харах

Merge pull request #991 from Arantor/release-2.1

! Fields that are regex-validated can't be left empty as per http://www....
Arantor 11 жил өмнө
parent
commit
7bec1140d1

+ 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']));
 			}
 		}