summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2019-10-11 12:00:59 +0200
committerBastien Nocera <hadess@hadess.net>2019-10-11 12:00:59 +0200
commit65a6270229326ba898b6ec6335f42e52c46b54d8 (patch)
tree7eada9bc6b38e0acde117526efb1830f717c0c66
parent0a7e768db4674f8f240622929fd75f674df39417 (diff)
downloadgvfs-65a6270229326ba898b6ec6335f42e52c46b54d8.tar.gz
sftp: Don't set a content-type that isn't certain
Don't ignore the result_uncertain flag from g_content_type_guess() as it might cause nautilus to incorrectly think that a particular file is of a certain type, and never check its magic.
-rw-r--r--daemon/gvfsbackendsftp.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/daemon/gvfsbackendsftp.c b/daemon/gvfsbackendsftp.c
index a2f353b0..ccaddee7 100644
--- a/daemon/gvfsbackendsftp.c
+++ b/daemon/gvfsbackendsftp.c
@@ -2410,6 +2410,7 @@ parse_attributes (GVfsBackendSftp *backend,
guint32 mode;
gboolean has_uid, free_mimetype;
char *mimetype;
+ gboolean uncertain_content_type;
flags = g_data_input_stream_read_uint32 (reply, NULL, NULL);
@@ -2449,6 +2450,7 @@ parse_attributes (GVfsBackendSftp *backend,
g_file_info_set_attribute_uint32 (info, G_FILE_ATTRIBUTE_UNIX_MODE, mode);
mimetype = NULL;
+ uncertain_content_type = FALSE;
if (S_ISREG (mode))
type = G_FILE_TYPE_REGULAR;
else if (S_ISDIR (mode))
@@ -2488,14 +2490,15 @@ parse_attributes (GVfsBackendSftp *backend,
{
if (basename)
{
- mimetype = g_content_type_guess (basename, NULL, 0, NULL);
+ mimetype = g_content_type_guess (basename, NULL, 0, &uncertain_content_type);
free_mimetype = TRUE;
}
else
mimetype = "application/octet-stream";
}
-
- g_file_info_set_content_type (info, mimetype);
+
+ if (!uncertain_content_type)
+ g_file_info_set_content_type (info, mimetype);
g_file_info_set_attribute_string (info, G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE, mimetype);
if (g_file_attribute_matcher_matches (matcher,