Package: w3m Version: 0.5.3+git20220429-1+b1 When opening a page in w3m that contains an <svg> element that contains a <title> tag, w3m will use that svg title as the page title.
An example of a page to demonstrate this problem is github.com. The real title of github.com is "GitHub: Where the world builds software ยท GitHub" but w3m displays the title "Go" (or the name of any other language) because the front page contains svg images for different programming languages with title tags. Here is a patch I made. I don't know if this is the most optimal way to solve this but it seems to work in practice and I will use it locally until there in an upstream fix. commit f41db326e73fde685c1d0b79e46beec56336995e Author: Robert Alm Nilsson <rob...@robalni.org> Date: Sun Sep 18 09:51:29 2022 +0200 Only read title when in head Before this change, it was possible that w3m would interpret a title tag under e.g. an svg tag as the page title. diff --git a/file.c b/file.c index 9704cea..8e8b280 100644 --- a/file.c +++ b/file.c @@ -4816,19 +4816,23 @@ HTMLtagproc1(struct parsed_tag *tag, struct html_feed_environ *h_env) /* obuf->flag |= RB_IGNORE_P; */ return 1; case HTML_TITLE: - close_anchor(h_env, obuf); - process_title(tag); - obuf->flag |= RB_TITLE; - obuf->end_tag = HTML_N_TITLE; + if (obuf->flag & RB_HEAD) { + close_anchor(h_env, obuf); + process_title(tag); + obuf->flag |= RB_TITLE; + obuf->end_tag = HTML_N_TITLE; + } return 1; case HTML_N_TITLE: - if (!(obuf->flag & RB_TITLE)) - return 1; - obuf->flag &= ~RB_TITLE; - obuf->end_tag = 0; - tmp = process_n_title(tag); - if (tmp) - HTMLlineproc1(tmp->ptr, h_env); + if (obuf->flag | RB_HEAD) { + if (!(obuf->flag & RB_TITLE)) + return 1; + obuf->flag &= ~RB_TITLE; + obuf->end_tag = 0; + tmp = process_n_title(tag); + if (tmp) + HTMLlineproc1(tmp->ptr, h_env); + } return 1; case HTML_TITLE_ALT: if (parsedtag_get_value(tag, ATTR_TITLE, &p)) @@ -5523,9 +5527,13 @@ HTMLtagproc1(struct parsed_tag *tag, struct html_feed_environ *h_env) } } case HTML_N_HEAD: + obuf->flag &= ~RB_HEAD; if (obuf->flag & RB_TITLE) HTMLlineproc1("</title>", h_env); + return 1; case HTML_HEAD: + obuf->flag |= RB_HEAD; + return 1; case HTML_N_BODY: return 1; default: diff --git a/fm.h b/fm.h index 25857f8..9e12b42 100644 --- a/fm.h +++ b/fm.h @@ -675,6 +675,7 @@ struct readbuffer { #define RB_DEL 0x100000 #define RB_S 0x200000 #define RB_HTML5 0x400000 +#define RB_HEAD 0x800000 #define RB_GET_ALIGN(obuf) ((obuf)->flag&RB_ALIGN) #define RB_SET_ALIGN(obuf,align) do{(obuf)->flag &= ~RB_ALIGN; (obuf)->flag |= (align); }while(0)