roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Johnson (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (ROL-2075) InitFilter#getAbsoluteUrl() returns wrong URL which got last character removed
Date Sat, 01 Jul 2017 21:39:01 GMT

     [ https://issues.apache.org/jira/browse/ROL-2075?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

David Johnson updated ROL-2075:
-------------------------------
    Fix Version/s: 5.2.0

> InitFilter#getAbsoluteUrl() returns wrong URL which got last character removed
> ------------------------------------------------------------------------------
>
>                 Key: ROL-2075
>                 URL: https://issues.apache.org/jira/browse/ROL-2075
>             Project: Apache Roller
>          Issue Type: Bug
>          Components: User Interface - General
>    Affects Versions: 5.1.2
>         Environment: Tomcat/7.0.54
>            Reporter: Kohei Nozaki
>            Assignee: Roller Unassigned
>            Priority: Minor
>             Fix For: 5.2.0
>
>         Attachments: ROL-2075.patch
>
>
> Roller produces wrong URLs that based on {{InitFilter#getAbsoluteUrl()}} in following
situation:
> * {{site.absoluteurl}} is not set
> * Roller is deployed on "/" (as ROOT.war)
> * The first request after deployment comes as a HTTPS request to GET "/"
> Problematic code:
> {code:java}
> String fullUrl = null;
> if (!request.isSecure()) {
>     fullUrl = request.getRequestURL().toString();
> } else {
>     fullUrl = "http://" + request.getServerName()
>             + request.getContextPath();
> }
> {code}
> In the preceding block,
> * {{request.isSecure()}} returns true
> * {{request.getServerName()}} returns "localhost"
> * {{request.getContextPath()}} returns ""
> So now {{fullUrl}} is {{http://localhost}}. then here comes following block:
> {code:java}
> // if the uri is only "/" then we are basically done
> if ("/".equals(request.getRequestURI())) {
>     if (log.isDebugEnabled()) {
>         log.debug(fullUrl.substring(0, fullUrl.length() - 1));
>     }
>     return fullUrl.substring(0, fullUrl.length() - 1);
> }
> {code}
> {{request.getRequestURI()}} returns {{"/"}}. then following {{fullUrl.substring()}} truncates
the last character, and now URL is {{http://localhos}}.
> DEBUG log (actual URLs are masked by ***):
> {noformat}
> INFO  2015-04-29 00:11:28,357 PreviewServlet:init - Initializing PreviewServlet
> DEBUG 2015-04-29 00:11:38,512 CharEncodingFilter:doFilter - Processing CharEncodingFilter
> DEBUG 2015-04-29 00:11:38,514 CharEncodingFilter:doFilter - Set request character encoding
to UTF-8
> DEBUG 2015-04-29 00:11:38,568 BootstrapFilter:doFilter - Entered /
> DEBUG 2015-04-29 00:11:38,569 WebloggerConfig:getProperty - Fetching property [installation.type=auto]
> DEBUG 2015-04-29 00:11:38,569 PersistenceSessionFilter:doFilter - Entered /
> DEBUG 2015-04-29 00:11:38,569 InitFilter:getAbsoluteUrl - http://***.rhcloud.co
> DEBUG 2015-04-29 00:11:38,569 InitFilter:doFilter - relPath = 
> DEBUG 2015-04-29 00:11:38,570 InitFilter:doFilter - absPath = http://***.rhcloud.co
> DEBUG 2015-04-29 00:11:38,570 RequestMappingFilter:doFilter - entering
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message