all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#20009: eww-render: misrecognizes XHTML (application/xhtml+xml)
@ 2015-03-05 19:45 Ivan Shmakov
  2015-03-05 22:27 ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 2+ messages in thread
From: Ivan Shmakov @ 2015-03-05 19:45 UTC (permalink / raw)
  To: 20009

[-- Attachment #1: Type: text/plain, Size: 541 bytes --]

Package:  emacs
Severity: minor
Tags: patch

	As currently implemented, EWW fails to properly render XHTML
	documents, when served with Content-Type: application/xhtml+xml.
	Consider, e. g.:

    M-x eww RET http://www.x.org/releases/X11R7.7/doc/man/man1/index.xhtml RET

	Please thus consider the patch MIMEd.

	* lisp/net/eww.el (eww-html-p): New function.
	(eww-render): Use it.

	(Tested on 619fc5c197eb, 2015-02-26 18:09:48 UTC.)

-- 
FSF associate member #7257  np. Memento Mori — Kamelot  … 3013 B6A0 230E 334A

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/diff, Size: 1391 bytes --]

--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -300,6 +284,12 @@
   (interactive "r")
   (eww (buffer-substring beg end)))
 
+(defun eww-html-p (content-type)
+  "Return non-nil if CONTENT-TYPE designates an HTML content type.
+Currently this means either text/html or application/xhtml+xml."
+  (string-match-p "^\\(text\\|application\\)/\\(html\\|xhtml\\+xml\\)$"
+		  content-type))
+
 (defun eww-render (status url &optional point buffer encode)
   (let ((redirect (plist-get status :redirect)))
     (when redirect
@@ -318,8 +308,7 @@ defun eww-render (status url &optional point buffer encode)
 	 (charset (intern
 		   (downcase
 		    (or (cdr (assq 'charset (cdr content-type)))
-			(eww-detect-charset (equal (car content-type)
-						   "text/html"))
+			(eww-detect-charset (eww-html-p (car content-type)))
 			"utf-8"))))
 	 (data-buffer (current-buffer)))
     ;; Save the https peer status.
@@ -332,7 +321,7 @@ defun eww-render (status url &optional point buffer encode)
                  (string-match-p eww-use-external-browser-for-content-type
                                  (car content-type)))
             (eww-browse-with-external-browser url))
-	   ((equal (car content-type) "text/html")
+	   ((eww-html-p (car content-type))
 	    (eww-display-html charset url nil point buffer encode))
 	   ((equal (car content-type) "application/pdf")
 	    (eww-display-pdf))

^ permalink raw reply	[flat|nested] 2+ messages in thread

* bug#20009: eww-render: misrecognizes XHTML (application/xhtml+xml)
  2015-03-05 19:45 bug#20009: eww-render: misrecognizes XHTML (application/xhtml+xml) Ivan Shmakov
@ 2015-03-05 22:27 ` Lars Magne Ingebrigtsen
  0 siblings, 0 replies; 2+ messages in thread
From: Lars Magne Ingebrigtsen @ 2015-03-05 22:27 UTC (permalink / raw)
  To: Ivan Shmakov; +Cc: 20009

Ivan Shmakov <ivan@siamics.net> writes:

> 	* lisp/net/eww.el (eww-html-p): New function.
> 	(eww-render): Use it.

Thanks.  I've applied a variant of your patch.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-03-05 22:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-05 19:45 bug#20009: eww-render: misrecognizes XHTML (application/xhtml+xml) Ivan Shmakov
2015-03-05 22:27 ` Lars Magne Ingebrigtsen

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.