Class StaticThemeResponder
This component is invoked by StaticThemeFilter, which resolves the active theme
for the current virtual host and decides — based on the request URI — whether to serve the
SPA entry HTML (serveIndex(jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.HttpServletResponse, org.codelibs.fess.theme.Theme, java.lang.String)) or a theme-relative static asset (serveAsset(jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.HttpServletResponse, org.codelibs.fess.theme.Theme, java.lang.String)).
The filter writes the response in place (no RequestDispatcher forward), so the
browser address bar keeps the original request URI.
Security: resolveAsset(Theme, String) enforces path-traversal protection by
rejecting absolute paths and any path containing "..", re-checking the canonicalized
result is still under the theme base directory, rejecting symlinks, and applying a filename
denylist (see isBlockedFilename(String)). The entry file is subjected to the same
filename denylist so a malicious manifest entry cannot serve internal files (e.g.
theme.yml or .env) as HTML.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidserveAsset(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res, Theme theme, String assetPath) Streams a static asset from the given theme's base directory after validating the path.voidserveIndex(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res, Theme theme, String requestPath) Streams the entry HTML file of the given theme withno-cachesemantics.
-
Constructor Details
-
StaticThemeResponder
public StaticThemeResponder()Default constructor.
-
-
Method Details
-
serveIndex
public void serveIndex(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res, Theme theme, String requestPath) throws IOException Streams the entry HTML file of the given theme withno-cachesemantics.When
requestPathstarts with/error, the response also carries:X-Fess-Route: error— signals to the SPA that this is an error route.X-Fess-Error-Code: <status>— the HTTP status code derived from the URI (e.g.404for/error/notFound).<meta name="x-fess-error-code" content="<status>">— the same status code injected as a meta tag into the HTML<head>so client-side JS can read it directly without relying on the HTTP header.<meta name="x-fess-error-detail-key" content="...">— when a safemessage_keyquery parameter is present.
- Parameters:
req- the current request (used to read themessage_keyparameter)res- the response to write totheme- the active theme whose entry file is servedrequestPath- the context-path-stripped request path (used for/errordetection)- Throws:
IOException- if writing the response fails
-
serveAsset
public void serveAsset(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res, Theme theme, String assetPath) throws IOException Streams a static asset from the given theme's base directory after validating the path.- Parameters:
req- the current request (used for conditional-GET headers)res- the response to write totheme- the active theme whose base directory anchors the resolutionassetPath- theme-relative asset path supplied by the filter- Throws:
IOException- if writing the response fails
-