[gs-commits] ghostpdl branch, master, updated. jbig2dec-0.14-1598-g2447833

[email protected] (Chris Liddell)
Newsgroups gmane.comp.printing.ghostscript.cvs
Message-ID <[email protected]>
The ghostpdl branch, master has been updated
       via  24478335925f891673160893513fac43b0334c48 (commit)
      from  7c9794ee644a904527006922e4fc387ad33be2a4 (commit)

----------------------------------------------------------------------
commit 24478335925f891673160893513fac43b0334c48
Author: Chris Liddell <[email protected]>
Date:   Thu Aug 22 08:58:01 2019 +0100

    Handle explicit '\' escaping in path matching
    
    As well as having to cope with both '/' and '\' as directory separators on
    Windows, it turns out we also need to cope with the backslash separator being
    explicitly escaped ("\\") - the explicit is added by the Postcript path
    templating code in gs_init.ps.
    
    I don't want to change templating code because that would likely have
    implications in a lot of other places.

diff --git a/base/gpmisc.c b/base/gpmisc.c
index 494e165..88a09c6 100644
--- a/base/gpmisc.c
+++ b/base/gpmisc.c
@@ -974,12 +974,22 @@ validate(const gs_memory_t *mem,
                  }
                 /* PATH=abcd pattern=abc */
                 break; /* No match */
-            } else if (*a != *b
-                       && (gs_file_name_check_separator(a, 1, a) == 1
-                       && gs_file_name_check_separator(b, 1, b) == 1)) {
+            } else if (gs_file_name_check_separator(a, 1, a) == 1
+                        && gs_file_name_check_separator(b, 1, b) == 1) {
                 /* On Windows we can get random combinations of "/" and "\" as directory
                  * separators, and we want "C:\" to match C:/" hence using the pair of
-                 * gs_file_name_check_separator() calls */
+                 * gs_file_name_check_separator() calls above */
+                 /* Annoyingly, we can also end up with a combination of explicitly escaped
+                  * '\' characters, and not escaped. So we also need "C:\\" to match "C:\"
+                  * and "C:/" - hence we need to check for, and skip over the
+                  * the extra '\' character - I'm reticent to change the upstream code that
+                  * adds the explicit escape, because that could have unforeseen side effects
+                  * elsewhere. */
+                 if (*(a + 1) != 0 && gs_file_name_check_separator(a + 1, 1, a + 1) == 1)
+                     a++;
+                 if (*(b + 1) != 0 && gs_file_name_check_separator(b + 1, 1, b + 1) == 1)
+                     b++;
+            } else if (*a != *b) {
                 break;
             }
             a++, b++;


Summary of changes:
 base/gpmisc.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.