]> git.eshelyaron.com Git - emacs.git/commitdiff
More lax doctype check in EWW (bug#73133)
authorSebastián Monía <sebastian.monia@sebasmonia.com>
Thu, 24 Oct 2024 17:09:11 +0000 (13:09 -0400)
committerEshel Yaron <me@eshelyaron.com>
Fri, 8 Nov 2024 13:27:42 +0000 (14:27 +0100)
The regexp to match doctype tags was simplified and will match
more legacy entries; also correct binding of 'case-fold-search'.
* lisp/net/eww.el (eww--html buffer-list): Update function.

(cherry picked from commit 6a0c2b8729c436ef4dfecf07737c86936cb94bd5)

lisp/net/eww.el

index 869fe869fffaac08a901643af7488cde4322624d..c7d838c88d1c02eb18890f2b87b3ac650c1d8a60 100644 (file)
@@ -650,15 +650,14 @@ valid Content-Type header.  If none of the functions can guess, return
   "Return \"text/html\" if RESPONSE-BUFFER has an HTML doctype declaration.
 HEADERS is unused."
   ;; https://html.spec.whatwg.org/multipage/syntax.html#the-doctype
-  (let ((case-fold-search t)
-        (target
-         "<!doctype +html *\\(>\\|system +\\(\\\"\\|'\\)+about:legacy-compat\\)"))
-    (with-current-buffer response-buffer
-      (goto-char (point-min))
-      ;; match basic <!doctype html> and also legacy variants as
-      ;; specified in link above
-      (when (re-search-forward target nil t)
-        "text/html"))))
+  (with-current-buffer response-buffer
+    (let ((case-fold-search t))
+      (save-excursion
+        (goto-char (point-min))
+        ;; match basic <!doctype html> and also legacy variants as
+        ;; specified in link above - being purposely lax about it
+        (when (search-forward "<!doctype html" nil t)
+          "text/html")))))
 
 (defun eww--rename-buffer ()
   "Rename the current EWW buffer.