prevent a bug preventing .mobileconfig uploads in Linux/Windows (#14716)

For #14056, per the [mdn web
docs](https://developer.mozilla.org/en-US/docs/Web/API/File/type)

> Note: Based on the current implementation, browsers won't actually
> read the bytestream of a file to determine its media type. It is
assumed
> based on the file extension; a PNG image file renamed to .txt would
give
> "text/plain" and not "image/png". Moreover, file.type is generally
> reliable only for common file types like images, HTML documents, audio
> and video. Uncommon file extensions would return an empty string.
Client
> configuration (for instance, the Windows Registry) may result in
> unexpected values even for common types. Developers are advised not to
> rely on this property as a sole validation scheme.
This commit is contained in:
Roberto Dip 2023-10-26 18:20:24 -03:00 committed by GitHub
parent 001120274c
commit 3869b41041
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

1
changes/14056-file-ext Normal file
View file

@ -0,0 +1 @@
* Fixed a bug preventing Windows and Linux users to upload .mobileconfig files in the UI.

View file

@ -61,7 +61,9 @@ const CustomSettings = ({
const file = files[0];
if (
file.type !== "application/x-apple-aspen-config" ||
// file.type might be empty on some systems as uncommon file extensions
// would return an empty string.
(file.type !== "" && file.type !== "application/x-apple-aspen-config") ||
!file.name.includes(".mobileconfig")
) {
renderFlash("error", UPLOAD_ERROR_MESSAGES.wrongType.message);