gwinhttpvfs: Fall back to wrapped VFS if creating a HTTP file fails

If we fail to create a GWinhttpFile for a URI (for example, because it’s
an invalid URI or is badly encoded), don’t just return NULL. Instead,
fall back to the wrapped VFS which might be able to handle it instead.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Fixes: #1819
This commit is contained in:
Philip Withnall 2019-07-02 12:10:21 +01:00
parent 4b0421a730
commit 562ac9de43

View File

@ -165,15 +165,25 @@ g_winhttp_vfs_get_file_for_uri (GVfs *vfs,
{
GWinHttpVfs *winhttp_vfs = G_WINHTTP_VFS (vfs);
int i;
GFile *ret = NULL;
/* If it matches one of "our" schemes, handle it */
for (i = 0; i < G_N_ELEMENTS (winhttp_uri_schemes); i++)
if (g_ascii_strncasecmp (uri, winhttp_uri_schemes[i], strlen (winhttp_uri_schemes[i])) == 0 &&
uri[strlen (winhttp_uri_schemes[i])] == ':')
return _g_winhttp_file_new (winhttp_vfs, uri);
{
if (g_ascii_strncasecmp (uri, winhttp_uri_schemes[i], strlen (winhttp_uri_schemes[i])) == 0 &&
uri[strlen (winhttp_uri_schemes[i])] == ':')
{
ret = _g_winhttp_file_new (winhttp_vfs, uri);
}
}
/* For other URIs fallback to the wrapped GVfs */
return g_vfs_get_file_for_uri (winhttp_vfs->wrapped_vfs, uri);
if (ret == NULL)
ret = g_vfs_get_file_for_uri (winhttp_vfs->wrapped_vfs, uri);
g_assert (ret != NULL);
return g_steal_pointer (&ret);
}
static const gchar * const *