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 620417 - g_uri_unescape_string cannot unescape %00
g_uri_unescape_string cannot unescape %00
Status: RESOLVED OBSOLETE
Product: glib
Classification: Platform
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2010-06-02 23:44 UTC by Arc Riley
Modified: 2018-05-24 12:21 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Arc Riley 2010-06-02 23:44:01 UTC
Some HTTP services include escaped binary values (such as 20-byte SHA1 hash) which may include a %00.  Currently there is no mechanism to support this properly with glib.

I propose something along the lines of:

gboolean g_uri_unescape_string_length (const char *escaped_string, const char *illegal_characters, char **unescaped_string, gsize *unescaped_string_length)
Comment 1 Javier Jardón (IRC: jjardon) 2010-06-03 15:11:47 UTC
@alex: As you are the author of the g_uri_* api, what do you think about this addition?
Comment 2 Daniel Macks 2010-06-03 15:43:09 UTC
Would we also need the inverse function, something like:

char * g_uri_escape_string_length (const char *unescaped,
                                   const char *reserved_chars_allowed,
                                   gboolean allow_utf8,
                                   gsize unescaped_string_length);

I assume g_uri_escape_string() treats \0 as termination of the unescaped string.
Comment 3 Evan Nemerson 2010-06-05 20:15:05 UTC
I don't think g_uri_*_string_length is the right name... the existing API handles strings, it is binary data that it can't handle.

I think this would be a good API:

char * g_uri_escape (const guchar *unescaped, gssize unescaped_length, const char *reversed_chars_allowed, gboolean allow_utf8);
guchar * g_uri_unescape (const char *escaped_string, const char *illegal_characters, gsize *result_length);
GString * g_string_append_uri_data_escaped (GString *string, const char *unescaped, gsize unescaped_length, const char *reserved_chars_allowed, gboolean allow_utf8);

The g_uri_* functions are similar to what already exists for g_base64_* (uchar* and gsize, no suffix) as well as the existing g_uri_{encode,decode}_string (all the other arguments). Unfortunately, g_string_append_uri_escaped already exists, and its name is a bit inconsistent with the g_uri_* API, so I think the next best thing is g_string_append_uri_data_escaped, or maybe g_string_append_uri_escaped_data?
Comment 4 GNOME Infrastructure Team 2018-05-24 12:21:02 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glib/issues/307.