Consistently allow null character in block and drawer bodies

Also, do not use [^\000] as a poor-man's replacement for
(rx (or any newline)).

* lisp/ob-core.el (org-babel-src-block-regexp):
* lisp/ob-haskell.el (org-babel-haskell-export-to-lhs):
* lisp/org-compat.el (org-hide-block-toggle-all):
* lisp/org-element.el:
* lisp/org-feed.el (org-feed-read-previous-status):
(org-feed-parse-rss-feed):
(org-feed-parse-rss-entry):
* lisp/ox-org.el (org-org-publish-to-org):
* testing/lisp/test-ob-tangle.el:
* lisp/org.el (org-block-regexp):
(org-clock-drawer-re): Use \(.\|\n\) regexp instead of [^\000].
(org-latex-regexps): Do not try to match \000 inside latex fragments -
we now use parser for this purpose.

Reported-by: Tommy Kelly <tommy.kelly@verilab.com>
Link: https://orgmode.org/list/875yfk9vlv.fsf@localhost
This commit is contained in:
Ihor Radchenko 2023-04-25 21:06:50 +02:00
parent d97ba5ba52
commit eaf274909f
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
8 changed files with 18 additions and 19 deletions

View File

@ -212,7 +212,7 @@ When matching, reference is stored in match group 1."
;; (4) header arguments ;; (4) header arguments
"\\([^\n]*\\)\n" "\\([^\n]*\\)\n"
;; (5) body ;; (5) body
"\\([^\000]*?\n\\)??[ \t]*#\\+end_src") "\\(\\(?:.\\|\n\\)*?\n\\)??[ \t]*#\\+end_src")
"Regexp used to identify code blocks.") "Regexp used to identify code blocks.")
(defun org-babel--get-vars (params) (defun org-babel--get-vars (params)

View File

@ -226,7 +226,7 @@ constructs (header arguments, no-web syntax etc...) are ignored."
(let* ((contents (buffer-string)) (let* ((contents (buffer-string))
(haskell-regexp (haskell-regexp
(concat "^\\([ \t]*\\)#\\+begin_src[ \t]haskell*\\(.*\\)[\r\n]" (concat "^\\([ \t]*\\)#\\+begin_src[ \t]haskell*\\(.*\\)[\r\n]"
"\\([^\000]*?\\)[\r\n][ \t]*#\\+end_src.*")) "\\(\\(?:.\\|\n\\)*?\\)[\r\n][ \t]*#\\+end_src.*"))
(base-name (file-name-sans-extension (buffer-file-name))) (base-name (file-name-sans-extension (buffer-file-name)))
(tmp-file (org-babel-temp-file "haskell-")) (tmp-file (org-babel-temp-file "haskell-"))
(tmp-org-file (concat tmp-file ".org")) (tmp-org-file (concat tmp-file ".org"))
@ -270,7 +270,7 @@ constructs (header arguments, no-web syntax etc...) are ignored."
(goto-char (point-min)) (forward-line 2) (goto-char (point-min)) (forward-line 2)
(insert "%include polycode.fmt\n") (insert "%include polycode.fmt\n")
;; ensure all \begin/end{code} statements start at the first column ;; ensure all \begin/end{code} statements start at the first column
(while (re-search-forward "^[ \t]+\\\\begin{code}[^\000]+\\\\end{code}" nil t) (while (re-search-forward "^[ \t]+\\\\begin{code}\\(?:.\\|\n\\)+\\\\end{code}" nil t)
(replace-match (save-match-data (org-remove-indentation (match-string 0))) (replace-match (save-match-data (org-remove-indentation (match-string 0)))
t t)) t t))
;; save org exported latex to a .lhs file ;; save org exported latex to a .lhs file

View File

@ -925,7 +925,7 @@ an error. Return a non-nil value when toggling is successful."
(goto-char start) (goto-char start)
(while (and (< (point) end) (while (and (< (point) end)
(re-search-forward "^[ \t]*#\\+begin_?\ (re-search-forward "^[ \t]*#\\+begin_?\
\\([^ \n]+\\)\\(\\([^\n]+\\)\\)?\n\\([^\000]+?\\)#\\+end_?\\1[ \t]*$" end t)) \\([^ \n]+\\)\\(\\([^\n]+\\)\\)?\n\\(\\(?:.\\|\n\\)+?\\)#\\+end_?\\1[ \t]*$" end t))
(save-excursion (save-excursion
(save-match-data (save-match-data
(goto-char (match-beginning 0)) (goto-char (match-beginning 0))

View File

@ -3671,7 +3671,7 @@ a plist with `:key', `:args', `:begin', `:end', `:value' and
Assume point is at the macro." Assume point is at the macro."
(save-excursion (save-excursion
(when (looking-at "{{{\\([a-zA-Z][-a-zA-Z0-9_]*\\)\\((\\([^\000]*?\\))\\)?}}}") (when (looking-at "{{{\\([a-zA-Z][-a-zA-Z0-9_]*\\)\\((\\(\\(?:.\\|\n\\)*?\\))\\)?}}}")
(let ((begin (point)) (let ((begin (point))
(key (downcase (match-string-no-properties 1))) (key (downcase (match-string-no-properties 1)))
(value (match-string-no-properties 0)) (value (match-string-no-properties 0))

View File

@ -475,7 +475,7 @@ This will find DRAWER and extract the alist."
(goto-char pos) (goto-char pos)
(let ((end (save-excursion (org-end-of-subtree t t)))) (let ((end (save-excursion (org-end-of-subtree t t))))
(if (re-search-forward (if (re-search-forward
(concat "^[ \t]*:" drawer ":[ \t]*\n\\([^\000]*?\\)\n[ \t]*:END:") (concat "^[ \t]*:" drawer ":[ \t]*\n\\(\\(?:.\\|\n\\)*?\\)\n[ \t]*:END:")
end t) end t)
(read (match-string 1)) (read (match-string 1))
nil)))) nil))))
@ -633,7 +633,7 @@ containing the properties `:guid' and `:item-full-text'."
end (and (re-search-forward "</item>" nil t) end (and (re-search-forward "</item>" nil t)
(match-beginning 0))) (match-beginning 0)))
(setq item (buffer-substring beg end) (setq item (buffer-substring beg end)
guid (if (string-match "<guid\\>.*?>\\([^\000]*?\\)</guid>" item) guid (if (string-match "<guid\\>.*?>\\(\\(?:.\\|\n\\)*?\\)</guid>" item)
(xml-substitute-special (match-string-no-properties 1 item)))) (xml-substitute-special (match-string-no-properties 1 item))))
(setq entry (list :guid guid :item-full-text item)) (setq entry (list :guid guid :item-full-text item))
(push entry entries) (push entry entries)
@ -647,7 +647,7 @@ containing the properties `:guid' and `:item-full-text'."
(with-temp-buffer (with-temp-buffer
(insert (plist-get entry :item-full-text)) (insert (plist-get entry :item-full-text))
(goto-char (point-min)) (goto-char (point-min))
(while (re-search-forward "<\\([a-zA-Z]+\\>\\).*?>\\([^\000]*?\\)</\\1>" (while (re-search-forward "<\\([a-zA-Z]+\\>\\).*?>\\(\\(?:.\\|\n\\)*?\\)</\\1>"
nil t) nil t)
(setq entry (plist-put entry (setq entry (plist-put entry
(intern (concat ":" (match-string 1))) (intern (concat ":" (match-string 1)))

View File

@ -405,7 +405,7 @@ FULL is given."
;;;; Block ;;;; Block
(defconst org-block-regexp (defconst org-block-regexp
"^[ \t]*#\\+begin_?\\([^ \n]+\\)\\(\\([^\n]+\\)\\)?\n\\([^\000]+?\\)#\\+end_?\\1[ \t]*$" "^[ \t]*#\\+begin_?\\([^ \n]+\\)\\(\\([^\n]+\\)\\)?\n\\(\\(?:.\\|\n\\)+?\\)#\\+end_?\\1[ \t]*$"
"Regular expression for hiding blocks.") "Regular expression for hiding blocks.")
(defconst org-dblock-start-re (defconst org-dblock-start-re
@ -611,7 +611,7 @@ Group 1 contains drawer's name or \"END\".")
"Matches an entire property drawer.") "Matches an entire property drawer.")
(defconst org-clock-drawer-re (defconst org-clock-drawer-re
(concat "\\(" org-clock-drawer-start-re "\\)[^\000]*?\\(" (concat "\\(" org-clock-drawer-start-re "\\)\\(?:.\\|\n\\)*?\\("
org-clock-drawer-end-re "\\)\n?") org-clock-drawer-end-re "\\)\n?")
"Matches an entire clock drawer.") "Matches an entire clock drawer.")
@ -661,14 +661,13 @@ An entry can be toggled between COMMENT and normal with
;;;; LaTeX Environments and Fragments ;;;; LaTeX Environments and Fragments
(defconst org-latex-regexps (defconst org-latex-regexps
'(("begin" "^[ \t]*\\(\\\\begin{\\([a-zA-Z0-9\\*]+\\)[^\000]+?\\\\end{\\2}\\)" 1 t) '(("begin" "^[ \t]*\\(\\\\begin{\\([a-zA-Z0-9\\*]+\\)\\(?:.\\|\n\\)+?\\\\end{\\2}\\)" 1 t)
;; ("$" "\\([ \t(]\\|^\\)\\(\\(\\([$]\\)\\([^ \t\n,.$].*?\\(\n.*?\\)\\{0,5\\}[^ \t\n,.$]\\)\\4\\)\\)\\([ \t.,?;:'\")]\\|$\\)" 2 nil) ;; ("$" "\\([ \t(]\\|^\\)\\(\\(\\([$]\\)\\([^ \t\n,.$].*?\\(\n.*?\\)\\{0,5\\}[^ \t\n,.$]\\)\\4\\)\\)\\([ \t.,?;:'\")]\\|$\\)" 2 nil)
;; \000 in the following regex is needed for org-inside-LaTeX-fragment-p ("$1" "\\([^$]\\|^\\)\\(\\$[^ \t\r\n,;.$]\\$\\)\\(\\s.\\|\\s-\\|\\s(\\|\\s)\\|\\s\"\\|'\\|$\\)" 2 nil)
("$1" "\\([^$]\\|^\\)\\(\\$[^ \t\r\n,;.$]\\$\\)\\(\\s.\\|\\s-\\|\\s(\\|\\s)\\|\\s\"\\|\000\\|'\\|$\\)" 2 nil) ("$" "\\([^$]\\|^\\)\\(\\(\\$\\([^ \t\n,;.$][^$\n\r]*?\\(\n[^$\n\r]*?\\)\\{0,2\\}[^ \t\n,.$]\\)\\$\\)\\)\\(\\s.\\|\\s-\\|\\s(\\|\\s)\\|\\s\"\\|'\\|$\\)" 2 nil)
("$" "\\([^$]\\|^\\)\\(\\(\\$\\([^ \t\n,;.$][^$\n\r]*?\\(\n[^$\n\r]*?\\)\\{0,2\\}[^ \t\n,.$]\\)\\$\\)\\)\\(\\s.\\|\\s-\\|\\s(\\|\\s)\\|\\s\"\\|\000\\|'\\|$\\)" 2 nil) ("\\(" "\\\\(\\(?:.\\|\n\\)*?\\\\)" 0 nil)
("\\(" "\\\\([^\000]*?\\\\)" 0 nil) ("\\[" "\\\\\\[\\(?:.\\|\n\\)*?\\\\\\]" 0 nil)
("\\[" "\\\\\\[[^\000]*?\\\\\\]" 0 nil) ("$$" "\\$\\$\\(?:.\\|\n\\)*?\\$\\$" 0 nil))
("$$" "\\$\\$[^\000]*?\\$\\$" 0 nil))
"Regular expressions for matching embedded LaTeX.") "Regular expressions for matching embedded LaTeX.")
;;;; Node Property ;;;; Node Property

View File

@ -337,7 +337,7 @@ Return output file name."
(when org-org-htmlized-css-url (when org-org-htmlized-css-url
(goto-char (point-min)) (goto-char (point-min))
(and (re-search-forward (and (re-search-forward
"<style type=\"text/css\">[^\000]*?\n[ \t]*</style>.*" nil t) "<style type=\"text/css\">\\(?:.\\|\n\\)*?\n[ \t]*</style>.*" nil t)
(replace-match (replace-match
(format (format
"<link rel=\"stylesheet\" type=\"text/css\" href=\"%s\">" "<link rel=\"stylesheet\" type=\"text/css\" href=\"%s\">"

View File

@ -45,7 +45,7 @@
;; (flet ((exp-p (arg) ;; (flet ((exp-p (arg)
;; (and ;; (and
;; (string-match ;; (string-match
;; (format "noweb-%s-start\\([^\000]*\\)noweb-%s-end" arg arg) ;; (format "noweb-%s-start\\(\\(?:.\\|\n\\)*\\)noweb-%s-end" arg arg)
;; tang) ;; tang)
;; (string-match "expanded" (match-string 1 tang))))) ;; (string-match "expanded" (match-string 1 tang)))))
;; (should (exp-p "yes")) ;; (should (exp-p "yes"))