Repository navigation
WW-5879 Convention plugin: resolve dot segments and keep view lookups inside the result location - #2193
Open
sohankanna wants to merge 1 commit into
Open
WW-5879 Convention plugin: resolve dot segments and keep view lookups inside the result location#2193sohankanna wants to merge 1 commit into
sohankanna wants to merge 1 commit into
Conversation
…the result location Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes WW-5879
When no result is configured,
ConventionUnknownHandlerbuilds a view path from the result location, the namespace, the action name and the result code. Until now it only collapsed repeated slashes, so.and..in a namespace or action name went straight toServletContext.getResourceand the class loader, with nothing checking that the path stayed under/WEB-INF/content/.Change
resolveDotSegments(path)collapses//and resolves.and... It returnsnullfor a path containing a backslash or one that would climb above its root.resolveInsideResultLocation(path, resultLocation)returns the resolved path only if it is still inside the result location. It compares againstlocation + "/", so/WEB-INF/content-private/does not count as inside/WEB-INF/content.handleUnknownActionnow calls a newfindResource(resultLocation, resultsByExtension, parts...), which skips any candidate that leaves the result location. The existing protectedfindResource(Map, String...)keeps its old behavior for subclasses.findResultcall inhandleUnknownResultgoes throughfindResultInside(...), which resolves the path and checks it the same way. The resolved path is also what ends up in the generated result config.determinePathis split intodetermineResultLocationplus the namespace append, so each lookup asksConventionsServiceonce and checks against the same location. That location honors per-packagestruts.convention.result.path(WW-5770).Namespaces and action names without such segments resolve to exactly the same views as before (all existing tests are unchanged).
Testing
mvn -pl plugins/convention test: 99 run, 0 failures, 0 errors (ConventionUnknownHandlerTest: 16, of which 5 are new).New tests in
ConventionUnknownHandlerTest:testResolveDotSegmentstestResolveInsideResultLocation(including the sibling-prefix case)testUnknownActionWithDotSegmentsInActionNameStaysInsideResultLocationtestUnknownActionWithDotSegmentsInNamespaceStaysInsideResultLocation(/ns/../otherstill finds/WEB-INF/content/other/page.jsp)testUnknownResultWithDotSegmentsStaysInsideResultLocation