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

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 UTC