Skip to content
  • Vasily Galkin's avatar
    gspawn, win32: quoted args - escape end backslash · 22e875f7
    Vasily Galkin authored
    According to msdn documentation last backslash(es) of quoted argument
    in a win32 cmdline need to be escaped, since they are
    directly preceding quote in the resulting string:
    https://docs.microsoft.com/en-us/cpp/c-language/parsing-c-command-line-arguments
    
    Glib <=2.58.0 passed children arguments like C:\Program Files\
    without escaping last backslash(es).
    So it had been passed as "C:\Program Files\"
    windows command line parsing treated this as escaped quote,
    and later text was treated as argument continuation instead of separate
    arguments.
    
    Existing implementation wasn't easily adoptable to fix this problem,
    so escaping logic was rewritten.
    Since the resulting length need to be increased due to extra escaping
    it was rewritten too. Now the calculated length assumes that all
    escapable chars would be escaped in a resulting string,
    so the length may be a bit bigger than actually needed,
    since backslashes not preceding quotes are not escaped.
    
    This fixes the glib...
    22e875f7