emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Warn about shell-expansion in the docstring of org-latex-to-html-con


From: Max Nikulin
Subject: Re: Warn about shell-expansion in the docstring of org-latex-to-html-convert-command
Date: Sun, 25 Feb 2024 17:41:43 +0700
User-agent: Mozilla Thunderbird

On 23/02/2024 19:46, Ihor Radchenko wrote:
Max Nikulin <manikulin@gmail.com> writes:

On 19/02/2024 02:36, Martin Edström wrote:
+Since this is a shell-command, remember to use single-quotes
+around \\='%i\\=', not double-quotes!  Else a math fragment such
+as \"$y = 200$\" gets butchered into only \" = 200\"."

I am afraid, the code, not the docstring must be fixed. I have not tried
it, but I expect an issue with

      Test \(f' = df/dx\)

So `shell-quote-argument' is necessary and quotes around %i must be
stripped similar to %s in mailcap entries in `org-open-file'.

That would be backwards-incompatible.
What about introducing %e replacement that will be shell-escaped?

Ihor, it is just a bug and its manifestation depends on content of .org files more than on user configuration. Do you really want to allow part of equations be executed as shell commands for the sake of miracle backward compatibility?

To minimize user annoyance my suggestion is to strip quotes in words like
- '%i'
- "%i"
- 'something%i'
- "something%i"
- something='%i'
- something="%i"
before calling `format-spec' with `shell-quote-argument' result.

Please, revert the commit that added a misleading recommendation.

By the way, single quotes have no special meaning in cmd.exe on windows.

Example of silent error resulting in incorrect equation:

(let ((org-latex-to-html-convert-command
       "printf '%%s' '%i'"))
  (org-format-latex-as-html "$f'' = df/dx$"))
"$f = df/dx$"

Random parts of math becomes part of shell command:

(let ((org-latex-to-html-convert-command
       "printf '%%s' '%i'"))
  (org-format-latex-as-html "$f' = df/dx$"))
"/bin/bash: -c: line 1: unexpected EOF while looking for matching `''
"

Something weird may be executed in the case of sufficiently complex equations.

It should be more reliable to pass fragment to command stdin. It can be done if %i is missed in `org-latex-to-html-convert-command'.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]