After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 528600 - g_dummy_file_get_parent("scheme://example.com/")
g_dummy_file_get_parent("scheme://example.com/")
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gio
unspecified
Other Linux
: Normal major
: ---
Assigned To: Alexander Larsson
gtkdev
: 530086 (view as bug list)
Depends on:
Blocks: 537298 537557
 
 
Reported: 2008-04-17 16:10 UTC by Owen Taylor
Modified: 2008-06-11 17:51 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
fix it (601 bytes, patch)
2008-04-18 17:20 UTC, A. Walton
none Details | Review
Christian Neumair's fix (481 bytes, patch)
2008-04-27 20:24 UTC, A. Walton
committed Details | Review

Description Owen Taylor 2008-04-17 16:10:30 UTC
g_file_get_parent() is supposed to return:

 * Returns: a #GFile structure to the parent of the given
 *     #GFile or %NULL if there is no parent. 

Which implies you can walk up to the root by checking for NULL (and
gnome-panel does this)

But 

 g_dummy_file_get_parent("scheme://example.com/")

Returns the same thing, which puts gnome-panel into a nice infinite
loop.
Comment 1 A. Walton 2008-04-18 17:20:36 UTC
Created attachment 109496 [details] [review]
fix it

Here's the fix for this; oddly enough we were doing the right thing in GDaemonFile but not in GDummyFile (I guess all of us were using GVFS during testing). It looks to be correct against RFC 3986 if I understand it correctly.

Anyways, here's the test case, which I would have included in the patch, but I'm not sure exactly where GIO tests will go and how they should be tooled to run (wrt make check, etc).

/**
 run test via:
 GIO_USE_VFS=local ./test-528600
 **/
#include <glib.h>
#include <gio/gio.h>

void
test_dummy_file_get_parent (void)
{
	GFile *file, *parent_file;
	file = g_file_new_for_uri ("scheme://example.com");
	g_assert_cmpstr (G_OBJECT_TYPE_NAME(file), ==, "GDummyFile");
	parent_file = g_file_get_parent (file);
	g_assert (parent_file == NULL);
	g_object_unref(file);
}

int
main (int argc, char *argv[])
{
	g_type_init();
	g_test_init(&argc, &argv, NULL);
	g_test_add_func ("/gio/g_dummy_file_get_parent", test_dummy_file_get_parent);
	return g_test_run();
}
Comment 2 A. Walton 2008-04-27 20:24:15 UTC
Created attachment 110003 [details] [review]
Christian Neumair's fix

Here's Christian Neumair's fix from the other bug. I'm not sure which is better other than that his is simpler (though I'm sadly not familiar enough with that section of code to assure that we're never reaching a state where the path can be NULL).

Either way, can we get a GLib maintainer to comment/commit one of these fixes?
Comment 3 A. Walton 2008-04-27 20:24:23 UTC
*** Bug 530086 has been marked as a duplicate of this bug. ***
Comment 4 A. Walton 2008-06-10 13:52:04 UTC
Raising severity, we really need to get a fix in for this as it's starting to pop up during usage (albeit strange cases).
Comment 5 Cosimo Cecchi 2008-06-10 14:40:54 UTC
I think using g_strcmp0 () instead of plain strcmp () in Christian's patch would be the safest option to solve this.
Comment 6 Matthias Clasen 2008-06-10 15:29:49 UTC
        Bug 528600 – g_dummy_file_get_parent("scheme://example.com/")

        * gdummyfile.c (g_dummy_file_get_parent): Return NULL if there
        is no parent.  (Owen Taylor, patch by Christian Persch)
Comment 7 A. Walton 2008-06-10 15:31:12 UTC
s/Persch/Neumair/ ;)