GNOME Bugzilla – Bug 670431
shut up libsoup runtime warning
Last modified: 2012-02-24 19:12:41 UTC
libsoup-WARNING **: (soup-uri.c:1017):soup_uri_set_path: runtime check failed: (path != NULL)
+ Trace 229691
Thread 1 (Thread 0xb3d3f890 (LWP 3715))
Created attachment 208029 [details] [review] ephy-profile-utils: update for SoupURI API change soup_uri_set_path does not like NULL as an argument anymore. It still works but will print a runtime warning. Use an empty string instead: "".
Comment on attachment 208029 [details] [review] ephy-profile-utils: update for SoupURI API change yes, that's correct
Actually I think the right patch would be: - soup_uri_set_path (uri, NULL); + soup_uri_set_path (uri, "/"); as this is how all my old passwords were stored by epy in previous versions. Even with Diego's patch, current code would not be able to use user stored passwords, something that looks like a huge regression to me.
(In reply to comment #3) > Actually I think the right patch would be: > > - soup_uri_set_path (uri, NULL); > + soup_uri_set_path (uri, "/"); > > as this is how all my old passwords were stored by epy in previous versions. You mean libsoup used to add "/" when NULL was passed before?
(In reply to comment #4) > (In reply to comment #3) > > Actually I think the right patch would be: > > > > - soup_uri_set_path (uri, NULL); > > + soup_uri_set_path (uri, "/"); > > > > as this is how all my old passwords were stored by epy in previous versions. > > You mean libsoup used to add "/" when NULL was passed before? No, what I mean is that all HTTP(S) uris created with soup_uri_new will have a path equal to "/" if none provided. I don't know the epy details but it looks like all my previous credentials where stored in the keyring using "/" as the path for the uri, no mather if the path was "/whatever/path" or none at all. So I guess epy was the one changing the actual URI path to "/" but as I said I haven't skimmed through the history.
This is what happens: soup_uri_to_string appends a '/' as path if there is no path but there are query or fragment parts. Which means that any SoupURI with ->path NULL will get a '/' path when it needs to. Also, libsoup's 6a8814e232f4c1e8f1bc4bf31f6899c1968dfe5e added a check for non NULL path. (the g_return_if_fail was added in a previous commit 675979d4aa6a72d8415294f989aeb20a6eae2ab6, which ended up needing this fixup) So, it should be ok to set_path to "", do not set it at all, or use "/". Even NULL is ok, but it prints a warning. soup_uri_set_path (SoupURI *uri, const char *path) { g_return_if_fail (uri != NULL); - g_return_if_fail (path != NULL); + + /* We allow a NULL path for compatibility, but warn about it. */ + if (!path) { + g_warn_if_fail (path != NULL); + path = ""; + } g_free (uri->path); uri->path = g_strdup (path); char * soup_uri_to_string (SoupURI *uri, gboolean just_path_and_query) { GString *str; char *return_result; g_return_val_if_fail (uri != NULL, NULL); g_warn_if_fail (SOUP_URI_IS_VALID (uri)); str = g_string_sized_new (20); if (uri->scheme && !just_path_and_query) g_string_append_printf (str, "%s:", uri->scheme); if (uri->host && !just_path_and_query) { g_string_append (str, "//"); if (uri->user) { append_uri_encoded (str, uri->user, ":;@?/"); g_string_append_c (str, '@'); } if (strchr (uri->host, ':')) { g_string_append_c (str, '['); g_string_append (str, uri->host); g_string_append_c (str, ']'); } else append_uri_encoded (str, uri->host, ":/"); if (uri->port && uri->port != soup_scheme_default_port (uri->scheme)) g_string_append_printf (str, ":%u", uri->port); if (!uri->path && (uri->query || uri->fragment)) g_string_append_c (str, '/'); } if (uri->path && *uri->path) g_string_append (str, uri->path); if (uri->query) { g_string_append_c (str, '?'); g_string_append (str, uri->query); } if (uri->fragment && !just_path_and_query) { g_string_append_c (str, '#'); g_string_append (str, uri->fragment); } return_result = str->str; g_string_free (str, FALSE); return return_result; }
setting it to "" is ok to shut up the warning, but since it results in different output from soup_uri_to_string(), it breaks saved passwords, as Sergio noted. So yeah, you want "/"
Sorry I forgot to close this. Xan asked me to commit the set_path("/") version some hours ago. Fixed in 62df9fbfc122699b421e541828d1b6dfd259269f