commit - 5657662f9f60baa58e29c8c34dbd0c68cc784790
commit + 25905047961cd12825ada96af1c8e155b4da3814
blob - 34abcd824819232b05a0c8ce3b2a9b468f46a8bf
blob + 64c58dc33bdf0f73fa2a8b792d4c300480608eca
--- include/telescope.h
+++ include/telescope.h
#include <stdio.h> /* XXX: for parsers.h */
#include "cmd.h"
-#include "phos.h"
+#include "iri.h"
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
char *cert;
enum trust_state trust;
struct proxy *proxy;
- struct phos_uri uri;
+ struct iri iri;
struct histhead hist;
struct hist *hist_cur;
size_t hist_off;
blob - f28aa10423a0b52f2045f8f71c9cf209dc54b784
blob + 202790522d830e1e67c26e02f7719f0c893744b2
--- parser/parser.c
+++ parser/parser.c
if ((slash = strchr(tab->buffer.page.title, '/')) != NULL)
*slash = '\0';
} else
- strlcpy(tab->buffer.page.title, tab->uri.host,
+ strlcpy(tab->buffer.page.title, tab->iri.iri_host,
sizeof(tab->buffer.page.title));
return r;
blob - 2957b75bcacd65449e3944e17755a0e98e92afa5
blob + da8ade9b8ac2b8a110d522f365d21f52c269b674
--- telescope.c
+++ telescope.c
host = tab->proxy->host;
port = tab->proxy->port;
} else {
- host = tab->uri.host;
- port = tab->uri.port;
+ host = tab->iri.iri_host;
+ port = tab->iri.iri_portstr;
}
if ((e = tofu_lookup(&certs, host, port)) == NULL) {
sizeof(accept));
if (accept) {
+ const char *host, *port;
+
+ host = tab->iri.iri_host;
+ port = tab->iri.iri_portstr;
+
/*
* trust the certificate for this session only. If
* the page results in a redirect while we're asking
* sense to save it for the current session if the
* user accepted it.
*/
- tofu_temp_trust(&certs, tab->uri.host, tab->uri.port,
- tab->cert);
+ tofu_temp_trust(&certs, host, port, tab->cert);
if (!safe_mode)
ui_yornp("Save the new certificate?",
host = tab->proxy->host;
port = tab->proxy->port;
} else {
- host = tab->uri.host;
- port = tab->uri.port;
+ host = tab->iri.iri_host;
+ port = tab->iri.iri_portstr;
}
if (!accept)
return;
}
- if ((f = strrchr(tab->uri.path, '/')) == NULL)
+ if ((f = strrchr(tab->iri.iri_path, '/')) == NULL)
f = "";
else
f++;
load_finger_url(struct tab *tab, const char *url)
{
struct get_req req;
- size_t len;
- char *at;
+ const char *path;
memset(&req, 0, sizeof(req));
- strlcpy(req.port, tab->uri.port, sizeof(req.port));
+ strlcpy(req.host, tab->iri.iri_host, sizeof(req.host));
+ strlcpy(req.port, tab->iri.iri_portstr, sizeof(req.port));
/*
* Sometimes the finger url have the user as path component
* (e.g. finger://thelambdalab.xyz/plugd), sometimes as
* userinfo (e.g. finger://cobradile@finger.farm).
*/
- if ((at = strchr(tab->uri.host, '@')) != NULL) {
- len = at - tab->uri.host;
- memcpy(req.req, tab->uri.host, len);
-
- if (len >= sizeof(req.req))
- die();
- req.req[len] = '\0';
-
- strlcpy(req.host, at+1, sizeof(req.host));
+ if (tab->iri.iri_flags & IH_UINFO) {
+ strlcpy(req.req, tab->iri.iri_uinfo, sizeof(req.req));
} else {
- strlcpy(req.host, tab->uri.host, sizeof(req.host));
-
- /* +1 to skip the initial `/' */
- strlcpy(req.req, tab->uri.path+1, sizeof(req.req));
+ path = tab->iri.iri_path;
+ while (*path == '/')
+ ++path;
+ strlcpy(req.req, path, sizeof(req.req));
}
strlcat(req.req, "\r\n", sizeof(req.req));
struct get_req req;
memset(&req, 0, sizeof(req));
- strlcpy(req.host, tab->uri.host, sizeof(req.host));
- strlcpy(req.port, tab->uri.port, sizeof(req.port));
+ strlcpy(req.host, tab->iri.iri_host, sizeof(req.host));
+ strlcpy(req.port, tab->iri.iri_portstr, sizeof(req.port));
make_request(tab, &req, PROTO_GEMINI, tab->hist_cur->h);
}
const char *path;
memset(&req, 0, sizeof(req));
- strlcpy(req.host, tab->uri.host, sizeof(req.host));
- strlcpy(req.port, tab->uri.port, sizeof(req.port));
+ strlcpy(req.host, tab->iri.iri_host, sizeof(req.host));
+ strlcpy(req.port, tab->iri.iri_portstr, sizeof(req.port));
- path = gopher_skip_selector(tab->uri.path, &type);
+ path = gopher_skip_selector(tab->iri.iri_path, &type);
switch (type) {
case '0':
parser_init(tab, textplain_initparser);
}
strlcpy(req.req, path, sizeof(req.req));
- if (*tab->uri.query != '\0') {
+ if (tab->iri.iri_flags & IH_QUERY) {
strlcat(req.req, "?", sizeof(req.req));
- strlcat(req.req, tab->uri.query, sizeof(req.req));
+ strlcat(req.req, tab->iri.iri_query, sizeof(req.req));
}
strlcat(req.req, "\r\n", sizeof(req.req));
struct get_req req;
memset(&req, 0, sizeof(req));
- strlcpy(req.host, tab->uri.host, sizeof(req.host));
- strlcpy(req.port, tab->uri.port, sizeof(req.port));
+ strlcpy(req.host, tab->iri.iri_host, sizeof(req.host));
+ strlcpy(req.port, tab->iri.iri_portstr, sizeof(req.port));
/* +2 to skip /7 */
- strlcpy(req.req, tab->uri.path+2, sizeof(req.req));
- if (*tab->uri.query != '\0') {
+ strlcpy(req.req, tab->iri.iri_path+2, sizeof(req.req));
+ if (tab->iri.iri_flags & IH_QUERY) {
strlcat(req.req, "?", sizeof(req.req));
- strlcat(req.req, tab->uri.query, sizeof(req.req));
+ strlcat(req.req, tab->iri.iri_query, sizeof(req.req));
}
strlcat(req.req, "\t", sizeof(req.req));
do_load_url(struct tab *tab, const char *url, const char *base, int mode)
{
const struct proto *p;
- struct phos_uri uri;
struct proxy *proxy;
int nocache = mode & LU_MODE_NOCACHE;
char *t;
tab->proxy = NULL;
tab->trust = TS_UNKNOWN;
- if (base == NULL)
- memcpy(&uri, &tab->uri, sizeof(tab->uri));
- else
- phos_parse_absolute_uri(base, &uri);
-
- if (!phos_resolve_uri_from_str(&uri, url, &tab->uri)) {
- if (asprintf(&t, "#error loading %s\n>%s\n",
- url, "Can't parse the URI") == -1)
+ if (iri_parse(base, url, &tab->iri) == -1) {
+ if (asprintf(&t, "# error loading %s\n>%s\n",
+ url, "Can't parse the IRI") == -1)
die();
strlcpy(tab->hist_cur->h, url, sizeof(tab->hist_cur->h));
load_page_from_str(tab, t);
return;
}
- phos_serialize_uri(&tab->uri, tab->hist_cur->h,
- sizeof(tab->hist_cur->h));
+ iri_unparse(&tab->iri, tab->hist_cur->h, sizeof(tab->hist_cur->h));
if (!nocache && mcache_lookup(tab->hist_cur->h, tab)) {
ui_on_tab_refresh(tab);
}
for (p = protos; p->schema != NULL; ++p) {
- if (!strcmp(tab->uri.scheme, p->schema)) {
- /* patch the port */
- if (*tab->uri.port == '\0' && p->port != NULL)
- strlcpy(tab->uri.port, p->port,
- sizeof(tab->uri.port));
+ if (!strcmp(tab->iri.iri_scheme, p->schema)) {
+ /* patch the port -- XXX should update `port' too */
+ if (*tab->iri.iri_portstr == '\0' &&
+ p->port != NULL)
+ strlcpy(tab->iri.iri_portstr, p->port,
+ sizeof(tab->iri.iri_portstr));
p->loadfn(tab, tab->hist_cur->h);
return;
}
TAILQ_FOREACH(proxy, &proxies, proxies) {
- if (!strcmp(tab->uri.scheme, proxy->match_proto)) {
+ if (!strcmp(tab->iri.iri_scheme, proxy->match_proto)) {
load_via_proxy(tab, url, proxy);
return;
}