Reject empty file names and fix FlashImage.path endswith call

- Return 400 for empty or whitespace-only file_name to prevent the
  idedata fallback from matching everything via empty-string suffix.
- Use image.path.as_posix().endswith() since FlashImage.path is a Path
  object which does not have a string endswith method.
- Add parametrized test for empty/whitespace file name values.
This commit is contained in:
J. Nick Koston
2026-02-08 07:32:00 -06:00
parent 43448d55f1
commit b650d2df31
2 changed files with 24 additions and 2 deletions
+2 -2
View File
@@ -1054,7 +1054,7 @@ class DownloadBinaryRequestHandler(BaseHandler):
# fallback to type=, but prioritize file=
file_name = self.get_argument("type", None)
file_name = self.get_argument("file", file_name)
if file_name is None:
if file_name is None or not file_name.strip():
self.send_error(400)
return
# get requested download name, or build it based on filename
@@ -1087,7 +1087,7 @@ class DownloadBinaryRequestHandler(BaseHandler):
found = False
for image in idedata.extra_flash_images:
if image.path.endswith(file_name):
if image.path.as_posix().endswith(file_name):
path = image.path
download_name = file_name
found = True