[
https://issues.apache.org/jira/browse/WW-5021?focusedWorklogId=532600&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-532600
]
ASF GitHub Bot logged work on WW-5021:
--------------------------------------
Author: ASF GitHub Bot
Created on: 07/Jan/21 16:28
Start Date: 07/Jan/21 16:28
Worklog Time Spent: 10m
Work Description: JCgH4164838Gh792C124B5 commented on a change in pull
request #462:
URL: https://github.com/apache/struts/pull/462#discussion_r553431390
##########
File path:
core/src/main/java/org/apache/struts2/dispatcher/StaticContentLoader.java
##########
@@ -57,4 +67,32 @@
*/
void findStaticResource(String path, HttpServletRequest request,
HttpServletResponse response) throws IOException;
+ class Validator {
+
+ private static final Logger LOG =
LogManager.getLogger(DefaultStaticContentLoader.class);
+
+ public static String validateStaticContentPath(String
uiStaticContentPath) {
+ if (StringUtils.isBlank(uiStaticContentPath)) {
+ LOG.warn("\"{}\" has been set to \"{}\", falling back into
default value \"{}\"",
+ StrutsConstants.STRUTS_UI_STATIC_CONTENT_PATH,
+ uiStaticContentPath,
+ StaticContentLoader.DEFAULT_STATIC_CONTENT_PATH);
+ return StaticContentLoader.DEFAULT_STATIC_CONTENT_PATH;
+ } else if ("/".equals(uiStaticContentPath)) {
+ LOG.warn("\"{}\" cannot be set to \"{}\", falling back into
default value \"{}\"",
+ StrutsConstants.STRUTS_UI_STATIC_CONTENT_PATH,
+ uiStaticContentPath,
+ StaticContentLoader.DEFAULT_STATIC_CONTENT_PATH);
+ return StaticContentLoader.DEFAULT_STATIC_CONTENT_PATH;
+ } else if(!uiStaticContentPath.startsWith("/")) {
Review comment:
Minor spacing item: "} else if(" could be "} else if ("
##########
File path:
core/src/main/java/org/apache/struts2/dispatcher/StaticContentLoader.java
##########
@@ -57,4 +67,32 @@
*/
void findStaticResource(String path, HttpServletRequest request,
HttpServletResponse response) throws IOException;
+ class Validator {
+
+ private static final Logger LOG =
LogManager.getLogger(DefaultStaticContentLoader.class);
+
+ public static String validateStaticContentPath(String
uiStaticContentPath) {
+ if (StringUtils.isBlank(uiStaticContentPath)) {
+ LOG.warn("\"{}\" has been set to \"{}\", falling back into
default value \"{}\"",
+ StrutsConstants.STRUTS_UI_STATIC_CONTENT_PATH,
+ uiStaticContentPath,
+ StaticContentLoader.DEFAULT_STATIC_CONTENT_PATH);
+ return StaticContentLoader.DEFAULT_STATIC_CONTENT_PATH;
+ } else if ("/".equals(uiStaticContentPath)) {
+ LOG.warn("\"{}\" cannot be set to \"{}\", falling back into
default value \"{}\"",
+ StrutsConstants.STRUTS_UI_STATIC_CONTENT_PATH,
+ uiStaticContentPath,
+ StaticContentLoader.DEFAULT_STATIC_CONTENT_PATH);
+ return StaticContentLoader.DEFAULT_STATIC_CONTENT_PATH;
+ } else if(!uiStaticContentPath.startsWith("/")) {
+ LOG.warn("\"{}\" must start with \"/\", but has been set to
\"{}\", prepending the missing \"/\"!",
+ StrutsConstants.STRUTS_UI_STATIC_CONTENT_PATH,
+ uiStaticContentPath);
+ return "/" + uiStaticContentPath;
+ } else {
Review comment:
I think there may be one validation condition missing from the checks
(trailing "/"), as it looks like that would break processing as well. Adding a
new clause like this:
```
} else if (uiStaticContentPath.endsWith("/")) {
LOG.warn("\"{}\" must not end with \"/\", but has been set to \"{}\",
removing all trailing \"/\"!",
StrutsConstants.STRUTS_UI_STATIC_CONTENT_PATH,
uiStaticContentPath);
return StringUtils.stripEnd(uiStaticContentPath, "/");
}
```
before the final else might work. What do you think ?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 532600)
Time Spent: 1h 20m (was: 1h 10m)
> Serve static resources from different path
> ------------------------------------------
>
> Key: WW-5021
> URL: https://issues.apache.org/jira/browse/WW-5021
> Project: Struts 2
> Issue Type: Task
> Affects Versions: 2.5.20
> Reporter: k918912
> Assignee: Lukasz Lenart
> Priority: Major
> Fix For: 2.6
>
> Time Spent: 1h 20m
> Remaining Estimate: 0h
>
> Is it somehow possible to serve the static Struts files from a different path?
> Currently domTT.js is loaded via /struts, but in my environment I would like
> to serve it via /test/struts for example. Is there any configuration I'm
> missing or is this currently not possible?
--
This message was sent by Atlassian Jira
(v8.3.4#803005)