--- evince-3.18.2.old/libdocument/ev-file-helpers.c +++ evince-3.18.2/libdocument/ev-file-helpers.c @@ -472,7 +472,78 @@ GFile *file; GFileInfo *file_info; const gchar *content_type; - gchar *mime_type = NULL; + + gchar *mime_type = NULL; + gchar *x_uri; + char *bp; + char *cp; + +//-------------------------------------------------------------------- + +#define MTODP "application/vnd.oasis.opendocument.presentation" +#define MTSXI "application/vnd.sun.xml.impress" +#define SCCMP strcasecmp + + x_uri = g_strdup (uri); + + if (((cp = strrchr (x_uri, '.')) != NULL) && + (cp [1] != '\000') && + (strlen (cp) < 50)) + { + char *mt = NULL; + char xyz [128]; + *cp++ = '\000'; + + if (((bp = strrchr (x_uri, '.')) != NULL) && + (bp [1] != '\000') && + (strlen (bp) < 50)) + { + bp++; + + if (!SCCMP (cp, "bz") || !SCCMP (cp, "bz2")) + { + sprintf (xyz, "bz%s", bp); cp = xyz; + } + else if (!SCCMP (cp, "gz")) + { + sprintf (xyz, "gz%s", bp); cp = xyz; + } + } + +if (!SCCMP (cp, "bzdvi" )) mt = "application/x-bzdvi" ; +if (!SCCMP (cp, "bzeps" )) mt = "image/x-bzeps" ; +if (!SCCMP (cp, "bzpdf" )) mt = "application/x-bzpdf" ; +if (!SCCMP (cp, "bzps" )) mt = "application/x-bzpostscript" ; +if (!SCCMP (cp, "cb7" )) mt = "application/x-cb7" ; +if (!SCCMP (cp, "cbr" )) mt = "application/x-cbr" ; +if (!SCCMP (cp, "cbz" )) mt = "application/x-cbz" ; +if (!SCCMP (cp, "djvu" )) mt = "image/vnd.djvu" ; +if (!SCCMP (cp, "dvi" )) mt = "application/x-dvi" ; +if (!SCCMP (cp, "eps" )) mt = "image/x-eps" ; +if (!SCCMP (cp, "gzdvi" )) mt = "application/x-gzdvi" ; +if (!SCCMP (cp, "gzeps" )) mt = "image/x-gzeps" ; +if (!SCCMP (cp, "gzpdf" )) mt = "application/x-gzpdf" ; +if (!SCCMP (cp, "gzps" )) mt = "application/x-gzpostscript" ; +if (!SCCMP (cp, "odp" )) mt = MTODP ; +if (!SCCMP (cp, "pdf" )) mt = "application/pdf" ; +if (!SCCMP (cp, "ps" )) mt = "application/postscript" ; +if (!SCCMP (cp, "svg" )) mt = "image/svg+xml" ; +if (!SCCMP (cp, "sxi" )) mt = MTSXI ; +if (!SCCMP (cp, "tif" )) mt = "image/tiff" ; +if (!SCCMP (cp, "tiff" )) mt = "image/tiff" ; + + if (mt != NULL) + { + mime_type = g_strdup (mt); + g_free (x_uri); + *error = NULL; + return (mime_type); + } + } + + g_free (x_uri); + +//-------------------------------------------------------------------- file = g_file_new_for_uri (uri); file_info = g_file_query_info (file, @@ -574,7 +645,21 @@ gboolean fast, GError **error) { - return fast ? get_mime_type_from_uri (uri, error) : get_mime_type_from_data (uri, error); +#ifdef NOTDEF // Old version + return fast ? get_mime_type_from_uri (uri, error) : get_mime_type_from_data (uri, error); +#else // Bug-fix version + gchar *mime_type = get_mime_type_from_uri (uri, error); + + if (mime_type == NULL) + { + if (!fast) + mime_type = get_mime_type_from_data (uri, error); + if (mime_type == NULL) + mime_type = g_strdup ("unknown/unknown"); + } + + return (mime_type); +#endif // Endif NOTDEF } /* Compressed files support */