Commit Diff


commit - 1a8f0d27f8b09e120149109002ac2c882f07aa0a
commit + bd3a3a9565aa91758111331344a341a8fafca0ec
blob - 25f459c0dc3c4395dc31d21f22a9cf7f1f46271f
blob + 8ac5fc6be7ccffdbf7dc9bbc4ef7337e23bf42fa
--- ChangeLog
+++ ChangeLog
@@ -1,3 +1,9 @@
+2021-07-20  Omar Polo  <op@omarpolo.com>
+
+	* cmd.c (cmd_push_button_new_tab): bugfix: push-button-new-tab on relative URLs now works
+
+	* fs.c (handle_get): add about:crash
+
 2021-07-19  Omar Polo  <op@omarpolo.com>
 
 	* defaults.c (line_prefixes): prettify the default settings
blob - 282fb116e6db11f622285a7832b35422a8ff0e19
blob + 9378cdf41912ed6de687495984024459f23472c3
--- cmd.c
+++ cmd.c
@@ -262,7 +262,7 @@ cmd_push_button(struct buffer *buffer)
 
 	switch (vl->parent->type) {
 	case LINE_LINK:
-		load_url_in_tab(current_tab, vl->parent->alt);
+		load_url_in_tab(current_tab, vl->parent->alt, NULL);
 		break;
 	case LINE_PRE_START:
 		l = TAILQ_NEXT(vl->parent, lines);
@@ -290,7 +290,7 @@ cmd_push_button_new_tab(struct buffer *buffer)
 	if (vl == NULL || vl->parent->type != LINE_LINK)
 		return;
 
-	new_tab(vl->parent->alt);
+	new_tab(vl->parent->alt, current_tab->hist_cur->h);
 }
 
 void
@@ -459,7 +459,7 @@ cmd_tab_new(struct buffer *buffer)
 	if ((url = new_tab_url) == NULL)
 		url = NEW_TAB_URL;
 
-	new_tab(url);
+	new_tab(url, NULL);
 }
 
 void
@@ -550,7 +550,7 @@ cmd_load_current_url(struct buffer *buffer)
 void
 cmd_reload_page(struct buffer *buffer)
 {
-	load_url_in_tab(current_tab, current_tab->hist_cur->h);
+	load_url_in_tab(current_tab, current_tab->hist_cur->h, NULL);
 }
 
 void
@@ -568,7 +568,7 @@ cmd_bookmark_page(struct buffer *buffer)
 void
 cmd_list_bookmarks(struct buffer *buffer)
 {
-	load_url_in_tab(current_tab, "about:bookmarks");
+	load_url_in_tab(current_tab, "about:bookmarks", NULL);
 }
 
 void
blob - 706151b3bffae902181ce00ef2bb4a66e77bc8e1
blob + f68eeb3a21375e9f465bd2c3be4008a4548aca81
--- minibuffer.c
+++ minibuffer.c
@@ -216,7 +216,7 @@ ir_select(void)
 	memcpy(&uri, &tab->uri, sizeof(tab->uri));
 	phos_uri_set_query(&uri, ministate.buf);
 	phos_serialize_uri(&uri, buf, sizeof(buf));
-	load_url_in_tab(tab, buf);
+	load_url_in_tab(tab, buf, NULL);
 }
 
 void
@@ -224,7 +224,7 @@ lu_select(void)
 {
 	exit_minibuffer();
 	minibuffer_hist_save_entry();
-	load_url_in_tab(current_tab, ministate.buf);
+	load_url_in_tab(current_tab, ministate.buf, NULL);
 }
 
 void
@@ -262,7 +262,7 @@ ls_select(void)
 	}
 
 	exit_minibuffer();
-	load_url_in_tab(current_tab, l->alt);
+	load_url_in_tab(current_tab, l->alt, NULL);
 }
 
 static inline void
