From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Sebasti=C3=A1n_?= =?UTF-8?Q?Mon=C3=ADa?= Newsgroups: gmane.emacs.bugs Subject: bug#73133: 29.2; EWW fails to render some webpages Date: Mon, 23 Sep 2024 11:56:16 -0400 Message-ID: References: <86plox4bef.fsf@gnu.org> <7eb7b048-06ea-5751-56e1-590689c8c318@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27255"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Eli Zaretskii , 73133@debbugs.gnu.org, ganimard@tuta.io To: Jim Porter Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Sep 23 18:28:05 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ssluu-0006pD-3a for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 23 Sep 2024 18:28:05 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sslsy-0004vP-3P; Mon, 23 Sep 2024 12:26:05 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sslsa-0003Ti-8p for bug-gnu-emacs@gnu.org; Mon, 23 Sep 2024 12:25:43 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sslsZ-00015p-W2 for bug-gnu-emacs@gnu.org; Mon, 23 Sep 2024 12:25:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=VwA5plKB/7LWOBxnV91ZB3w54Q69d3EjYjKuqwTuPb4=; b=ZU6b/DV7ahMYhukY+Y/PSAngcPW0hhP58keS7gxSqOWAzNVgAKA7Q2/5/seVm7VkdQkhNAi3uBpZk+kqJYzKOcCzaQoq/cztQTeNjymJVdXuGyel6NmcuQKNXEpGt62wVFzlEaRL9dXWgya7tPn/WWsgDNjWgw3Vxb5mcklWFCs8QQEVK8HB5ZaW1pNzHghNjwOdfPT5Fa2U+pj2f4PnEcvP+JubYnWXh6o9Dlb6TXQdvZ3swpBxAw1blaV2ggvHhXkdjP+dLxbYXZYU+JjTNw/3/1p93IlOE/1eva7/9QPlgl6jSwYFZpDgKxgKArU7Zr5EY1Dr+SkqXecU3K8MFQ==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sslsx-0007bG-3z for bug-gnu-emacs@gnu.org; Mon, 23 Sep 2024 12:26:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?Sebasti=C3=A1n_?= =?UTF-8?Q?Mon=C3=ADa?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 23 Sep 2024 16:26:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73133 X-GNU-PR-Package: emacs Original-Received: via spool by 73133-submit@debbugs.gnu.org id=B73133.172710873329005 (code B ref 73133); Mon, 23 Sep 2024 16:26:03 +0000 Original-Received: (at 73133) by debbugs.gnu.org; 23 Sep 2024 16:25:33 +0000 Original-Received: from localhost ([127.0.0.1]:44674 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sslsS-0007XU-8n for submit@debbugs.gnu.org; Mon, 23 Sep 2024 12:25:32 -0400 Original-Received: from fout-a7-smtp.messagingengine.com ([103.168.172.150]:44475) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sslQc-0005tL-09 for 73133@debbugs.gnu.org; Mon, 23 Sep 2024 11:56:48 -0400 Original-Received: from phl-compute-01.internal (phl-compute-01.phl.internal [10.202.2.41]) by mailfout.phl.internal (Postfix) with ESMTP id 88D0313801CA; Mon, 23 Sep 2024 11:56:17 -0400 (EDT) Original-Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-01.internal (MEProxy); Mon, 23 Sep 2024 11:56:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sebasmonia.com; h=cc:cc:content-type:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm2; t=1727106977; x= 1727193377; bh=VwA5plKB/7LWOBxnV91ZB3w54Q69d3EjYjKuqwTuPb4=; b=o 7wP3W0G5XlhSzfE/l8mjM2I7kRtqFt2uzZR7wUBSDH6dYwJhlmPvNrpioC63s3xb C6yOi95u+VQj/5TRknFfv3DGW5MOjDi1LoogwrBhKLtQ7kVspFMqm/MlsiIjZjvw czkLnWnMCcrNFyvVNeQv3W/ObZG7yRyamv+r0CntCkLgijxtI+mvL9jZ71PKl6j5 jhSIw2ta4bhoPbKMyGcLRQboess5gDXuI4N/32fUpOW9DlFkREC3GzLVxZRr81Z+ 4X3/QtBdcUr2MoL8R17mFFBL2GUlH5GFoOc+Ijer6UUsUwpgVGfW+De9IuLtqMbG WzfqXDLP+3NgnO+9myO5Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1727106977; x=1727193377; bh=VwA5plKB/7LWOBxnV91ZB3w54Q69 d3EjYjKuqwTuPb4=; b=H4z28T2nSsX4FpfxRMk4z9MmbsrFl6nzLH+jDOE7/W9r n9t+/jRlMy521pcP2CNew73Pw8OUxLHdOZW/A0Q5R3q3kuivROmM+g+7Syhny4Ou WeVkEiQF+v3eQR9t7lmHzImL1IYAX+VwEEzKztBgZjW6A9UmbQsx71EBFYfYFnfP 0Sb2XO5ule59NfGxdL28zjYva1yQb3IN5Zt8FPnv+Oeu+DDjo6Y/uO0rVmEHJH0X nCrjMLZ0/Vh6jnSdTR+Fd4wso3LBJCw+476Py0xZCY/m1BHGoM5LKiqma/k8Evn6 TMhmSE/V0l+xwh3yh8sVqc9XMFD7OOq4GRnwI4VUqQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudelledgleeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhephffvvefujghffgffkfggtgesmhdtreertderuden ucfhrhhomhepufgvsggrshhtihojnhcuofhonhovrgcuoehsvggsrghsthhirghnsehsvg gsrghsmhhonhhirgdrtghomheqnecuggftrfgrthhtvghrnheptdetiedvhfevffegjedu hfdtffehkeejkefhkeehleekudekueeigeffvdehheegnecuvehluhhsthgvrhfuihiivg eptdenucfrrghrrghmpehmrghilhhfrhhomhepshgvsggrshhtihgrnhesshgvsggrshhm ohhnihgrrdgtohhmpdhnsggprhgtphhtthhopeegpdhmohguvgepshhmthhpohhuthdprh gtphhtthhopehgrghnihhmrghrugesthhuthgrrdhiohdprhgtphhtthhopeejfedufeef seguvggssghughhsrdhgnhhurdhorhhgpdhrtghpthhtohepvghlihiisehgnhhurdhorh hgpdhrtghpthhtohepjhhpohhrthgvrhgsuhhgshesghhmrghilhdrtghomh X-ME-Proxy: Feedback-ID: iab2c46da:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 23 Sep 2024 11:56:17 -0400 (EDT) In-Reply-To: <7eb7b048-06ea-5751-56e1-590689c8c318@gmail.com> (Jim Porter's message of "Sat, 21 Sep 2024 10:12:22 -0700") X-Mailman-Approved-At: Mon, 23 Sep 2024 12:25:27 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:292287 Archived-At: --=-=-= Content-Type: text/plain Hi all, Would something like the attached patch work? Thanks, Seb PS: I think I sent this to just one person by mistake instead of a wide reply, my bad. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Add-option-eww-use-doctype-fallback-code-to-detect-i.patch Content-Description: eww-use-doctype-fallback >From 499abe197e6d245228be853731314e19148bb658 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Mon=C3=ADa?= Date: Mon, 23 Sep 2024 11:40:18 -0400 Subject: [PATCH] Add option eww-use-doctype-fallback, code to detect if a page has a valid doctype tag, and use it as alternative to a content-type header --- lisp/net/eww.el | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/lisp/net/eww.el b/lisp/net/eww.el index a651d9d5020..59a146c8392 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -170,6 +170,14 @@ the first item is the program, and the rest are the arguments." :type '(choice (const :tag "Never" nil) regexp)) +(defcustom eww-use-doctype-fallback t + "Accept a DOCTYPE tag as evidence that page content is HTML. +This is used only when the page does not have a valid Content-Type +header." + :version "30.1" + :group 'eww + :type 'boolean) + (defcustom eww-browse-url-new-window-is-tab 'tab-bar "Whether to open up new windows in a tab or a new buffer. If t, then open the URL in a new tab rather than a new buffer if @@ -630,6 +638,18 @@ Currently this means either text/html or application/xhtml+xml." (member content-type '("text/html" "application/xhtml+xml"))) +(defun eww--doctype-html-p (data-buffer) + "Return non-nil if DATA-BUFFER contains a doctype declaration." + ;; https://html.spec.whatwg.org/multipage/syntax.html#the-doctype + (let ((case-fold-search t) + (target + "\\|system +\\(\\\"\\|'\\)+about:legacy-compat\\)")) + (with-current-buffer data-buffer + (goto-char (point-min)) + ;; match basic and also legacy variants as + ;; specified in link above + (re-search-forward target nil t)))) + (defun eww--rename-buffer () "Rename the current EWW buffer. The renaming scheme is performed in accordance with @@ -695,7 +715,9 @@ The renaming scheme is performed in accordance with url)) (goto-char (point-min)) (eww-display-html (or encode charset) url nil point buffer)) - ((eww-html-p (car content-type)) + ((or (eww-html-p (car content-type)) + (and eww-use-doctype-fallback + (eww--doctype-html-p data-buffer))) (eww-display-html (or encode charset) url nil point buffer)) ((equal (car content-type) "application/pdf") (eww-display-pdf)) @@ -717,7 +739,7 @@ The renaming scheme is performed in accordance with (setq buffer-undo-list nil))) (kill-buffer data-buffer))) (unless (buffer-live-p buffer) - (kill-buffer data-buffer)))) + (kill-buffer data-buffer))) (defun eww-parse-headers () (let ((headers nil)) -- 2.45.2.windows.1 --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable --=20 Sebasti=E1n Mon=EDa https://site.sebasmonia.com/ --=-=-=--