Bug#1020215: w3m interprets when not in <head> but in <svg></span></a></span> </h1> <p class="darkgray font13"> <span class="sender pipe"><a href="/search?l=debian-bugs-dist@lists.debian.org&q=from:%22Robert+Alm+Nilsson%22" rel="nofollow"><span itemprop="author" itemscope itemtype="http://schema.org/Person"><span itemprop="name">Robert Alm Nilsson</span></span></a></span> <span class="date"><a href="/search?l=debian-bugs-dist@lists.debian.org&q=date:20220918" rel="nofollow">Sun, 18 Sep 2022 01:39:16 -0700</a></span> </p> </div> <div itemprop="articleBody" class="msgBody"> <!--X-Body-of-Message--> <pre>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.</pre><pre> 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) </pre> </div> <div class="msgButtons margintopdouble"> <ul class="overflow"> <li class="msgButtonItems"><a class="button buttonleft " accesskey="p" href="msg1870263.html">Previous message</a></li> <li class="msgButtonItems textaligncenter"><a class="button" accesskey="c" href="thrd11.html#1870265">View by thread</a></li> <li class="msgButtonItems textaligncenter"><a class="button" accesskey="i" href="mail12.html#1870265">View by date</a></li> <li class="msgButtonItems textalignright"><a class="button buttonright " accesskey="n" href="msg1870268.html">Next message</a></li> </ul> </div> <a name="tslice"></a> <div class="tSliceList margintopdouble"> <ul class="icons monospace"> <li class="icons-email tSliceCur"><span class="subject">Bug#1020215: w3m interprets <title> when not in &...</span> <span class="sender italic">Robert Alm Nilsson</span></li> <li><ul> <li class="icons-email"><span class="subject"><a href="msg1870268.html">Bug#1020215: (no subject)</a></span> <span class="sender italic">Robert Alm Nilsson</span></li> </ul> </ul> </div> <div class="overflow msgActions margintopdouble"> <div class="msgReply" > <h2> Reply via email to </h2> <form method="POST" action="/mailto.php"> <input type="hidden" name="subject" value="Bug#1020215: w3m interprets <title> when not in <head> but in <svg>"> <input type="hidden" name="msgid" value="YybXFJw9boTt8fyJ@f"> <input type="hidden" name="relpath" value="debian-bugs-dist@lists.debian.org/msg1870265.html"> <input type="submit" value=" Robert Alm Nilsson "> </form> </div> </div> </div> <div class="aside" role="complementary"> <div class="logo"> <a href="/"><img src="/logo.png" width=247 height=88 alt="The Mail Archive"></a> </div> <form class="overflow" action="/search" method="get"> <input type="hidden" name="l" value="debian-bugs-dist@lists.debian.org"> <label class="hidden" for="q">Search the site</label> <input class="submittext" type="text" id="q" name="q" placeholder="Search debian-bugs-dist"> <input class="submitbutton" name="submit" type="image" src="/submit.png" alt="Submit"> </form> <div class="nav margintop" id="nav" role="navigation"> <ul class="icons font16"> <li class="icons-home"><a href="/">The Mail Archive home</a></li> <li class="icons-list"><a href="/debian-bugs-dist@lists.debian.org/">debian-bugs-dist - all messages</a></li> <li class="icons-about"><a href="/debian-bugs-dist@lists.debian.org/info.html">debian-bugs-dist - about the list</a></li> <li class="icons-expand"><a href="/search?l=debian-bugs-dist@lists.debian.org&q=subject:%22Bug%231020215%5C%3A+w3m+interprets+%3Ctitle%3E+when+not+in+%3Chead%3E+but+in+%3Csvg%3E%22&o=newest&f=1" title="e" id="e">Expand</a></li> <li class="icons-prev"><a href="msg1870263.html" title="p">Previous message</a></li> <li class="icons-next"><a href="msg1870268.html" title="n">Next message</a></li> </ul> </div> <div class="listlogo margintopdouble"> <a href="#"><img src="/debian-bugs-dist@lists.debian.org/logo.png" alt="debian-bugs-dist"></a> </div> <div class="margintopdouble"> </div> </div> </div> <div class="footer" role="contentinfo"> <ul> <li><a href="/">The Mail Archive home</a></li> <li><a href="/faq.html#newlist">Add your mailing list</a></li> <li><a href="/faq.html">FAQ</a></li> <li><a href="/faq.html#support">Support</a></li> <li><a href="/faq.html#privacy">Privacy</a></li> <li class="darkgray">YybXFJw9boTt8fyJ@f</li> </ul> </div> </body> </html>