Force g_file_query_info if magic_file returns application/octet-stream
If a new file type is not recognized by libmagic, ristretto fails to consult the mime database. This is because libmagic will not return NULL, but "application/octet-stream", which is not handled by rsott_file_is_valid.
The following patch fixes that: It simply checks if magic_file returns "application/octet-stream" and then sets content_type to NULL. The rest of the processing is the unchanged.
diff -ru ristretto-0.13.0/src/file.c ristretto-0.13.0-content-type/src/file.c
--- ristretto-0.13.0/src/file.c 2023-01-06 11:08:47.000000000 +0100
+++ ristretto-0.13.0-content-type/src/file.c 2023-04-28 23:44:31.592674158 +0200
@@ -215,6 +215,10 @@
if (NULL != file_path && magic_load (magic, NULL) == 0)
{
content_type = magic_file (magic, file_path);
+ /* magic_file returns "application/octet-stream", not NULL */
+ if (g_strcmp0 (content_type, "application/octet-stream") == 0) {
+ content_type = NULL;
+ }
if (NULL != content_type)
{
/* mime types that require post-processing */