Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(event_handler): make invalid chars a raw str to fix invalid escape sequence #2982

Merged
merged 2 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion aws_lambda_powertools/event_handler/api_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
_DYNAMIC_ROUTE_PATTERN = r"(<\w+>)"
_SAFE_URI = "-._~()'!*:@,;=" # https://www.ietf.org/rfc/rfc3986.txt
# API GW/ALB decode non-safe URI chars; we must support them too
_UNSAFE_URI = "%<> \[\]{}|^" # noqa: W605
_UNSAFE_URI = r"%<> \[\]{}|^"
_NAMED_GROUP_BOUNDARY_PATTERN = rf"(?P\1[{_SAFE_URI}{_UNSAFE_URI}\\w]+)"
_ROUTE_REGEX = "^{}$"

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/data_classes/test_api_gateway_authorizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_authorizer_response_invalid_verb(builder: APIGatewayAuthorizerResponse)


def test_authorizer_response_invalid_resource(builder: APIGatewayAuthorizerResponse):
with pytest.raises(ValueError, match="Invalid resource path: \$."): # noqa: W605
with pytest.raises(ValueError, match=r"Invalid resource path: \$."):
# GIVEN an invalid resource path "$"
# WHEN calling deny_method
builder.deny_route(http_method=HttpVerb.GET.value, resource="$")
Expand Down