if the passed filename starts with a valid, but unhandled uri scheme, fail

2006-10-15  Michael Natterer  <mitch@gimp.org>

	* app/file/file-utils.c (file_utils_filename_to_uri): if the
	passed filename starts with a valid, but unhandled uri scheme,
	fail with an error saying "URI scheme 'foo:' is not supported"
	instead of treating it as relative file path. Fixes bug #358203.

	* app/dialogs/file-open-location-dialog.c
	(file_open_location_response): don't close the dialog on errors
	that are related to the entered URI because these errors are
	failed user input validation, not failed open.
This commit is contained in:
Michael Natterer 2006-10-15 20:04:51 +00:00 committed by Michael Natterer
parent 33720907ef
commit a99f968775
3 changed files with 39 additions and 0 deletions

View File

@ -1,3 +1,15 @@
2006-10-15 Michael Natterer <mitch@gimp.org>
* app/file/file-utils.c (file_utils_filename_to_uri): if the
passed filename starts with a valid, but unhandled uri scheme,
fail with an error saying "URI scheme 'foo:' is not supported"
instead of treating it as relative file path. Fixes bug #358203.
* app/dialogs/file-open-location-dialog.c
(file_open_location_response): don't close the dialog on errors
that are related to the entered URI because these errors are
failed user input validation, not failed open.
2006-10-15 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpview-popup.c: close the popup when a drag starts.

View File

@ -228,6 +228,9 @@ file_open_location_response (GtkDialog *dialog,
_("Opening '%s' failed:\n\n%s"),
text, error->message);
g_clear_error (&error);
gimp_dialog_set_sensitive (dialog, TRUE);
return;
}
}

View File

@ -125,6 +125,30 @@ file_utils_filename_to_uri (GSList *procs,
return NULL;
}
}
else if (strstr (filename, "://"))
{
gchar *scheme;
gchar *canon;
scheme = g_strndup (filename, (strstr (filename, "://") - filename));
canon = g_strdup (scheme);
g_strcanon (canon, G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "+-.", '-');
if (! strcmp (scheme, canon) && g_ascii_isgraph (canon[0]))
{
g_set_error (error, G_FILE_ERROR, 0,
_("URI scheme '%s:' is not supported"), scheme);
g_free (scheme);
g_free (canon);
return NULL;
}
g_free (scheme);
g_free (canon);
}
if (! g_path_is_absolute (filename))
{