fix: reject trailing newline in tool-name and URI-template varname validation (#3076)

Python's $ with re.match also matches just before a single trailing newline, so tool-name validation accepted "name\n" and UriTemplate.parse accepted varnames like "foo\n". Switch both checks to re.fullmatch.

Closes #3084
This commit is contained in:
Otis Cui 2026-07-10 20:56:54 +08:00 • committed by GitHub
commit 1216c53693
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -144,6 +144,8 @@ def test_parse_rejects_operator_without_variable():
# RFC §2.3: dots only between varchars, not consecutive or trailing
"foo..bar",
"foo.",
# a single trailing newline slipped past `$` with re.match
"foo\n",
],
)
def test_parse_rejects_invalid_varname(name: str):