roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ghu...@apache.org
Subject svn commit: r1605684 - /roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/CommentServlet.java
Date Thu, 26 Jun 2014 07:47:22 GMT
Author: ghuber
Date: Thu Jun 26 07:47:22 2014
New Revision: 1605684

URL: http://svn.apache.org/r1605684
Log:
Additional fix for ROL-2002.  Allow url with no protocol, which will be updated accordingly.

Modified:
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/CommentServlet.java

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/CommentServlet.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/CommentServlet.java?rev=1605684&r1=1605683&r2=1605684&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/CommentServlet.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/CommentServlet.java
Thu Jun 26 07:47:22 2014
@@ -241,7 +241,23 @@ public class CommentServlet extends Http
         WeblogEntryComment comment = new WeblogEntryComment();
         comment.setName(commentRequest.getName());
         comment.setEmail(commentRequest.getEmail());
-        comment.setUrl(commentRequest.getUrl());
+        
+        // Validate url
+        if (StringUtils.isNotEmpty(commentRequest.getUrl())) {
+            String theUrl = commentRequest.getUrl().trim().toLowerCase();
+            StringBuilder url = new StringBuilder();
+            if (theUrl.startsWith("http://")) {
+                url.append(theUrl);
+            } else if (theUrl.startsWith("https://")) {
+                url.append(theUrl);
+            } else {
+                url.append("http://").append(commentRequest.getUrl());
+            }
+            comment.setUrl(url.toString());
+        } else {
+            comment.setUrl("");
+        }
+        
         comment.setContent(commentRequest.getContent());
         comment.setNotify(commentRequest.isNotify());
         comment.setWeblogEntry(entry);
@@ -283,11 +299,11 @@ public class CommentServlet extends Http
             log.debug("Email Adddress is invalid : "
                     + commentRequest.getEmail());
             // if there is an URL it must be valid
-        } else if (StringUtils.isNotEmpty(commentRequest.getUrl())
+        } else if (StringUtils.isNotEmpty(comment.getUrl())
                 && !new UrlValidator(new String[] { "http", "https" })
-                        .isValid(commentRequest.getUrl())) {
+                        .isValid(comment.getUrl())) {
                 error = messageUtils.getString("error.commentPostFailedURL");
-                log.debug("URL is invalid : " + commentRequest.getUrl());
+                log.debug("URL is invalid : " + comment.getUrl());
             // if this is a real comment post then authenticate request
         } else if (!preview && !this.authenticator.authenticate(request)) {
             String[] msg = { request.getParameter("answer") };



Mime
View raw message