You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@roller.apache.org by sn...@apache.org on 2018/03/14 21:09:20 UTC

roller git commit: With a multi-host blog setup, use hostname to determine match instead of URL.

Repository: roller
Updated Branches:
  refs/heads/master 7f4ac300d -> c6459e5c7


With a multi-host blog setup, use hostname to determine match instead of URL.

Using the URL is problematic when HTTPS s enabled and originally requesed URL was redirected from http:// to https://


Project: http://git-wip-us.apache.org/repos/asf/roller/repo
Commit: http://git-wip-us.apache.org/repos/asf/roller/commit/c6459e5c
Tree: http://git-wip-us.apache.org/repos/asf/roller/tree/c6459e5c
Diff: http://git-wip-us.apache.org/repos/asf/roller/diff/c6459e5c

Branch: refs/heads/master
Commit: c6459e5c707cf4f4903b2b408a6ac3fb8f6b5adc
Parents: 7f4ac30
Author: Dave Johnson <sn...@gmail.com>
Authored: Wed Mar 14 17:09:16 2018 -0400
Committer: Dave Johnson <sn...@gmail.com>
Committed: Wed Mar 14 17:09:16 2018 -0400

----------------------------------------------------------------------
 .../ui/rendering/WeblogRequestMapper.java       | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/roller/blob/c6459e5c/app/src/main/java/org/apache/roller/weblogger/ui/rendering/WeblogRequestMapper.java
----------------------------------------------------------------------
diff --git a/app/src/main/java/org/apache/roller/weblogger/ui/rendering/WeblogRequestMapper.java b/app/src/main/java/org/apache/roller/weblogger/ui/rendering/WeblogRequestMapper.java
index cf3ec65..ad8c170 100644
--- a/app/src/main/java/org/apache/roller/weblogger/ui/rendering/WeblogRequestMapper.java
+++ b/app/src/main/java/org/apache/roller/weblogger/ui/rendering/WeblogRequestMapper.java
@@ -19,6 +19,7 @@
 package org.apache.roller.weblogger.ui.rendering;
 
 import java.io.IOException;
+import java.net.URL;
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.Set;
@@ -133,12 +134,19 @@ public class WeblogRequestMapper implements RequestMapper {
             return false;
         }
 
-        String weblogAbsoluteURL =
-            WebloggerConfig.getProperty("weblog.absoluteurl." + weblogHandle);
-        // If an absolute URL is specified for this weblog, make sure request URL matches
-        if (weblogAbsoluteURL != null && !request.getRequestURL().toString().startsWith(weblogAbsoluteURL)) {
-            log.debug("SKIPPED " + weblogHandle);
-            return false;
+        // is there a special hostname for the specified hostname?
+        String multiHostNameURL =  WebloggerConfig.getProperty("weblog.absoluteurl." + weblogHandle);
+        if ( multiHostNameURL != null ) {
+
+            // there is, so check that configured hostname matches the one in the request
+            URL weblogAbsoluteURL = new URL( multiHostNameURL );
+            String headerHost = request.getHeader("Host");
+            String configHost = weblogAbsoluteURL.getHost();
+
+            if (headerHost != null && configHost != null && !headerHost.equals(configHost)) {
+                log.debug("SKIPPED " + weblogHandle);
+                return false;
+            }
         }
         
         log.debug("WEBLOG_URL "+request.getServletPath());