Hi,
From my understanding, there are some superfluous quotes in context/base/mkiv/grph-con.lua, cancelling the proper quoting done by validcommand in context/base/mkiv/util-sbx.lua.
For my document, it tries to run something like (the space in the 'Google Drive' directory breaks the generation): inkscape ""[...]/Google Drive/[...].svg"" --export-dpi=600 --export-pdf=""[...]/Google Drive/[...].svg.pdf"" Applying this patch fixes the double quotes issue: local runner = sandbox.registerrunner { name = "svg to something", program = "inkscape", template = longtostring [[ - "%oldname%" + %oldname% --export-dpi=%resolution% - --export-%format%="%newname%" + --export-%format%=%newname% ]], However, it seems there are more similar quotes in the other templates of the file. mtx-context | current version: 2019.04.16 08:54 (I hope this is the proper way of reporting.) Regards.
On 4/19/2019 9:06 PM, Kevin Boulain wrote:
Hi,
From my understanding, there are some superfluous quotes in context/base/mkiv/grph-con.lua, cancelling the proper quoting done by validcommand in context/base/mkiv/util-sbx.lua.
For my document, it tries to run something like (the space in the 'Google Drive' directory breaks the generation): inkscape ""[...]/Google Drive/[...].svg"" --export-dpi=600 --export-pdf=""[...]/Google Drive/[...].svg.pdf""
Applying this patch fixes the double quotes issue: local runner = sandbox.registerrunner { name = "svg to something", program = "inkscape", template = longtostring [[ - "%oldname%" + %oldname% --export-dpi=%resolution% - --export-%format%="%newname%" + --export-%format%=%newname% ]],
However, it seems there are more similar quotes in the other templates of the file.
I'm a bit reluctant to change this as it can break existing workflows. What if you use "%[oldname]%" and don't feed an quoted argument?
mtx-context | current version: 2019.04.16 08:54
(I hope this is the proper way of reporting.)
Regards. _______________________________________________ dev-context mailing list dev-context@ntg.nl https://mailman.ntg.nl/mailman/listinfo/dev-context
-- ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
I'm a bit reluctant to change this as it can break existing workflows.
I understand the motivation but I don't understand the technical reason. This seems to be a simple shell quoting problem to me. I'm an inexperienced ConTeXt/TeX user though, so feel free to tell me I'm utterly wrong :)
What if you use "%[oldname]%" and don't feed an quoted argument?
I'm not sure I understood: I'm not feeding a quoted argument, grph-con.lua introduces superfluous quotes, breaking the proper quoting introduced later by util-sbx.lua (since the shell is used to spawn the process). Let me try to explain it a little bit better. Here is a minimal reproduction (needs Inkscape installed): dir="/tmp/s p a c e s" mkdir -p "$dir" cat > "$dir/test.svg" << EOF <?xml version="1.0" standalone="no"?> <svg width="100" height="100" version="1.1" xmlns="http://www.w3.org/2000/svg"> <rect x="10" y="10" width="80" height="80"/> </svg> EOF cat > "$dir/test.tex" << EOF \defineexternalfigure[test][height=1cm] \starttext \externalfigure[test.svg][test] \stoptext EOF (cd "$dir" && context test.tex) 1/ With an unpatched ConTeXt, the Inkscape command line is: inkscape ""/private/tmp/s p a c e s/test.svg"" --export-dpi=600 --export-pdf=""/private/tmp/s p a c e s/m_k_i_v_test.svg.pdf"" So Inkscape can't find the file because the shell actually gives multiple parameters (some parts omitted for brevity): ** (inkscape-bin:8703): WARNING **: Can't open file: /private/tmp/s (doesn't exist) ** (inkscape-bin:8703): WARNING **: Specified document /private/tmp/s cannot be opened (does not exist or not a valid SVG file) ** (inkscape-bin:8703): WARNING **: Can't open file: p (doesn't exist) ** (inkscape-bin:8703): WARNING **: Specified document p cannot be opened (does not exist or not a valid SVG file) ** (inkscape-bin:8703): WARNING **: Can't open file: a (doesn't exist) [...] 2/ With the proposed "%[oldname]%" patch: template = longtostring [[ - "%oldname%" + "%[oldname]%" --export-dpi=%resolution% - --export-%format%="%newname%" + --export-%format%="%[newname]%" ]], The Inkscape command line is: inkscape "\"/private/tmp/s p a c e s/test.svg\"" --export-dpi=600 --export-pdf="\"/private/tmp/s p a c e s/m_k_i_v_test.svg.pdf\"" Now, Inkscape will complain because we added quotes to the path itself: ** (inkscape-bin:9113): WARNING **: Can't open file: "/private/tmp/s p a c e s/test.svg" (doesn't exist) ** (inkscape-bin:9113): WARNING **: Specified document "/private/tmp/s p a c e s/test.svg" cannot be opened (does not exist or not a valid SVG file) 3/ With my first patch, spaces in the path or even double quotes in filenames are now properly handled. Probably all of the conversion routines in grph-con.lua must be patched similarly. The Inkscape command line is: inkscape "/private/tmp/s p a c e s/test.svg" --export-dpi=600 --export-pdf="/private/tmp/s p a c e s/m_k_i_v_test.svg.pdf" I hope I was a bit clearer this time. Thanks.
On 4/21/2019 1:04 PM, Kevin Boulain wrote:
I'm a bit reluctant to change this as it can break existing workflows.
I understand the motivation but I don't understand the technical reason. This seems to be a simple shell quoting problem to me. I'm an inexperienced ConTeXt/TeX user though, so feel free to tell me I'm utterly wrong :)
What if you use "%[oldname]%" and don't feed an quoted argument?
I'm not sure I understood: I'm not feeding a quoted argument, grph-con.lua introduces superfluous quotes, breaking the proper quoting introduced later by util-sbx.lua (since the shell is used to spawn the process). Let me try to explain it a little bit better. Ok, but then the issue is not the name only
\enabletrackers[sandbox] the sandbox runner always wraps so then we also need to remove quotes in --export-%format%=%newname% and such. (The original runners didn't do escaping.) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
\enabletrackers[sandbox]
I didn't know about that one (I was print debugging in util-sbx.lua...), thanks.
the sandbox runner always wraps so then we also need to remove quotes in
--export-%format%=%newname%
and such. (The original runners didn't do escaping.)
Yes, this exactly what I was thinking about (see first patch) and it should address your concerns about being backward compatible too. That's also true for the others runners in the file (but I don't know if the parameters like %color% and %rgbprofile% relies on this behavior).
participants (2)
-
Hans Hagen
-
Kevin Boulain