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 508773 - g_uri_escape_string() documentation unclear.
g_uri_escape_string() documentation unclear.
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gio
2.12.x
Other Linux
: Normal normal
: ---
Assigned To: Alexander Larsson
gtkdev
Depends on:
Blocks:
 
 
Reported: 2008-01-11 14:29 UTC by Murray Cumming
Modified: 2008-01-15 15:58 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Murray Cumming 2008-01-11 14:29:42 UTC
g_uri_escape_string() takes "a string of reserved characters that are allowed to be used.", but it's not clear how this is used:
http://library.gnome.org/devel/glib/unstable/glib-URI-Functions.html#g-uri-escape-string

Is it a list of reserved characters that may _not_ be used (and will therefore be escaped) or is it a list of reserved characters (some subset of some well-known list of reserved characters) that will not be escaped?
Comment 1 Alexander Larsson 2008-01-14 14:39:07 UTC
Added:
 * Normally all characters that are not "unreserved" (i.e. ASCII alphanumerical
 * characters plus dash, dot, underscore and tilde) are escaped.
 * But if you specify characters in @reserved_chars_allowed they are not
 * escaped. This is useful for the "reserved" characters in the URI
 * specification, since those are allowed unescaped in some portions of
 * a URI. 
Comment 2 Murray Cumming 2008-01-15 12:03:40 UTC
Thanks. That's very helpful.

g_uri_unescape_string() could use some similar clarification. For instance, it's not clear whether anything would happen if illegal_characters was NULL, or if that's again just modifying some standard set of characters to expect to be escaped.
Comment 3 Alexander Larsson 2008-01-15 13:09:12 UTC
Adding this:

 * If any of the characters in @illegal_characters or the character zero appears
 * as an escaped character in @escaped_string then that is an error and %NULL
 * will be returned. This is useful it you want to avoid for instance having a
 * slash being expanded in an escaped path element, which might confuse pathname
 * handling.
Comment 4 Alexander Larsson 2008-01-15 13:09:46 UTC
and:

 * @illegal_characters: an optional string of illegal characters not to be allowed.
Comment 5 Murray Cumming 2008-01-15 13:55:42 UTC
Many thanks. I assume that reserved_chars_allowed and illegal_characters may be UTF-8? Sorry if this is getting annoying.
Comment 6 Alexander Larsson 2008-01-15 15:58:23 UTC
No, they are bytes. Uri escaping works on a byte basis, not a unicode character basis. There is no encoding specified, and in fact there might not be any (for example in an inline encoded data uri).