summaryrefslogtreecommitdiff
path: root/lisp/international
diff options
context:
space:
mode:
authorRomain Francoise <romain@orebokech.com>2007-01-05 17:58:02 +0000
committerRomain Francoise <romain@orebokech.com>2007-01-05 17:58:02 +0000
commit129f19896b1b328a510a999a3511f3ab547ec759 (patch)
treeda2e598af888cf735d589fb7de5e9476e74279e0 /lisp/international
parentab3aad87d91e8b56d2abc95436b68ab4ad73c332 (diff)
downloademacs-129f19896b1b328a510a999a3511f3ab547ec759.tar.gz
(sgml-html-meta-auto-coding-function): Ensure that the buffer contains a
HTML document.
Diffstat (limited to 'lisp/international')
-rw-r--r--lisp/international/mule.el7
1 files changed, 6 insertions, 1 deletions
diff --git a/lisp/international/mule.el b/lisp/international/mule.el
index ddaacfe7216..954146453ed 100644
--- a/lisp/international/mule.el
+++ b/lisp/international/mule.el
@@ -2292,7 +2292,12 @@ This function is intended to be added to `auto-coding-functions'."
;; In case of no header, search only 10 lines.
(forward-line 10))
(point))))
- (when (re-search-forward "<meta\\s-+http-equiv=[\"']?content-type[\"']?\\s-+content=[\"']text/\\sw+;\\s-*charset=\\(.+?\\)[\"']" size t)
+ ;; Make sure that the buffer really contains an HTML document, by
+ ;; checking that it starts with a doctype or a <HTML> start tag
+ ;; (allowing for whitespace at bob). Note: 'DOCTYPE NETSCAPE' is
+ ;; useful for Mozilla bookmark files.
+ (when (and (re-search-forward "\\`[[:space:]\n]*\\(<!doctype[[:space:]\n]+\\(html\\|netscape\\)\\|<html\\)" size t)
+ (re-search-forward "<meta\\s-+http-equiv=[\"']?content-type[\"']?\\s-+content=[\"']text/\\sw+;\\s-*charset=\\(.+?\\)[\"']" size t))
(let* ((match (match-string 1))
(sym (intern (downcase match))))
(if (coding-system-p sym)