Skip to content

Commit 3ad5690

Browse files
committed
updated docstring
1 parent 41fcd6f commit 3ad5690

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

packages/google-api-core/google/api_core/path_template.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ def _extract_and_validate_wildcards(
216216
if template_str is None or template_str == "*":
217217
# Single-segment templates (None or "*") cannot match exactly "." or ".."
218218
# and cannot have multi-segment paths resolving to 0 segments.
219+
#
220+
# Empty strings pose no traversal security risk here.
219221
if val and not _validate_multi_segment_value(val):
220222
raise err
221223
elif template_str == "**":

packages/google-api-core/tests/unit/test_path_template.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -829,6 +829,11 @@ def test_path_traversal_dots_validation_bare_double_star(
829829
("projects/*/locations/**", "projects/([^/]+)/locations/(.+)", ("*", "**")),
830830
("projects/abc", "projects/abc", ()),
831831
("projects/my-project", r"projects/my\-project", ()),
832+
(
833+
r"my-test/{id}/v1.0?abc+def-g|h()\\",
834+
r"my\-test/([^/]+)/v1\.0\?abc\+def\-g\|h\(\)\\\\",
835+
("*",),
836+
),
832837
],
833838
)
834839
def test_build_capture_pattern(template_str, expected_pattern, expected_wildcards):

0 commit comments

Comments
 (0)