Skip to content

Canonicalize interceptor and IP restriction request paths (7.0.x) - #16394

Merged
jdaugherty merged 1 commit into
7.0.xfrom
fix/interceptor-canonical-path-7.0.x
Sep 24, 2026
Merged

jdaugherty merged 1 commit into
7.0.xfrom
fix/interceptor-canonical-path-7.0.x

Conversation

@matrei

@matrei matrei commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Backport of #16332 (including the #16330 follow-up) to 7.0.x.

Summary

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.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.

UrlMappingMatcher still accepts patterns that begin with the context path. Interceptors pairing match(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.Matcher is unchanged. Groovy 4 compiles an interface default method as a trait, which hides Matcher.THROWABLE from Interceptor and GrailsInterceptorHandlerInterceptorAdapter. The context-path-aware doesMatch(uri, info, method, contextPath) overload is therefore on UrlMappingMatcher only, and custom matchers keep receiving the canonical path through the three-argument doesMatch. The spec that exercised the interface default method was dropped.
  • The AntPathRequestMatcher compat class and its build/test wiring do not exist on 7.0.x and are not included.
  • The upgrade note is added as section 18 of the Grails 6 to 7 upgrade guide.

Testing

  • :grails-interceptors:test
  • :grails-spring-security:test
  • :grails-interceptors:codeStyle, :grails-spring-security:codeStyle

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.
@testlens-app

testlens-app Bot commented Sep 24, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: 63637eb
▶️ Tests: 50350 executed
⚪️ Checks: 51/51 completed


Learn more about TestLens at testlens.app/docs.

@jdaugherty

Copy link
Copy Markdown
Contributor

This is just a backport, so merging.

@jdaugherty
jdaugherty merged commit c2dd6e0 into 7.0.x Sep 24, 2026
52 checks passed
@jdaugherty
jdaugherty deleted the fix/interceptor-canonical-path-7.0.x branch September 24, 2026 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants