W3C home > Mailing lists > Public > www-validator-cvs@w3.org > October 2009

2006/unicorn/src/org/w3c/unicorn/action LanguageAction.java,1.17,1.18

From: Thomas Gambet via cvs-syncmail <cvsmail@w3.org>
Date: Tue, 13 Oct 2009 12:57:48 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1Mxgwm-00088k-Lp@lionel-hutz.w3.org>
Update of /sources/public/2006/unicorn/src/org/w3c/unicorn/action
In directory hutz:/tmp/cvs-serv31274/src/org/w3c/unicorn/action

Modified Files:
	LanguageAction.java 
Log Message:
check the translator email address syntax

Index: LanguageAction.java
===================================================================
RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/action/LanguageAction.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- LanguageAction.java	13 Oct 2009 12:08:36 -0000	1.17
+++ LanguageAction.java	13 Oct 2009 12:57:46 -0000	1.18
@@ -16,6 +16,8 @@
 import java.util.Properties;
 import java.util.TreeMap;
 
+import javax.mail.internet.AddressException;
+import javax.mail.internet.InternetAddress;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -209,6 +211,18 @@
 				return;
 			}
 			
+			try {
+				InternetAddress ia = new InternetAddress(req.getParameter("translator_mail"));
+				ia.validate();
+			} catch (AddressException e) {
+				MessageList messages = new MessageList();
+				messages.add(new Message(Message.WARNING, "The email address you entered is invalid."));
+				req.setAttribute("messages", messages);
+				req.setAttribute("submitted_props", langProps);
+				doGet(req, resp);
+				return;
+			}
+			
 			contextObjects.put("translator_name", req.getParameter("translator_name"));
 			contextObjects.put("translator_mail", req.getParameter("translator_mail"));
 			contextObjects.put("translator_comments", req.getParameter("translator_comments"));
Received on Tuesday, 13 October 2009 12:57:52 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 26 April 2012 12:55:15 GMT