Skip to content

[v1.x] fix: reject trailing newline in tool-name validation - #3086

Merged
maxisbey merged 2 commits into
v1.xfrom
fix/tool-name-trailing-newline-v1x
Jul 17, 2026
Merged

[v1.x] fix: reject trailing newline in tool-name validation#3086
maxisbey merged 2 commits into
v1.xfrom
fix/tool-name-trailing-newline-v1x

fix: reject trailing newline in resource template matching

5052de7
Select commit
Loading
Failed to load commit list.
Claude / Claude Code Review completed Jul 16, 2026 in 4m 35s

Code review found 2 potential issues

Found 2 candidates, confirmed 2. See review comments for details.

Details

Severity Count
🔴 Important 0
🟡 Nit 0
🟣 Pre-existing 2
Severity File:Line Issue
🟣 Pre-existing src/mcp/server/fastmcp/resources/templates.py:88-89 Template literal segments not regex-escaped in ResourceTemplate.matches()

Annotations

Check notice on line 89 in src/mcp/server/fastmcp/resources/templates.py

See this annotation in the file changed.

@claude claude / Claude Code Review

Template literal segments not regex-escaped in ResourceTemplate.matches()

Pre-existing issue, not introduced by this PR: the template-to-regex conversion on line 88 never `re.escape()`s the literal (non-parameter) segments, so regex metacharacters in a template are interpreted as regex syntax — e.g. template `test://a.b/{x}` matches `test://aXb/foo` because `.` is a wildcard, and literals containing `(` raise `re.error` at match time. Since this PR already tightens this exact line via `re.fullmatch`, a natural follow-up is to split the template on `{param}` boundaries