[ 
https://issues.apache.org/jira/browse/WW-3655?focusedWorklogId=1047824&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1047824
 ]

ASF GitHub Bot logged work on WW-3655:
--------------------------------------

                Author: ASF GitHub Bot
            Created on: 16/Oct/26 12:09
            Start Date: 16/Oct/26 12:09
    Worklog Time Spent: 10m 
      Work Description: lukaszlenart opened a new pull request, #2037:
URL: https://github.com/apache/struts/pull/2037

   Fixes [WW-3655](https://issues.apache.org/jira/browse/WW-3655)
   
   ## Summary
   
   WW-3655 reported that `FreemarkerResult` built a relative (or empty) 
location from the request URI. A request path could therefore decide which 
template got loaded. [WW-4169](https://issues.apache.org/jira/browse/WW-4169) 
already changed this in 2.3.17: a relative location is now resolved against the 
action namespace.
   
   This PR adds a regression test only. No production code changes.
   
   ## Test
   
   `FreeMarkerResultTest#testEmptyLocationDoesNotLoadRequestUriAsTemplate` 
sends a request to `/com/acme/actions/Action.class/` with an empty result 
location. A recording `StringTemplateLoader` holds a template at that path. The 
test asserts that the loader is never asked for that path and that its content 
is never written to the response.
   
   - With the old request-URI resolution temporarily restored, the test fails: 
the template is loaded and written to the response.
   - On `main`, it passes (`FreeMarkerResultTest` 6/6, 
`FreemarkerResultMockedTest` 8/8).
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)




Issue Time Tracking
-------------------

            Worklog Id:     (was: 1047824)
    Remaining Estimate: 0h
            Time Spent: 10m

> Freemarker result loads request uri as template
> -----------------------------------------------
>
>                 Key: WW-3655
>                 URL: https://issues.apache.org/jira/browse/WW-3655
>             Project: Struts 2
>          Issue Type: Bug
>    Affects Versions: 2.2.3
>            Reporter: Johno Crawford
>            Assignee: Maurizio Cucchiara
>            Priority: Major
>             Fix For: 7.5.0
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> If the template location is either null or an empty string "" 
> FreemarkerResult will take the request uri 
> org.apache.struts2.views.freemarker.FreemarkerResult#doExecute and load it as 
> a template.
> Example url, http://localhost:8080/com/acme/actions/Action.class/ would load 
> /com/acme/actions/Action.class/ as a template and dump the bytecode in the 
> response.
> The "feature" / culprit below seems a little exotic, however someone may be 
> relying on it.. (same actions handling stuff in different directories?)
> {code}
> if (!locationArg.startsWith("/")) {
>             String base = ResourceUtil.getResourceBase(req);
>             locationArg = base + "/" + locationArg;
> }
> {code}
> To mitigate the problem and maintain previous functionality we could throw an 
> exception if the template location is empty, I have created a pull request 
> with my proposed fix https://github.com/apache/struts2/pull/1



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to