You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2012/11/03 00:45:15 UTC
[1/2] git commit: TAP5-1933: Change the regular expression used for
email validation Change the validation message to not display the value (as
this will not be correct for client-side validation)
Updated Branches:
refs/heads/5.4-js-rewrite 1778660c6 -> 0e2369ba0
TAP5-1933: Change the regular expression used for email validation
Change the validation message to not display the value (as this will not be correct for client-side validation)
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/0e2369ba
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/0e2369ba
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/0e2369ba
Branch: refs/heads/5.4-js-rewrite
Commit: 0e2369ba06c08ba71180c58460ed9c13735b0593
Parents: 5c10418
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Fri Nov 2 16:44:58 2012 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Fri Nov 2 16:44:58 2012 -0700
----------------------------------------------------------------------
.../java/org/apache/tapestry5/validator/Email.java | 17 ++------------
.../resources/org/apache/tapestry5/core.properties | 2 +-
2 files changed, 4 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/0e2369ba/tapestry-core/src/main/java/org/apache/tapestry5/validator/Email.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/validator/Email.java b/tapestry-core/src/main/java/org/apache/tapestry5/validator/Email.java
index 7c7e7fc..ef5cc01 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/validator/Email.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/validator/Email.java
@@ -30,14 +30,8 @@ import java.util.regex.Pattern;
*/
public class Email extends AbstractValidator<Void, String>
{
- private static final String ATOM = "[^\\x00-\\x1F^\\(^\\)^\\<^\\>^\\@^\\,^\\;^\\:^\\\\^\\\"^\\.^\\[^\\]^\\s]";
-
- private static final String DOMAIN = "(" + ATOM + "+(\\." + ATOM + "+)*";
-
- private static final String IP_DOMAIN = "\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\]";
-
private static final Pattern PATTERN = Pattern
- .compile("^" + ATOM + "+(\\." + ATOM + "+)*@" + DOMAIN + "|" + IP_DOMAIN + ")$", Pattern.CASE_INSENSITIVE);
+ .compile("[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", Pattern.CASE_INSENSITIVE);
public Email(JavaScriptSupport javaScriptSupport)
{
@@ -53,18 +47,13 @@ public class Email extends AbstractValidator<Void, String>
writer.getElement().attributes("data-validation", "true",
"data-validate-regexp", PATTERN.pattern(),
- "data-regexp-message", buildMessage(formatter, field));
+ "data-regexp-message", formatter.toString());
}
}
- private String buildMessage(MessageFormatter formatter, Field field)
- {
- return formatter.format(field.getLabel());
- }
-
public void validate(Field field, Void constraintValue, MessageFormatter formatter, String value)
throws ValidationException
{
- if (!PATTERN.matcher(value).matches()) throw new ValidationException(buildMessage(formatter, field));
+ if (!PATTERN.matcher(value).matches()) throw new ValidationException(formatter.toString());
}
}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/0e2369ba/tapestry-core/src/main/resources/org/apache/tapestry5/core.properties
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/resources/org/apache/tapestry5/core.properties b/tapestry-core/src/main/resources/org/apache/tapestry5/core.properties
index 4ffa2fe..558ed8f 100644
--- a/tapestry-core/src/main/resources/org/apache/tapestry5/core.properties
+++ b/tapestry-core/src/main/resources/org/apache/tapestry5/core.properties
@@ -38,7 +38,7 @@ core-progressive-display-loading=Loading ...
core-sortable=[Sortable]
core-submit-label=Create/Update
integer-format-exception=You must provide an integer value for %s.
-invalid-email='%s' is not a valid email address.
+invalid-email=Not a valid email address.
max-integer=%2$s requires a value no larger than %1$d.
maximum-string-length=You may provide at most %d characters for %s.
min-integer=%2$s requires a value of at least %1$d.