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:43:36 -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="19842"; 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:26:34 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 1ssltR-0004zA-2l for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 23 Sep 2024 18:26:34 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sslt3-0005eg-7a; Mon, 23 Sep 2024 12:26:09 -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 1sslsZ-0003SK-T5 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-00015k-Jq for bug-gnu-emacs@gnu.org; Mon, 23 Sep 2024 12:25:39 -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=4aES1+zv73t1xz1g/9Bw789YRidPYl/OjD9m04FVMkQ=; b=kqbalzBeVhPuAflVI3yMESXcfp3hE4GCNNfFUEDicm8BxkSAxZHwznSM6drz3MxJTmRNXYhKtdZjpxRLFxEy8ix3LBjiwRuO7QB4n1W0gAUBO1oYJ6pH6tN0f/Xj6fKnvOFiN3e8UnCXAgbPoMv/NdiiyZ08m9eY/6JKQ1AHKI33Kin38gTFHIrR1WQ6Rqk6U1JHz45Vg5f6XuC358IYcOJMkcZ9vzxRqyesv/E0xPHfQs2reQ3MFKHyVUcsnNXsIcOfTCAAK0KN2wpZHW8bQSC7flkZqirQYefHHa9s7ubsMDrU/i7uLpape0JS1tFetxRoJtAxH5WIGOCPK2Bhtw==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sslsw-0007b9-IQ for bug-gnu-emacs@gnu.org; Mon, 23 Sep 2024 12:26:02 -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:02 +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.172710873228987 (code B ref 73133); Mon, 23 Sep 2024 16:26:02 +0000 Original-Received: (at 73133) by debbugs.gnu.org; 23 Sep 2024 16:25:32 +0000 Original-Received: from localhost ([127.0.0.1]:44672 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sslsO-0007UW-MB for submit@debbugs.gnu.org; Mon, 23 Sep 2024 12:25:32 -0400 Original-Received: from fhigh-a5-smtp.messagingengine.com ([103.168.172.156]:59905) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sslEL-00058U-G2 for 73133@debbugs.gnu.org; Mon, 23 Sep 2024 11:44:08 -0400 Original-Received: from phl-compute-08.internal (phl-compute-08.phl.internal [10.202.2.48]) by mailfhigh.phl.internal (Postfix) with ESMTP id 18EF3114020B; Mon, 23 Sep 2024 11:43:37 -0400 (EDT) Original-Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-08.internal (MEProxy); Mon, 23 Sep 2024 11:43:37 -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=1727106217; x= 1727192617; bh=4aES1+zv73t1xz1g/9Bw789YRidPYl/OjD9m04FVMkQ=; b=n o0LhjE35gzO91f0IBFIE3tdDtqo6NdfXUGtmAk7Byi42razxkJiTkUctMWcz8tYS X5JSVYTfsLZ1TA9JcUtqKaMAKvP5K3TqKMWLcWuBsCqyBDqBGoyJgZGTPsGgQI7h ccN7gZVhPMmBEZm5QL82jXxcAWar8tPwTuqVX3IBNMlbLex5ccGh/8kPukCUJfui wFvz8B/0E7Vs5PnSpou//I720exwsoP5+q2zGiC3YKXvMojskNCY17rDEFaVPThR brGgy6mmKbjdi2fz9dCDJZDIv+4EOo4v5BtAw/pahMVYrqqG4RDwLsIhCQc2VPnY hotODg2WEwjyv/qD+wv4A== 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=1727106217; x=1727192617; bh=4aES1+zv73t1xz1g/9Bw789YRidP Yl/OjD9m04FVMkQ=; b=MzAI8MNSK5NWA7gyX94m0ymsTr5wBZOKkrgt0FJWWVHd inPcwibnAlkGY7LGggYvR+SDoX0IKuMjRRD1VnhOJdRt74rvIzQrjq22pKLc2QA4 W7EEr9IiWd9RBp8PBQ4FBdoAPpwsxgC+53dXyU7nWEOzk9CybNB5jSIuK69S2VZf qN5GTXAwIUYSgpABACjAOtmET4sJZ6vs9b+cYGg3peJpVzOasnPSoSzTo5pfgNsr u/rQ699hVOq4vzW2UqUhggIwsqyYdex8VkoZVr0zdpDtrnDf5lhCUD2+667QT45V 1O77lQaaar64YmTj1NxIgAXotrvBi9nrEZxxRDfj7A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudelledgleefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhephffvvefujghffffkfgggtgesmhdtreertderuden ucfhrhhomhepufgvsggrshhtihojnhcuofhonhovrgcuoehsvggsrghsthhirghnsehsvg gsrghsmhhonhhirgdrtghomheqnecuggftrfgrthhtvghrnhepfeejteehheelkeetffdv gfejtdethffhfeeuieffgfffffdtjeejudduhfeigfevnecuffhomhgrihhnpehrfhgtqd gvughithhorhdrohhrghenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgr ihhlfhhrohhmpehsvggsrghsthhirghnsehsvggsrghsmhhonhhirgdrtghomhdpnhgspg hrtghpthhtohepgedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepghgrnhhimhgr rhgusehtuhhtrgdrihhopdhrtghpthhtohepjeefudeffeesuggvsggsuhhgshdrghhnuh drohhrghdprhgtphhtthhopegvlhhiiiesghhnuhdrohhrghdprhgtphhtthhopehjphho rhhtvghrsghughhsse X-ME-Proxy: Feedback-ID: iab2c46da:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 23 Sep 2024 11:43:36 -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:292286 Archived-At: --=-=-= Content-Type: text/plain Jim Porter writes: > On 9/21/2024 2:13 AM, Eli Zaretskii wrote: >>> Date: Mon, 9 Sep 2024 23:06:56 -0700 >>> From: Jim Porter >>> >>> From my reading of RFC9110[1], this is *technically* a bug (we should >>> assume application/octet-stream, not text/plain), but that wouldn't fix >>> the rendering here; it would probably make things worse. However, per >>> the RFC, EWW would be within its rights to guess that the page is HTML, >>> e.g. by checking for "". It also recommends having that >>> be an option that can be disabled, which is reasonable (and in keeping >>> with Emacs's design principles anyway). >>> >>> [1] https://www.rfc-editor.org/rfc/rfc9110#section-8.3-5 >> Thanks. Would someone like to submit a patch along these lines? > > It'll probably be a couple weeks until I have time to write a patch, > but if no one has done so by then, I'll look into it. Would the patch attached work? --=-=-= 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/ --=-=-=--