Repository navigation
Canonicalize interceptor and IP restriction request paths (7.0.x) - #16394
Merged
Merged
Conversation
Backport of #16332 (including #16330) to 7.0.x. Interceptor `uri` matchers and the Spring Security `ipRestrictions` filter now match the path within the application exactly as URL mapping dispatch resolves it with UrlPathHelper: percent escapes decoded once, matrix parameters removed per segment, context path stripped. Previously the raw request URI was matched, so an encoded or matrix-parameter form of a path could be dispatched to a controller without the matcher for the plain path applying. UrlMappingMatcher still accepts patterns that begin with the context path. Interceptors pairing match(uri:) with an exclusion now also run when deployed under a context path. Differences from the 8.0.x change: - The Matcher interface is unchanged. Groovy 4 compiles an interface default method as a trait, which hides Matcher.THROWABLE, so the context-path-aware doesMatch overload lives on UrlMappingMatcher only and custom matchers keep receiving the canonical path through the three-argument method. - The AntPathRequestMatcher compat class does not exist on 7.0.x. - The upgrade note is added to the Grails 6 to 7 upgrade guide.
jdaugherty
approved these changes
Sep 24, 2026
✅ All tests passed ✅🏷️ Commit: 63637eb Learn more about TestLens at testlens.app/docs. |
Contributor
|
This is just a backport, so merging. |
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.
Backport of #16332 (including the #16330 follow-up) to 7.0.x.
Summary
Interceptor
urimatchers and the Spring SecurityipRestrictionsfilter now match the path within the application exactly as URL mapping dispatch resolves it withUrlPathHelper.getPathWithinApplication: percent escapes are decoded once, matrix parameters (;name=value) are removed per segment, and the context path is stripped. Previously the raw request URI was matched, so an encoded (/%61dmin/users) or matrix-parameter (/admin;x=1/users) form of a path could be dispatched to a controller without the matcher for the plain path applying.UrlMappingMatcherstill accepts patterns that begin with the context path. Interceptors pairingmatch(uri:)with an exclusion now also run when the application is deployed under a context path.Differences from the 8.0.x change
grails.interceptors.Matcheris unchanged. Groovy 4 compiles an interface default method as a trait, which hidesMatcher.THROWABLEfromInterceptorandGrailsInterceptorHandlerInterceptorAdapter. The context-path-awaredoesMatch(uri, info, method, contextPath)overload is therefore onUrlMappingMatcheronly, and custom matchers keep receiving the canonical path through the three-argumentdoesMatch. The spec that exercised the interface default method was dropped.AntPathRequestMatchercompat class and its build/test wiring do not exist on 7.0.x and are not included.Testing
:grails-interceptors:test:grails-spring-security:test:grails-interceptors:codeStyle,:grails-spring-security:codeStyle