Skip to content

Commit

Permalink
Merge pull request #3 from foolab/master
Browse files Browse the repository at this point in the history
[glib] Add 0001-networkaddress-fix-parsing-of-uri-with-after-authoripatch. Fixes JB#32240
  • Loading branch information
foolab committed Sep 15, 2015
2 parents 8594609 + 9e19234 commit e17d031
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
@@ -0,0 +1,62 @@
From 20feb23569e61b061b507e995b5438a35676ae51 Mon Sep 17 00:00:00 2001
From: Wim Taymans <wtaymans@redhat.com>
Date: Mon, 10 Mar 2014 16:27:48 +0100
Subject: [PATCH] networkaddress: fix parsing of uri with @ after authority

Make sure that the @ sign is inside the authority part before attempting
to parse the userinfo. We do this by checking if the @ sign comes before
any of the possible authority delimiters.
Add unit test to verify parsing of ftp://ftp.gnome.org/start?foo=bar@baz

https://bugzilla.gnome.org/show_bug.cgi?id=726040
---
gio/gnetworkaddress.c | 11 +++++++++--
gio/tests/network-address.c | 3 ++-
2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/gio/gnetworkaddress.c b/gio/gnetworkaddress.c
index 342a6b9..0519713 100644
--- a/gio/gnetworkaddress.c
+++ b/gio/gnetworkaddress.c
@@ -453,7 +453,7 @@ _g_uri_parse_authority (const char *uri,
char **userinfo)
{
char *tmp_str;
- const char *start, *p;
+ const char *start, *p, *at, *delim;
char c;

g_return_val_if_fail (uri != NULL, FALSE);
@@ -493,7 +493,14 @@ _g_uri_parse_authority (const char *uri,

start += 2;

- if (strchr (start, '@') != NULL)
+ /* check if the @ sign is part of the authority before attempting to
+ * decode the userinfo */
+ delim = strpbrk (start, "/?#[]");
+ at = strchr (start, '@');
+ if (at && delim && at > delim)
+ at = NULL;
+
+ if (at != NULL)
{
/* Decode userinfo:
* userinfo = *( unreserved / pct-encoded / sub-delims / ":" )
diff --git a/gio/tests/network-address.c b/gio/tests/network-address.c
index a8be415..ac4842c 100644
--- a/gio/tests/network-address.c
+++ b/gio/tests/network-address.c
@@ -42,7 +42,8 @@ static ParseTest uri_tests[] = {
{ "http://[fec0::abcd%em1]/start", "http", "fec0::abcd%em1", 8080, -1 },
{ "http://[fec0::abcd%25em1]/start", "http", "fec0::abcd%em1", 8080, -1 },
{ "http://[fec0::abcd%10]/start", "http", "fec0::abcd%10", 8080, -1 },
- { "http://[fec0::abcd%25em%31]/start", NULL, NULL, 0, G_IO_ERROR_INVALID_ARGUMENT }
+ { "http://[fec0::abcd%25em%31]/start", NULL, NULL, 0, G_IO_ERROR_INVALID_ARGUMENT },
+ { "ftp://ftp.gnome.org/start?foo=bar@baz", "ftp", "ftp.gnome.org", 8080, -1 }
};

static void
--
2.1.4

3 changes: 3 additions & 0 deletions rpm/glib2.spec
Expand Up @@ -16,6 +16,7 @@ Patch0: 0001-GDBusObjectManagerClient-keep-the-manager-alive-whil.patch
Patch1: glib-2.36.3-syslog-message-handler.patch
Patch2: 0001-Add-dev-mmcblk-to-the-list-of-devices-to-be-detected.patch
Patch3: use-mtab-instead-of-fstab.patch
Patch4: 0001-networkaddress-fix-parsing-of-uri-with-after-authori.patch
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
BuildRequires: pkgconfig(libpcre)
Expand Down Expand Up @@ -69,6 +70,8 @@ version 2 of the GLib library.
%patch2 -p1
# use-mtab-instead-of-fstab.patch
%patch3 -p1
# 0001-networkaddress-fix-parsing-of-uri-with-after-authori.patch
%patch4 -p1

%build
# >> build pre
Expand Down

0 comments on commit e17d031

Please sign in to comment.