[
https://issues.apache.org/jira/browse/WW-4843?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16138992#comment-16138992
]
ASF GitHub Bot commented on WW-4843:
------------------------------------
GitHub user aleksandr-m opened a pull request:
https://github.com/apache/struts/pull/163
WW-4843 DefaultUrlHelper().buildUrl() not outputting port when used as
parameter
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/aleksandr-m/struts feature/WW-4843
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/struts/pull/163.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #163
----
commit 0b9e68ed16341c585d48d301ceacfb9e74438552
Author: Aleksandr Mashchenko <[email protected]>
Date: 2017-08-23T20:05:29Z
WW-4843 DefaultUrlHelper().buildUrl() not outputting port when used as
parameter
----
> DefaultUrlHelper().buildUrl() not outputting port when used as parameter
> ------------------------------------------------------------------------
>
> Key: WW-4843
> URL: https://issues.apache.org/jira/browse/WW-4843
> Project: Struts 2
> Issue Type: Bug
> Components: Core
> Affects Versions: 2.3.33
> Reporter: k918912
> Fix For: 2.3.x, 2.5.x
>
>
> This is related to WW-1950.
> If you use the method DefaultUrlHelper().buildUrl() and set
> forceAddSchemeHostAndPort to true Struts2 does not always add the port. This
> is a problem if you intend to use the output as a parameter.
> Example code:
> {code:java}
> Map<String, Object> parameters = new HashMap<String, Object>();
> String backUrlParameters = new DefaultUrlHelper().buildUrl("someurl.html",
> getServletRequest(), getServletResponse(), null, null, true, false, true,
> true);
> parameters.put("backUrl", backUrlParameters);
> String backUrl = new DefaultUrlHelper().buildUrl("someurl2.html",
> getServletRequest(), getServletResponse(), parameters, null, false, false,
> false, false);
> {code}
> The resulting parameter appended to backUrl does not have the port, even with
> setting forceAddSchemeHostAndPort to true.
> Resulting URL:
> http://localhost:8080/someurl2.html?backUrl=http%3A%2F%2Flocalhost%2Fsomeurl.html
> My current workaround is to use:
> {code:java}
> String backUrlParameters = new DefaultUrlHelper().buildUrl("someurl.html",
> getServletRequest(), getServletResponse(), null,
> getServletRequest().getScheme(), true, false, true, true);
> {code}
> This gives Struts2 the same scheme that is currently used but makes it think
> that there could be a change. Result is that the port in the parameter URL is
> appended.
> My environment is Struts2 2.3.33 but I didn't see a code change in that area
> between 2.3 and 2.5, nonetheless I only selected the version I actually
> tested this on.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)