HomePhabricator
Diffusion Comm eb9aa10454da

[lib][native] Sanitize media upload filenames

Description

[lib][native] Sanitize media upload filenames

Summary:
Related: ENG-2562, ENG-2475

  • Created a function that replaces all invalid characters in filename with underscores. If the filename is not present, it is randomly generated and extension is deduced from MIME type.
  • Made the filename optional in MediaLibrarySelection type.
  • Used the above function to make sure that filename is valid when processed in processMedia().

Test Plan:
On both platforms various different photos/videos including these containing spaces. Confirmed that all of them work and thumbnail generation doesn't crash.

Also manually tested the regex: https://regex101.com/r/1FCRbJ/2

Reviewers: ashoat, atul

Reviewed By: ashoat, atul

Subscribers: tomek

Differential Revision: https://phab.comm.dev/D6493

Details

Provenance
bartekAuthored on Feb 1 2023, 7:42 AM
Reviewer
ashoat
Differential Revision
D6493: [lib][native] Sanitize media upload filenames
Parents
rCOMM87657d1bd188: [patch] Export `emojiAvatarForAddress` from `rainbowkit`
Branches
Unknown
Tags
Unknown