File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -55,11 +55,23 @@ def _validate_path(path: str, append_slash: bool) -> None:
5555 if not path .startswith ("/" ):
5656 raise ValueError ("Path must start with a slash." )
5757
58+ if path .endswith ("/" ) and append_slash :
59+ raise ValueError ("Cannot use append_slash=True when path ends with /" )
60+
61+ if "//" in path :
62+ raise ValueError ("Path cannot contain double slashes." )
63+
5864 if "<>" in path :
5965 raise ValueError ("All URL parameters must be named." )
6066
61- if path .endswith ("/" ) and append_slash :
62- raise ValueError ("Cannot use append_slash=True when path ends with /" )
67+ if re .search (r"[^/]<[^/]+>|<[^/]+>[^/]" , path ):
68+ raise ValueError ("All URL parameters must be between slashes." )
69+
70+ if re .search (r"[^/.]\.\.\.\.?|\.?\.\.\.[^/.]" , path ):
71+ raise ValueError ("... and .... must be between slashes" )
72+
73+ if "....." in path :
74+ raise ValueError ("Path cannot contain more than 4 dots in a row." )
6375
6476 def matches (
6577 self , method : str , path : str
You can’t perform that action at this time.
0 commit comments