| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 4fc8882 commit 1216c53
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -77,7 +77,7 @@ def validate_tool_name(name: str) -> ToolNameValidationResult: | |||
| 77 | 77 | warnings.append("Tool name starts or ends with a dot, which may cause parsing issues in some contexts") | |
| 78 | 78 | ||
| 79 | 79 | # Check for invalid characters | |
| 80 | - if not TOOL_NAME_REGEX.match(name): | ||
| 80 | + if not TOOL_NAME_REGEX.fullmatch(name): | ||
| 81 | 81 | # Find all invalid characters (unique, preserving order) | |
| 82 | 82 | invalid_chars: list[str] = [] | |
| 83 | 83 | seen: set[str] = set() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -813,7 +813,7 @@ def _parse_expression(template: str, body: str, pos: int) -> _Expression: | |||
| 813 | 813 | explode = spec.endswith("*") | |
| 814 | 814 | name = spec[:-1] if explode else spec | |
| 815 | 815 | ||
| 816 | - if not _VARNAME_RE.match(name): | ||
| 816 | + if not _VARNAME_RE.fullmatch(name): | ||
| 817 | 817 | raise InvalidUriTemplate( | |
| 818 | 818 | f"Invalid variable name {name!r} at position {pos}", | |
| 819 | 819 | template=template, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -65,12 +65,17 @@ def test_validate_tool_name_rejects_name_exceeding_max_length() -> None: | |||
| 65 | 65 | ("get,user,profile", "','"), | |
| 66 | 66 | ("user/profile/update", "'/'"), | |
| 67 | 67 | ("user@domain.com", "'@'"), | |
| 68 | + # a single trailing newline slipped past `$` with re.match | ||
| 69 | + ("valid_name\n", "'\\n'"), | ||
| 70 | + ("a" * 127 + "\n", "'\\n'"), | ||
| 68 | 71 | ], | |
| 69 | 72 | ids=[ | |
| 70 | 73 | "with_spaces", | |
| 71 | 74 | "with_commas", | |
| 72 | 75 | "with_slashes", | |
| 73 | 76 | "with_at_symbol", | |
| 77 | + "with_trailing_newline", | ||
| 78 | + "max_length_with_trailing_newline", | ||
| 74 | 79 | ], | |
| 75 | 80 | ) | |
| 76 | 81 | def test_validate_tool_name_rejects_invalid_characters(tool_name: str, expected_char: str) -> None: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -144,6 +144,8 @@ def test_parse_rejects_operator_without_variable(): | |||
| 144 | 144 | # RFC §2.3: dots only between varchars, not consecutive or trailing | |
| 145 | 145 | "foo..bar", | |
| 146 | 146 | "foo.", | |
| 147 | + # a single trailing newline slipped past `$` with re.match | ||
| 148 | + "foo\n", | ||
| 147 | 149 | ], | |
| 148 | 150 | ) | |
| 149 | 151 | def test_parse_rejects_invalid_varname(name: str): | |
| Back | FazBrowse Home | New Git URL |
0 commit comments