blob - 1f54d49fcb3d5345c2e0fc8fdfbaf94aea14deb7
blob + 929eb99ebf685048d9bacf7d7cf6cb9f618a5d7b
--- telescope.c
+++ telescope.c
@@ -107,7 +107,7 @@ static void		 handle_imsg_save_cert_ok(struct imsg*, s
 static void		 handle_imsg_update_cert_ok(struct imsg *, size_t);
 static void		 handle_dispatch_imsg(int, short, void*);
 static void		 load_page_from_str(struct tab*, const char*);
-static int		 do_load_url(struct tab*, const char*);
+static int		 do_load_url(struct tab*, const char *, const char *);
 static void		 parse_session_line(char *, const char **, uint32_t *);
 static void		 load_last_session(void);
 static pid_t		 start_child(enum telescope_process, const char *, int);
@@ -373,7 +373,7 @@ handle_imsg_got_meta(struct imsg *imsg, size_t datalen
 			load_page_from_str(tab,
 			    err_pages[TOO_MUCH_REDIRECTS]);
 		} else
-			do_load_url(tab, tab->meta);
+			do_load_url(tab, tab->meta, NULL);
 	} else { /* 4x, 5x & 6x */
 		load_page_from_str(tab, err_pages[tab->code]);
 	}
@@ -621,7 +621,7 @@ load_via_proxy(struct tab *tab, const char *url, struc
  * called by the handling function (such as load_page_from_str).
  */
 static int
-do_load_url(struct tab *tab, const char *url)
+do_load_url(struct tab *tab, const char *url, const char *base)
 {
 	struct phos_uri	 uri;
 	struct proto	*p;
@@ -639,7 +639,11 @@ do_load_url(struct tab *tab, const char *url)
 
 	tab->trust = TS_UNKNOWN;
 
-	memcpy(&uri, &tab->uri, sizeof(tab->uri));
+	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)
@@ -677,7 +681,7 @@ do_load_url(struct tab *tab, const char *url)
  * do load it!
  */
 void
-load_url(struct tab *tab, const char *url)
+load_url(struct tab *tab, const char *url, const char *base)
 {
 	int lazy;
 
@@ -707,7 +711,7 @@ load_url(struct tab *tab, const char *url)
 			    sizeof(tab->hist_cur->h));
 	}
 
-	if (!lazy && do_load_url(tab, url))
+	if (!lazy && do_load_url(tab, url, base))
 		erase_buffer(&tab->buffer);
 }
 
@@ -719,7 +723,7 @@ load_previous_page(struct tab *tab)
 	if ((h = TAILQ_PREV(tab->hist_cur, mhisthead, entries)) == NULL)
 		return 0;
 	tab->hist_cur = h;
-	do_load_url(tab, h->h);
+	do_load_url(tab, h->h, NULL);
 	return 1;
 }
 
@@ -731,7 +735,7 @@ load_next_page(struct tab *tab)
 	if ((h = TAILQ_NEXT(tab->hist_cur, entries)) == NULL)
 		return 0;
 	tab->hist_cur = h;
-	do_load_url(tab, h->h);
+	do_load_url(tab, h->h, NULL);
 	return 1;
 }
 
@@ -825,8 +829,8 @@ load_last_session(void)
 
 	if ((session = fopen(session_file, "r")) == NULL) {
 		/* first time? */
-		new_tab("about:new");
-		switch_to_tab(new_tab("about:help"));
+		new_tab("about:new", NULL);
+		switch_to_tab(new_tab("about:help", NULL));
 		return;
 	}
 
@@ -834,7 +838,7 @@ load_last_session(void)
                 if ((nl = strchr(line, '\n')) != NULL)
 			*nl = '\0';
 		parse_session_line(line, &title, &flags);
-		if ((tab = new_tab(line)) == NULL)
+		if ((tab = new_tab(line, NULL)) == NULL)
 			err(1, "new_tab");
                 strlcpy(tab->buffer.page.title, title,
 		    sizeof(tab->buffer.page.title));
