diff options
author | Philip Withnall <withnall@endlessm.com> | 2019-07-02 12:10:21 +0100 |
---|---|---|
committer | Philip Withnall <withnall@endlessm.com> | 2019-08-27 08:24:16 +0300 |
commit | 87c8168980f70fe6cc46bd7a8d88431813a34be0 (patch) | |
tree | c3cf0f8d1df76f5fca2d724084d44b084f5dee24 | |
parent | 7b90d507d8a22eb2a31a8c291966d271db0212eb (diff) | |
download | glib-87c8168980f70fe6cc46bd7a8d88431813a34be0.tar.gz |
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
-rw-r--r-- | gio/win32/gwinhttpvfs.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/gio/win32/gwinhttpvfs.c b/gio/win32/gwinhttpvfs.c index 038368f81..91d7fed9d 100644 --- a/gio/win32/gwinhttpvfs.c +++ b/gio/win32/gwinhttpvfs.c @@ -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 * |