Commit Graph

22231 Commits

Author SHA1 Message Date
Sebastian Dröge
cff78507dc Merge branch 'uri-bees' into 'master'
guri: Always prepend `//` to the host when building a URI

See merge request GNOME/glib!1611
2020-08-07 12:38:49 +00:00
Philip Withnall
89cf298b19 guri: Document and check restrictions on path prefixes
RFC 3986, section 3 says:
> The scheme and path components are required, though the path may be
> empty (no characters).  When authority is present, the path must
> either be empty or begin with a slash ("/") character.  When
> authority is not present, the path cannot begin with two slash
> characters ("//").  These restrictions result in five different ABNF
> rules for a path (Section 3.3), only one of which will match any
> given URI reference.

(See https://tools.ietf.org/html/rfc3986#section-3.)

Given that those conditions are almost always going to be true, and that
typically the number and form of arguments passed to g_uri_join() will
be known at compile time, it would be unnecessarily awkward to add a
`GError` argument to g_uri_join() to detect these situations.

Instead, add precondition checks and document the restrictions.
Developers are responsible for ensuring their paths are in the right
format themselves.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-08-07 13:24:12 +01:00
Philip Withnall
623cb10f55 guri: Always prepend // to the host when building a URI
This is needed to distinguish the host (‘authority’ in the terms of RFC
3986) from a path if a scheme is not present.

It can be seen from the grammar in RFC 3986
(https://tools.ietf.org/html/rfc3986#appendix-A) that `authority` only
ever appears after `"//"`.

Spotted by Simon McVittie in
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1606#note_884893.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-08-07 12:51:31 +01:00
Sebastian Dröge
13ad6ab83c Merge branch 'patch-1' into 'master'
Fix multiple typos in guri.c

See merge request GNOME/glib!1609
2020-08-06 14:36:51 +00:00
Felix Yan
161168c672 Fix multiple typos in guri.c 2020-08-06 14:18:01 +00:00
Sebastian Dröge
d7e0fde3ca Merge branch 'dont-use-gnulib-ios' into 'master'
meson: Don't use gnulib for printf on iOS

Closes #1868

See merge request GNOME/glib!1607
2020-08-06 06:07:46 +00:00
Nirbheek Chauhan
77f9b0b9d5 meson: Don't use gnulib for printf on iOS
iOS and tvOS use the same printf family as macOS, and these all have
been available on macOS for a long time.

Closes https://gitlab.gnome.org/GNOME/glib/-/issues/1868
2020-08-06 05:16:15 +05:30
Sebastian Dröge
a2c8f6f719 Merge branch 'guri-join-schemeless' into 'master'
uri: allow to join a partial URI, without scheme

Closes #2166

See merge request GNOME/glib!1606
2020-08-05 19:14:21 +00:00
Marc-André Lureau
0ba7ebfda9 uri: allow to join a partial URI, without scheme
Fixes: #2166

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-08-05 22:40:08 +04:00
Philip Withnall
bb1df0e515 Merge branch 'uri-params-iter' into 'master'
Add GUriParamsIter

See merge request GNOME/glib!1572
2020-08-05 16:07:42 +00:00
Philip Withnall
df8dc7fc38 Merge branch 'guri-gio' into 'master'
Replace _g_uri_parse_authority() with GUri

Closes #2156

See merge request GNOME/glib!1567
2020-08-05 16:06:02 +00:00
Philip Withnall
71d1a28afb Merge branch 'ipv6-zoneid' into 'master'
Make g_hostname_is_ip_address() accept ipv6 zoneid

See merge request GNOME/glib!1604
2020-08-05 16:00:32 +00:00
Philip Withnall
931496b93a Merge branch 'replace-destination' into 'master'
GFile: Document that G_FILE_CREATE_REPLACE_DESTINATION can only be used with...

See merge request GNOME/glib!1594
2020-08-05 15:39:34 +00:00
Marc-André Lureau
3bcc6fd39f guri: add a test to check ipv6 with zoneid URI to string
The test was failing since commit 20ae4b46d ("uri: do not add ipv6
brackets on non-ip host").

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-08-05 18:50:13 +04:00
Marc-André Lureau
03550ec097 hostutils: accept zoneid in IPv6 addresses
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-08-05 18:50:13 +04:00
Philip Withnall
1c08f55c6d Merge branch 'wip/oholy/x-gvfs-notrash' into 'master'
Add support to ignore trash for certain mounts

See merge request GNOME/glib!1549
2020-08-05 13:25:05 +00:00
Ondrej Holy
4602a5ee17 gfile: Add support for x-gvfs-notrash option to ignore mounts
Add support for x-gvfs-notrash mount option, which allows to disable
trash functionality for certain mounts. This might be especially useful
e.g. to prevent trash folder creation on enterprise shares, which are
also accessed from Windows...

https://bugzilla.redhat.com/show_bug.cgi?id=1096200
2020-08-05 13:07:04 +01:00
Ondrej Holy
0d6b17584a gunixmounts: Add g_unix_mount_point_at
There is already g_unix_mount_at function which allows to find certain
unix mount for given mount path. It would be useful to have similar
function for mount points, which will allow to replace custom codes in
gvfs. Let's add g_unix_mount_point_at.
2020-08-05 13:07:04 +01:00
Marc-André Lureau
5767eef895 uri: add GUriParamsIter
See also:
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1328#note_863735
2020-08-04 20:10:57 +04:00
Sebastian Dröge
50343afb6e Merge branch 'uri-userinfo-enc' into 'master'
uri: do not encode ':' and ';' from userinfo

See merge request GNOME/glib!1600
2020-08-04 13:33:18 +00:00
Sebastian Dröge
48ad40aca3 Merge branch 'uri-encoded-parts' into 'master'
uri: add ENCODED_PATH & ENCODED_FRAGMENT flags

See merge request GNOME/glib!1595
2020-08-04 13:13:52 +00:00
Marc-André Lureau
ef173e2e75 uri: do not encode ':' and ';' from userinfo
The g_uri_join_internal() function was making a simplification that
userinfo can be encoded with the same restricted character set as the
user field alone, fix this by allowing the correct character set.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-08-04 17:10:06 +04:00
Marc-André Lureau
c354c404c6 tests/uri: check user field is correctly encoded
Suggested-by: Dan Winship <danw@gnome.org>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-08-04 17:10:06 +04:00
Marc-André Lureau
4c20ea477c uri: always add G_URI_FLAGS_HAS_PASSWORD with build_with_user()
Otherwise, the to_string() encoding will not be reversible. Furthermore,
if no distinction is needed in the first place, g_uri_build() with
userinfo should be used instead.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-08-04 17:10:06 +04:00
Marc-André Lureau
b0f9af0e1d uri: do not encode userinfo fields
g_uri_build_with_user() builds a userinfo, but it shouldn't encode it
itself, but let the user flags declare what's there. Otherwise,
to_string() code paths may encode a second time.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-08-04 17:03:30 +04:00
Marc-André Lureau
c9c349aeaa uri: add ENCODED_PATH & ENCODED_FRAGMENT flags
Add encoded flags, similar to what was done in commit 7bee36b4 ("uri:
add G_FLAGS_ENCODED_QUERY").

SoupURI has manual handling of encoded path & fragment, but it can rely
on GUri decoding for the rest.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-08-04 16:56:19 +04:00
Sebastian Dröge
a97fe4e863 Merge branch 'uri-ipv6-bkt' into 'master'
uri: do not add ipv6 brackets on non-ip host

See merge request GNOME/glib!1599
2020-08-04 12:44:12 +00:00
Matthias Clasen
e3b6f20b77 Merge branch 'revert-8f960c79' into 'master'
Revert "Merge branch 'appinfo-properties' into 'master'"

See merge request GNOME/glib!1602
2020-08-02 21:14:43 +00:00
Matthias Clasen
96d39f86b5 Revert "Merge branch 'appinfo-properties' into 'master'"
This reverts merge request !1582
2020-08-02 21:02:03 +00:00
Matthias Clasen
5b3da6ea34 Merge branch 'fix-uninitialized-use' into 'master'
timezone: Fix an uninitialized use

See merge request GNOME/glib!1601
2020-08-02 02:18:19 +00:00
Matthias Clasen
0992978202 timezone: Fix an uninitialized use
GTK ci rightly complains about this when ti builds
GLib as a subproject with -Werror=maybe-uninitialized.

subkey_dynamic_w will be freed without being initialized
when the first goto is taken.
2020-07-31 14:04:21 -04:00
Marc-André Lureau
20ae4b46d4 uri: do not add ipv6 brackets on non-ip host
The heuristic is a bit too agressive, as we may have hostname with
%-encoded ':' (as shown in GVfs URI tests).

Add an extra test to check :-decoding as well.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-07-30 21:37:34 +04:00
Daniel Mustieles
7ce6a01f99 Updated Spanish translation 2020-07-29 12:07:49 +02:00
Matthias Clasen
8f960c79e9 Merge branch 'appinfo-properties' into 'master'
appinfo: Add properties

See merge request GNOME/glib!1582
2020-07-29 01:20:50 +00:00
Matthias Clasen
9193fd529f Add a missing include 2020-07-28 17:29:47 -04:00
Hans Petter Jansson
4c5ccd3e8f gslice: Allow inlining of memset() in g_slice_new0() macro
Inlining the memset() is beneficial since the size here is constant
and usually small.

Closes #5
2020-07-28 18:22:21 +02:00
Marc-André Lureau
0fea3d71e4 guri: add some IPv6 scope-id tests
Add a few ipv6 scope parsing corner test cases.

- checking incorrect scoped IPv6 ending with only %25 isn't decoded.
- checking valid scoped IPv6 is passing g_uri_is_valid()

As discussed in
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1567#note_860499,
for historical reasons, GUri accepts the % preceding the zone-id in the
unescaped form as well.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-07-28 16:48:01 +04:00
Marc-André Lureau
dd0fae1303 gio: remove _g_uri_parse_authority()
It is now unused and redundant with GUri.

Fixes: #2156

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-07-28 16:35:13 +04:00
Marc-André Lureau
aa0b09ebef gio: use g_uri_split_network() in g_simple_proxy_resolver_lookup()
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-07-28 16:35:05 +04:00
Marc-André Lureau
1b6a0535e8 gio: use g_uri_split_with_user() in save_userinfo()
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-07-28 16:32:50 +04:00
Marc-André Lureau
6f419e7e2f gio: use g_uri_split_network() in g_network_address_parse_uri()
_g_uri_parse_authority() can be replaced with g_uri_split_network() &
PARSE_STRICT. Keep the original error code, for compatibility reasons.

Notice that GUri uses gint for the port, and value -1 if the port value
is missing. However, GNetworkAddress::port is a guint.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-07-28 16:31:11 +04:00
Marc-André Lureau
a173a6f617 gio: use g_uri_is_valid()
_g_uri_parse_authority() without argument is actually checking that the
URI is valid, by checking it parses successfully

We keep the existing error domain / code for compatibility reasons,
instead of raising the underlying G_URI_ERROR.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-07-28 16:15:50 +04:00
Marc-André Lureau
034a4dcdc0 gio: replace _g_uri_from_authority() with g_uri_join()
_g_uri_from_authority() is doing the same work as g_uri_join(): taking
URI components and merging them in a legit URI string, with encoding.

It turns out g_uri_from_authority was unnecessarily complex, since no
caller used the userinfo field.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-07-28 16:12:37 +04:00
Marc-André Lureau
82ad7853ba uri: change g_uri_is_valid() to check absolute URI
g_uri_is_valid() should check the given URI is valid following RFC-3986,
and reject relative references.

Fixes: https://gitlab.gnome.org/GNOME/glib/-/issues/2169

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-07-28 15:44:43 +04:00
Marc-André Lureau
44d4640c47 uri: rename absolute & relative uri_string to uri_ref
Let's reserve the term URI for absolute URIs, following rfc3986
terminology.

See:
https://gitlab.gnome.org/GNOME/glib/-/issues/2169

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-07-28 15:07:08 +04:00
Marc-André Lureau
d625a29b28 uri: add a comment about temporary GUri construction
As pointed out in the discussion of:
https://gitlab.gnome.org/GNOME/glib/-/issues/2169

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-07-28 14:54:55 +04:00
Marc-André Lureau
19c0db3185 uri: improve some documentation about absolute URIs
As pointed out in the discussion
https://gitlab.gnome.org/GNOME/glib/-/issues/2169.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-07-28 14:54:55 +04:00
Marc-André Lureau
3521763532 uri: add some note about the API scope
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2020-07-28 14:54:42 +04:00
Matthias Clasen
df7f35e81a Apply 1 suggestion(s) to 1 file(s) 2020-07-27 19:49:05 +00:00
Matthias Clasen
b5fc5d6423 Apply 1 suggestion(s) to 1 file(s) 2020-07-27 19:48:50 +00:00