@@ -852,7 +856,7 @@ load_last_session(void)
 		switch_to_tab(curr);
 
 	if (last_time_crashed())
-		switch_to_tab(new_tab("about:crash"));
+		switch_to_tab(new_tab("about:crash", NULL));
 
 	return;
 }
@@ -1050,7 +1054,7 @@ main(int argc, char * const *argv)
 	if (ui_init()) {
 		load_last_session();
 		if (has_url || TAILQ_EMPTY(&tabshead))
-			new_tab(url);
+			new_tab(url, NULL);
 
 		sandbox_ui_process();
 		ui_main_loop();
blob - de756be73c9d06373360b1b6f4614f46046196bd
blob + 5ab3f09c94af932d9be2bb9188942c1d0d5923a7
--- telescope.h
+++ telescope.h
@@ -319,7 +319,7 @@ void		 sandbox_fs_process(void);
 void		 load_about_url(struct tab*, const char*);
 void		 load_gemini_url(struct tab*, const char*);
 void		 load_via_proxy(struct tab *, const char *, struct proxy *);
-void		 load_url(struct tab *, const char *);
+void		 load_url(struct tab *, const char *, const char *);
 int		 load_previous_page(struct tab*);
 int		 load_next_page(struct tab*);
 void		 stop_tab(struct tab*);
blob - accb67c15dbb6a719e0adacf5ae22980e59a9642
blob + a19c00c0a5a2a2fb9a7165c4304f360df71c55a9
--- ui.c
+++ ui.c
@@ -1121,16 +1121,16 @@ stop_loading_anim(struct tab *tab)
 }
 
 void
-load_url_in_tab(struct tab *tab, const char *url)
+load_url_in_tab(struct tab *tab, const char *url, const char *base)
 {
 	if (!operating) {
-		load_url(tab, url);
+		load_url(tab, url, base);
 		return;
 	}
 
 	message("Loading %s...", url);
 	start_loading_anim(tab);
-	load_url(tab, url);
+	load_url(tab, url, base);
 
 	redraw_tab(tab);
 }
@@ -1142,7 +1142,7 @@ switch_to_tab(struct tab *tab)
 	tab->flags &= ~TAB_URGENT;
 
 	if (operating && tab->flags & TAB_LAZY)
-		load_url_in_tab(tab, tab->hist_cur->h);
+		load_url_in_tab(tab, tab->hist_cur->h, NULL);
 }
 
 unsigned int
@@ -1152,7 +1152,7 @@ tab_new_id(void)
 }
 
 struct tab *
-new_tab(const char *url)
+new_tab(const char *url, const char *base)
 {
 	struct tab	*tab;
 
@@ -1176,7 +1176,7 @@ new_tab(const char *url)
 	else
 		TAILQ_INSERT_TAIL(&tabshead, tab, tabs);
 
-	load_url_in_tab(tab, url);
+	load_url_in_tab(tab, url, base);
 	return tab;
 }
 
blob - bdc4da264c23a4ce36b91209801b74b380fb05c9
blob + 0882a7aac655e9ee23595b1a2ef1cf8db1286f51
--- ui.h
+++ ui.h
@@ -107,10 +107,10 @@ struct vline	*adjust_line(struct vline *, struct buffe
 void		 vmessage(const char *, va_list);
 void		 message(const char *, ...) __attribute__((format(printf, 1, 2)));
 void		 start_loading_anim(struct tab *);
-void		 load_url_in_tab(struct tab *, const char *);
+void		 load_url_in_tab(struct tab *, const char *, const char *);
 void		 switch_to_tab(struct tab *);
 struct buffer	*current_buffer(void);
-struct tab	*new_tab(const char *);
+struct tab	*new_tab(const char *, const char *base);
 unsigned int	 tab_new_id(void);
 int		 ui_print_colors(void);
 int		 ui_init(void);