(request: Request, handler: Handler)
| 75 | |
| 76 | @middleware |
| 77 | async def impl(request: Request, handler: Handler) -> StreamResponse: |
| 78 | if isinstance(request.match_info.route, SystemRoute): |
| 79 | paths_to_check = [] |
| 80 | if "?" in request.raw_path: |
| 81 | path, query = request.raw_path.split("?", 1) |
| 82 | query = "?" + query |
| 83 | else: |
| 84 | query = "" |
| 85 | path = request.raw_path |
| 86 | |
| 87 | if merge_slashes: |
| 88 | paths_to_check.append(re.sub("//+", "/", path)) |
| 89 | if append_slash and not request.path.endswith("/"): |
| 90 | paths_to_check.append(path + "/") |
| 91 | if remove_slash and request.path.endswith("/"): |
| 92 | paths_to_check.append(path[:-1]) |
| 93 | if merge_slashes and append_slash: |
| 94 | paths_to_check.append(re.sub("//+", "/", path + "/")) |
| 95 | if merge_slashes and remove_slash: |
| 96 | merged_slashes = re.sub("//+", "/", path) |
| 97 | paths_to_check.append(merged_slashes[:-1]) |
| 98 | |
| 99 | for path in paths_to_check: |
| 100 | path = re.sub("^//+", "/", path) # SECURITY: GHSA-v6wp-4m6f-gcjg |
| 101 | resolves, request = await _check_request_resolves(request, path) |
| 102 | if resolves: |
| 103 | raise redirect_class(request.raw_path + query) |
| 104 | |
| 105 | return await handler(request) |
| 106 | |
| 107 | return impl |
| 108 |
nothing calls this directly
no test coverage detected
searching dependent graphs…