mirror of https://github.com/zulip/zulip.git
rocketchat: Fix "OSError: [Errno 36] File name too long" error.
Earlier, we were replacing too long attachment name with random uuid when the character count of the file name was greater than 255. This results in "OSError: [Errno 36] File name too long" error in few cases when the file name has less than 255 characters but more than 255 bytes (file name with Non-ASCII characters). This commit updates the code to check the file name's byte size instead of characters count.
This commit is contained in:
parent
54492ec7a0
commit
19d56f77b5
|
@ -402,7 +402,7 @@ def process_message_attachment(
|
||||||
logging.info("Replacing invalid attachment name with random uuid: %s", file_name)
|
logging.info("Replacing invalid attachment name with random uuid: %s", file_name)
|
||||||
sanitized_name = uuid.uuid4().hex
|
sanitized_name = uuid.uuid4().hex
|
||||||
|
|
||||||
if len(sanitized_name) >= 255: # nocoverage
|
if len(sanitized_name.encode("utf-8")) >= 255: # nocoverage
|
||||||
logging.info("Replacing too long attachment name with random uuid: %s", file_name)
|
logging.info("Replacing too long attachment name with random uuid: %s", file_name)
|
||||||
sanitized_name = uuid.uuid4().hex
|
sanitized_name = uuid.uuid4().hex
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue