Skip to content
Snippets Groups Projects
Commit ab9dd2be authored by Florian Gnaegi - frentix GmbH's avatar Florian Gnaegi - frentix GmbH
Browse files

OO-1003 fix issue with trailing white space when setting email via RESt

parent ad4f788c
No related branches found
No related tags found
No related merge requests found
...@@ -59,9 +59,9 @@ public class EmailProperty extends Generic127CharTextPropertyHandler { ...@@ -59,9 +59,9 @@ public class EmailProperty extends Generic127CharTextPropertyHandler {
@Override @Override
protected void setInternalValue(User user, String mail) { protected void setInternalValue(User user, String mail) {
// save mail addresses always lowercase // save mail addresses always lower case and remove trailing whitespace
if (mail != null) { if (mail != null) {
super.setInternalValue(user, mail.toLowerCase()); super.setInternalValue(user, mail.toLowerCase().trim());
} else { } else {
super.setInternalValue(user, null); super.setInternalValue(user, null);
} }
...@@ -132,6 +132,7 @@ public class EmailProperty extends Generic127CharTextPropertyHandler { ...@@ -132,6 +132,7 @@ public class EmailProperty extends Generic127CharTextPropertyHandler {
String value = textElement.getValue(); String value = textElement.getValue();
if (StringHelper.containsNonWhitespace(value)) { if (StringHelper.containsNonWhitespace(value)) {
value = value.toLowerCase().trim();
// check mail address syntax // check mail address syntax
if (!MailHelper.isValidEmailAddress(value)) { if (!MailHelper.isValidEmailAddress(value)) {
textElement.setErrorKey(i18nFormElementLabelKey() + ".error.valid", null); textElement.setErrorKey(i18nFormElementLabelKey() + ".error.valid", null);
...@@ -159,6 +160,7 @@ public class EmailProperty extends Generic127CharTextPropertyHandler { ...@@ -159,6 +160,7 @@ public class EmailProperty extends Generic127CharTextPropertyHandler {
} }
if (StringHelper.containsNonWhitespace(value)) { if (StringHelper.containsNonWhitespace(value)) {
value = value.toLowerCase().trim();
// check mail address syntax // check mail address syntax
if ( ! MailHelper.isValidEmailAddress(value)) { if ( ! MailHelper.isValidEmailAddress(value)) {
validationError.setErrorKey(i18nFormElementLabelKey() + ".error.valid"); validationError.setErrorKey(i18nFormElementLabelKey() + ".error.valid");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment