Skip to content

Commit 8d2e1f4

Browse files
committed
fallback case
1 parent f675161 commit 8d2e1f4

7 files changed

Lines changed: 14 additions & 0 deletions

File tree

modules/openapi-generator/src/main/resources/python/api_client.mustache

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,8 @@ class ApiClient:
725725
)
726726
assert m is not None, "Unexpected 'content-disposition' header value"
727727
filename = os.path.basename(m.group(1)) # Strip any directory traversal
728+
if filename in ("", ".", ".."): # fall back to tmp filename
729+
filename = os.path.basename(path)
728730
path = os.path.join(os.path.dirname(path), filename)
729731

730732
with open(path, "wb") as f:

samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/api_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,8 @@ def __deserialize_file(self, response):
709709
)
710710
assert m is not None, "Unexpected 'content-disposition' header value"
711711
filename = os.path.basename(m.group(1)) # Strip any directory traversal
712+
if filename in ("", ".", ".."): # fall back to tmp filename
713+
filename = os.path.basename(path)
712714
path = os.path.join(os.path.dirname(path), filename)
713715

714716
with open(path, "wb") as f:

samples/client/echo_api/python/openapi_client/api_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,8 @@ def __deserialize_file(self, response):
709709
)
710710
assert m is not None, "Unexpected 'content-disposition' header value"
711711
filename = os.path.basename(m.group(1)) # Strip any directory traversal
712+
if filename in ("", ".", ".."): # fall back to tmp filename
713+
filename = os.path.basename(path)
712714
path = os.path.join(os.path.dirname(path), filename)
713715

714716
with open(path, "wb") as f:

samples/openapi3/client/petstore/python-aiohttp/petstore_api/api_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,8 @@ def __deserialize_file(self, response):
718718
)
719719
assert m is not None, "Unexpected 'content-disposition' header value"
720720
filename = os.path.basename(m.group(1)) # Strip any directory traversal
721+
if filename in ("", ".", ".."): # fall back to tmp filename
722+
filename = os.path.basename(path)
721723
path = os.path.join(os.path.dirname(path), filename)
722724

723725
with open(path, "wb") as f:

samples/openapi3/client/petstore/python-httpx/petstore_api/api_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,8 @@ def __deserialize_file(self, response):
718718
)
719719
assert m is not None, "Unexpected 'content-disposition' header value"
720720
filename = os.path.basename(m.group(1)) # Strip any directory traversal
721+
if filename in ("", ".", ".."): # fall back to tmp filename
722+
filename = os.path.basename(path)
721723
path = os.path.join(os.path.dirname(path), filename)
722724

723725
with open(path, "wb") as f:

samples/openapi3/client/petstore/python-lazyImports/petstore_api/api_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,8 @@ def __deserialize_file(self, response):
715715
)
716716
assert m is not None, "Unexpected 'content-disposition' header value"
717717
filename = os.path.basename(m.group(1)) # Strip any directory traversal
718+
if filename in ("", ".", ".."): # fall back to tmp filename
719+
filename = os.path.basename(path)
718720
path = os.path.join(os.path.dirname(path), filename)
719721

720722
with open(path, "wb") as f:

samples/openapi3/client/petstore/python/petstore_api/api_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,8 @@ def __deserialize_file(self, response):
715715
)
716716
assert m is not None, "Unexpected 'content-disposition' header value"
717717
filename = os.path.basename(m.group(1)) # Strip any directory traversal
718+
if filename in ("", ".", ".."): # fall back to tmp filename
719+
filename = os.path.basename(path)
718720
path = os.path.join(os.path.dirname(path), filename)
719721

720722
with open(path, "wb") as f:

0 commit comments

Comments
 (0)