Also decode entities like &#x3212
authorLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Sun, 29 Aug 2010 20:16:03 +0000 (22:16 +0200)
committerLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Sun, 29 Aug 2010 20:16:03 +0000 (22:16 +0200)
lisp/ChangeLog
lisp/mm-url.el

index a230e2c..b58b5bd 100644 (file)
@@ -1,3 +1,8 @@
+2010-08-29  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+       * mm-url.el (mm-url-decode-entities): Also decode entities like
+       &#x3212.
+
 2009-07-16  Kevin Ryde  <user42@zip.com.au>  (tiny change)
 
        * gnus-sum.el (gnus-summary-idna-message):
index c963bda..0e7a258 100644 (file)
@@ -365,15 +365,20 @@ If FOLLOW-REFRESH is non-nil, redirect refresh url in META."
 (defun mm-url-decode-entities ()
   "Decode all HTML entities."
   (goto-char (point-min))
-  (while (re-search-forward "&\\(#[0-9]+\\|[a-z]+[0-9]*\\);" nil t)
-    (let ((elem (if (eq (aref (match-string 1) 0) ?\#)
-                       (let ((c (mm-ucs-to-char
-                                 (string-to-number
-                                  (substring (match-string 1) 1)))))
-                         (if (mm-char-or-char-int-p c) c ?#))
-                     (or (cdr (assq (intern (match-string 1))
-                                    mm-url-html-entities))
-                         ?#))))
+  (while (re-search-forward "&\\(#x?[0-9]+\\|[a-z]+[0-9]*\\);" nil t)
+    (let* ((entity (match-string 1))
+          (elem (if (eq (aref entity 0) ?\#)
+                    (let ((c (mm-ucs-to-char
+                              ;; Hex number: &#x3212
+                              (if (eq (aref entity 1) ?x)
+                                  (string-to-number (substring entity 2)
+                                                    16)
+                                ;; Decimal number: &#23
+                                (string-to-number (substring entity 1))))))
+                      (if (mm-char-or-char-int-p c) c ?#))
+                  (or (cdr (assq (intern entity)
+                                 mm-url-html-entities))
+                      ?#))))
       (unless (stringp elem)
        (setq elem (char-to-string elem)))
       (replace-match elem t t))))