commit 3e9a1c2da7afb6a557df884121041bd1b1586e0a
Author: Enrico Forestieri <for...@lyx.org>
Date:   Fri Dec 14 11:41:16 2018 +0100

    Fix bug #9622
    
    The backslash is the escape character used in our parser. Hence,
    when used as a path separator on Windows, it has to be itself
    escaped or the path enclosed in either double or single quotes.
    Windows users are maybe trained to quote paths containing spaces
    but not paths with backslashes. So, we automatically escape the
    backslashes when they are not already enclosed in quotes.
    
    (cherry picked from commit 4c9df62c6cb8168d8d129f2c5f6a16ba7e895f63)
---
 src/Format.cpp |   22 ++++++++++++++++++++++
 status.23x     |    2 ++
 2 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/src/Format.cpp b/src/Format.cpp
index 3b3a10d..51dd054 100644
--- a/src/Format.cpp
+++ b/src/Format.cpp
@@ -697,6 +697,28 @@ bool Formats::view(Buffer const & buffer, FileName const & 
filename,
 
        string command = format->viewer();
 
+       // Escape backslashes if not already in double or single quotes.
+       // We cannot simply quote the whole command as there may be arguments.
+       if (contains(command, '\\')) {
+               bool inquote1 = false;
+               bool inquote2 = false;
+               string::iterator cit = command.begin();
+               for (; cit != command.end(); ++cit) {
+                       switch (*cit) {
+                       case '"':
+                               inquote1 = !inquote1;
+                               break;
+                       case '\'':
+                               inquote2 = !inquote2;
+                               break;
+                       case '\\':
+                               if (!inquote1 && !inquote2)
+                                       cit = ++command.insert(cit, '\\');
+                               break;
+                       }
+               }
+       }
+
        if (format_name == "dvi" &&
            !lyxrc.view_dvi_paper_option.empty()) {
                string paper_size = 
buffer.params().paperSizeName(BufferParams::XDVI);
diff --git a/status.23x b/status.23x
index f979769..8eaa54b 100644
--- a/status.23x
+++ b/status.23x
@@ -61,6 +61,8 @@ What's new
 - Fix on-screen display of macros whose name is a single non-letter symbol
   (part of bug 11158).
 
+- Do not swallow backspaces in custom viewer/editor paths (bug 9622).
+
 
 * INTERNALS
 

Reply via email to