mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-02 05:27:41 -05:00
patterns: Disallow application/octet-stream to be used as MIME type
This commit is contained in:
@@ -21,4 +21,6 @@ namespace hex::magic {
|
||||
std::string getMIMEType(const std::vector<u8> &data);
|
||||
std::string getMIMEType(prv::Provider *provider, size_t size = 100_KiB);
|
||||
|
||||
bool isValidMIMEType(const std::string &mimeType);
|
||||
|
||||
}
|
||||
@@ -96,4 +96,18 @@ namespace hex::magic {
|
||||
return getMIMEType(buffer);
|
||||
}
|
||||
|
||||
bool isValidMIMEType(const std::string &mimeType) {
|
||||
// MIME types always contain a slash
|
||||
if (!mimeType.contains("/"))
|
||||
return false;
|
||||
|
||||
// The MIME type "application/octet-stream" is a fallback type for arbitrary binary data.
|
||||
// Specifying this in a pattern would make it get suggested for every single unknown binary that's being loaded.
|
||||
// We don't want that, so we ignore it here
|
||||
if (mimeType == "application/octet-stream")
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user