From e7ea471cd74d07c262b488bf432cda2cd0821176 Mon Sep 17 00:00:00 2001 From: "Michael W. Olson" Date: Tue, 19 Feb 2008 19:41:46 -0600 Subject: [PATCH] Mark some tags as dangerous for text by untrusted contributors. --- ChangeLog | 16 ++++++++++++++++ lisp/muse-html.el | 11 +++++++++++ lisp/muse-latex2png.el | 4 ++++ lisp/muse-poem.el | 2 ++ lisp/muse-publish.el | 18 ++++++++++++++++++ 5 files changed, 51 insertions(+) diff --git a/ChangeLog b/ChangeLog index 989025d..cf2996f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2008-02-19 Michael Olson + + * lisp/muse-html.el (muse-html-src-allowed-modes): New option that + specifies the modes that we permit the tag to colorize. + + * lisp/muse-latex2png.el (muse-publish-latex-tag) + (muse-publish-math-tag): + * lisp/muse-poem.el (muse-poem-markup-tag): + * lisp/muse-publish.el (muse-publish-literal-tag) + (muse-publish-lisp-tag, muse-publish-command-tag) + (muse-publish-perl-tag, muse-publish-php-tag) + (muse-publish-python-tag, muse-publish-ruby-tag) + (muse-publish-include-tag, muse-publish-mark-up-tag): Mark these + tags as potentially dangerous for text written by untrusted + contributors. + 2008-02-10 Michael Olson * lisp/muse-publish.el (muse-publish-enable-local-variables): New diff --git a/lisp/muse-html.el b/lisp/muse-html.el index 497cb66..f8c8efc 100644 --- a/lisp/muse-html.el +++ b/lisp/muse-html.el @@ -416,6 +416,17 @@ This will be used if no special characters are found." :type 'string :group 'muse-html) +(defcustom muse-html-src-allowed-modes t + "Modes that we allow the tag to colorize. +If t, permit the tag to colorize any mode. + +If a list of mode names, such as '(\"html\" \"latex\"), and the +lang argument to is in the list, then use fundamental mode +instead." + :type '(choice (const :tag "Any" t) + (repeat (string :tag "Mode"))) + :group 'muse-html) + (defun muse-html-insert-anchor (anchor) "Insert an anchor, either around the word at point, or within a tag." (skip-chars-forward (concat muse-regexp-blank "\n")) diff --git a/lisp/muse-latex2png.el b/lisp/muse-latex2png.el index f2628b5..6a6c11b 100644 --- a/lisp/muse-latex2png.el +++ b/lisp/muse-latex2png.el @@ -209,6 +209,8 @@ See `muse-latex2png-region' for valid keys for ATTRS." (muse-publish-mark-read-only beg end) (muse-latex2png-region beg end attrs))) +(put 'muse-publish-latex-tag 'muse-dangerous-tag t) + (defun muse-publish-math-tag (beg end) "Surround the given region with \"$\" characters. Then, if the current style is not Latex-based, generate an image for the given @@ -255,6 +257,8 @@ centered in the published output, among other things." (muse-publish-mark-read-only beg (point)) (muse-latex2png-region beg (point) attrs)))) +(put 'muse-publish-math-tag 'muse-dangerous-tag t) + ;;; Insinuate with muse-publish (add-to-list 'muse-publish-markup-tags diff --git a/lisp/muse-poem.el b/lisp/muse-poem.el index cdc0a11..c85cb1c 100644 --- a/lisp/muse-poem.el +++ b/lisp/muse-poem.el @@ -227,6 +227,8 @@ The form of usage is: (forward-line 1)) (set-marker end nil)))) +(put 'muse-poem-markup-tag 'muse-dangerous-tag t) + (add-to-list 'muse-publish-markup-tags muse-poem-tag) ;;; Register the Muse POEM Publishers diff --git a/lisp/muse-publish.el b/lisp/muse-publish.el index 0a537ce..3b36bbc 100644 --- a/lisp/muse-publish.el +++ b/lisp/muse-publish.el @@ -1871,6 +1871,8 @@ is exactly this style." (when (and (bolp) (eolp) (not (eobp))) (delete-char 1))))) +(put 'muse-publish-literal-tag 'muse-dangerous-tag t) + (defun muse-publish-verbatim-tag (beg end) (muse-publish-escape-specials beg end nil 'verbatim) (muse-publish-mark-read-only beg end)) @@ -1986,6 +1988,8 @@ BEG is modified to be the start of the published markup." (set-text-properties 0 (length str) nil str) (insert str)))))) +(put 'muse-publish-lisp-tag 'muse-dangerous-tag t) + (defun muse-publish-command-tag (beg end attrs) (muse-publish-markup-attribute beg end attrs nil (while (looking-at "\\s-*$") @@ -2006,26 +2010,36 @@ BEG is modified to be the start of the published markup." (insert ?\n)) (goto-char (point-min)))) +(put 'muse-publish-command-tag 'muse-dangerous-tag t) + (defun muse-publish-perl-tag (beg end attrs) (muse-publish-command-tag beg end (cons (cons "interp" (executable-find "perl")) attrs))) +(put 'muse-publish-perl-tag 'muse-dangerous-tag t) + (defun muse-publish-php-tag (beg end attrs) (muse-publish-command-tag beg end (cons (cons "interp" (executable-find "php")) attrs))) +(put 'muse-publish-php-tag 'muse-dangerous-tag t) + (defun muse-publish-python-tag (beg end attrs) (muse-publish-command-tag beg end (cons (cons "interp" (executable-find "python")) attrs))) +(put 'muse-publish-python-tag 'muse-dangerous-tag t) + (defun muse-publish-ruby-tag (beg end attrs) (muse-publish-command-tag beg end (cons (cons "interp" (executable-find "ruby")) attrs))) +(put 'muse-publish-ruby-tag 'muse-dangerous-tag t) + (defun muse-publish-comment-tag (beg end) (if (null muse-publish-comments-p) (delete-region beg end) @@ -2053,6 +2067,8 @@ explanation of how it works." (muse-publish-markup-attribute beg end attrs t (muse-insert-file-contents filename)))) +(put 'muse-publish-include-tag 'muse-dangerous-tag t) + (defun muse-publish-mark-up-tag (beg end attrs) "Run an Emacs Lisp function on the region delimted by this tag. @@ -2093,6 +2109,8 @@ current style is exactly this style." (muse-publish-mark-read-only beg (point))) (delete-region beg end)))) +(put 'muse-publish-mark-up-tag 'muse-dangerous-tag t) + ;; Miscellaneous helper functions (defun muse-publish-strip-URL (string &rest ignored) -- 2.11.4.GIT