Merge branch '1819-file-for-uri-null' into 'master'

Resolve "Invalid characters in Open Location dialog crashes GIMP"

Closes #1819

See merge request GNOME/glib!966
This commit is contained in:
Philip Withnall 2019-08-27 05:41:24 +00:00
commit 1c41e348ae
3 changed files with 21 additions and 9 deletions

View File

@ -236,7 +236,7 @@ g_vfs_get_file_for_uri (GVfs *vfs,
const char *uri)
{
GVfsClass *class;
GFile *ret;
GFile *ret = NULL;
g_return_val_if_fail (G_IS_VFS (vfs), NULL);
g_return_val_if_fail (uri != NULL, NULL);
@ -244,10 +244,12 @@ g_vfs_get_file_for_uri (GVfs *vfs,
class = G_VFS_GET_CLASS (vfs);
ret = get_file_for_uri_internal (vfs, uri);
if (ret)
return ret;
if (!ret)
ret = (* class->get_file_for_uri) (vfs, uri);
return (* class->get_file_for_uri) (vfs, uri);
g_assert (ret != NULL);
return g_steal_pointer (&ret);
}
/**

View File

@ -80,7 +80,7 @@ g_winhttp_file_init (GWinHttpFile *winhttp)
* @vfs: GWinHttpVfs to use
* @uri: URI of the GWinHttpFile to create.
*
* Returns: new winhttp #GFile.
* Returns: (nullable): new winhttp #GFile, or %NULL if there was an error constructing it.
*/
GFile *
_g_winhttp_file_new (GWinHttpVfs *vfs,

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 *