ConnMan network manager
 help / color / mirror / Atom feed
From: Grant Erickson <gerickson@nuovations.com>
To: connman@lists.linux.dev
Cc: Marcel Holtmann <marcel@holtmann.org>, Denis Kenzior <denkenz@gmail.com>
Subject: [PATCH v6 0/3] gweb: refactor parse_url for IPv6 addresses.
Date: Sat, 11 Nov 2023 09:44:49 -0800	[thread overview]
Message-ID: <D7CD4553-EAFB-4A13-8847-668F8E909424@nuovations.com> (raw)

Prior to this change, 'parse_url' failed to correctly handle RFC 2732-
compliant URLs with bracketed IPv6 addresses such as:

    http://[2001:db8:4006:812::200e]:8080/online/status.html

Such bracketing is necessary when using IPv6 addresses to disambiguate
the host component from the port component due to the presence of the
colon (':') in IPv6 addresses. As such, prior to this change, such URLs
resulted in the brackets and the IPv6 address being passed to GResolv
which, unsurprisingly, failed to successfully forward resolve since the
resulting host was neither a valid host name nor a valid IPv6 address.

As a result, support for such RFC 2732-compliant bracketed IPv6
addresses has been added with this change which refactors the
previously-monolithic 'parse_url' into several, focused functions:

    * parse_request_and_proxy_urls
        - parse_request_url
            o parse_url_components
                + parse_url_scheme
                + parse_url_host_and_port
                    * parse_url_host
                    * parse_url_port
                + parse_url_path
        - parse_proxy_url

In particular, 'parse_url_host' is the new function responsible for
parsing the host and correctly handling one of seven possible
combinations of host and port, two of which include bracketed IPv6
addresses.

In addition, 'parse_url_host' will now return an error on an empty,
non-existent host and 'parse_url_port' will return an error on invalid,
out-of-range ports.

Grant Erickson (3):
  gweb: Rename 'parse_url'.
  gweb: Refactor 'parse_request_and_proxy_urls'.
  gweb: Add documentation to URL parsing functions.

 gweb/gweb.c | 855 ++++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 789 insertions(+), 66 deletions(-)

-- 
2.42.0



             reply	other threads:[~2023-11-11 17:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-11 17:44 Grant Erickson [this message]
2023-11-11 17:45 ` [PATCH v6 1/3] gweb: Rename 'parse_url' Grant Erickson
2023-11-11 17:47 ` [PATCH v6 2/3] gweb: Refactor 'parse_request_and_proxy_urls' Grant Erickson
2023-11-11 17:47 ` [PATCH v6 3/3] gweb: Add documentation to URL parsing functions Grant Erickson
2023-11-11 18:16 ` [PATCH v6 0/3] gweb: refactor parse_url for IPv6 addresses Marcel Holtmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=D7CD4553-EAFB-4A13-8847-668F8E909424@nuovations.com \
    --to=gerickson@nuovations.com \
    --cc=connman@lists.linux.dev \
    --cc=denkenz@gmail.com \
    --cc=marcel@holtmann.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).