diff --git a/lisp/ob-core.el b/lisp/ob-core.el index d7f6241cb..082e9bd9e 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -3360,16 +3360,23 @@ situations in which is it not appropriate." (string= cell "*this*"))) ;; FIXME: Arbitrary code evaluation. (eval (read cell) t)) - ((save-match-data - (and (string-match "^[[:space:]]*\"\\(.*\\)\"[[:space:]]*$" cell) - ;; CELL is a single string - (with-temp-buffer - (insert cell) - (goto-char 1) - (read (current-buffer)) - (skip-chars-forward "[:space:]") - (eobp)))) - (read cell)) + ((let (read-val) + (save-match-data + (and (string-match + (rx bos (0+ space) + ?\" (0+ anychar) ?\" + (0+ space) eos) + cell) + ;; CELL is a single string + (with-temp-buffer + (insert cell) + (goto-char 1) + (when (setq read-val + (ignore-errors + (read (current-buffer)))) + (skip-chars-forward "[:space:]") + (eobp))) + read-val)))) (t (org-no-properties cell)))) (defun org-babel--string-to-number (string) diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el index da11258f2..30ce2875c 100644 --- a/testing/lisp/test-ob.el +++ b/testing/lisp/test-ob.el @@ -2599,6 +2599,9 @@ abc ;; Special case: data inside quotes (should (equal "foo" (org-babel-read " \"foo\" " inhibit))) (should (equal "foo with\" inside" (org-babel-read " \"foo with\\\" inside\" " inhibit))) + (should (equal "abc\nsdf" (org-babel-read "\"abc\nsdf\"" inhibit))) + (should (equal "foo" (org-babel-read "\"foo\"" inhibit))) + (should (equal "\"foo\"(\"bar\"" (org-babel-read "\"foo\"(\"bar\"" inhibit))) ;; Unpaired quotes (should (equal "\"foo\"\"bar\"" (org-babel-read "\"foo\"\"bar\"" inhibit)))))