From 6dcca348337c05d33d62da6eeb1f4193b73f4d6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= Date: Fri, 14 Jun 2024 16:55:24 +0200 Subject: [PATCH 1/4] ob-lua: Escape double quote characters in results * lisp/ob-lua.el (org-babel-lua-wrapper-method): Escape all double quote characters in Lua before giving them to Org Babel. * testing/lisp/test-ob-lua.el (test-ob-lua/escaping-quotes): Test automatic escaping of double quote characters. Reported-by: Max Nikulin Link: https://list.orgmode.org/216278dc-075c-47d1-94dc-f5bde8346b3c@gmail.com/ --- lisp/ob-lua.el | 2 +- testing/lisp/test-ob-lua.el | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lisp/ob-lua.el b/lisp/ob-lua.el index 041abfabc..0168bc070 100644 --- a/lisp/ob-lua.el +++ b/lisp/ob-lua.el @@ -283,7 +283,7 @@ function dump(it, indent) end return result else - return tostring(it) + return string.gsub(tostring(it), '\"', '\\\"') end end diff --git a/testing/lisp/test-ob-lua.el b/testing/lisp/test-ob-lua.el index 0a60c68ca..ff69f5411 100644 --- a/testing/lisp/test-ob-lua.el +++ b/testing/lisp/test-ob-lua.el @@ -176,6 +176,12 @@ return x (org-test-with-temp-text "src_lua{return 1, 2, 3}" (org-babel-execute-src-block)))))) +(ert-deftest test-ob-lua/escaping-quotes () + (should + (equal "A \" B" + (org-test-with-temp-text "src_lua{return 'A \" B'}" + (org-babel-execute-src-block))))) + (provide 'test-ob-lua) ;;; test-ob-lua.el ends here -- 2.39.3 (Apple Git-146)