Skip to content

Commit

Permalink
exclude ext from character_limit
Browse files Browse the repository at this point in the history
  • Loading branch information
arash77 committed Nov 20, 2024
1 parent 77767b3 commit dfafd7a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/galaxy/util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2011,6 +2011,7 @@ def lowercase_alphanum_to_hex(lowercase_alphanum: str) -> str:

def to_content_disposition(target: str) -> str:
filename, ext = os.path.splitext(target)
sanitized_filename = "".join(c in FILENAME_VALID_CHARS and c or "_" for c in filename)[0:255] + ext
utf8_encoded_filename = quote(re.sub(r'[\/\\\?%*:|"<>]', "_", filename), safe="")[0:255] + ext
character_limit = 255 - len(ext)
sanitized_filename = "".join(c in FILENAME_VALID_CHARS and c or "_" for c in filename)[0:character_limit] + ext
utf8_encoded_filename = quote(re.sub(r'[\/\\\?%*:|"<>]', "_", filename), safe="")[0:character_limit] + ext
return f"attachment; filename=\"{sanitized_filename}\"; filename*=UTF-8''{utf8_encoded_filename}"

0 comments on commit dfafd7a

Please sign in to comment.