Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect escaping of quotes for CMD when quoting #998

Merged
merged 5 commits into from
Jun 27, 2023

Commits on Jun 26, 2023

  1. Configuration menu
    Copy the full SHA
    3d4c3c3 View commit details
    Browse the repository at this point in the history

Commits on Jun 27, 2023

  1. Update escaping for quoting for CMD on Windows

    Update the `escapeArgForQuoted` function for CMD, preserving how quoting
    is done. The majority of the old escape logic is gone (except for
    control characters) and is replaced with new logic based first on (of
    all sources) [1] to escape double quotes (which have to be escaped
    somehow because they're also used to do the quoting). In short, the
    rules for escaping quotes are as follows (adapted from [1]):
    1. "For each double quote in the original string, let N be the number
       of backslash(es) before it, N might be zero. Replace these N
       backslash(es) by 2*N+1 backslash(es)."
    2. "Let N be the number of backslash(es) [before a space or tab in] the
       original string, N might be zero. Replace these N backslash(es)
       by 2*N backslash(es)."
    
    Second, based on [2] and experimentation, special characters are escaped
    if and only if they're preceded by an even number (and/including 0) of
    quotes. I can't really tell why this is correct, but from testing it
    appears to be necessary as otherwise the escape character ("^") would
    appear in the argument received by the target program when there's an
    odd number of quotes preceding it.
    
    --
    1. https://www.gnu.org/software/gawk/manual/html_node/DOS-Quoting.html
    2. https://ss64.com/nt/
    ericcornelissen committed Jun 27, 2023
    Configuration menu
    Copy the full SHA
    f466bad View commit details
    Browse the repository at this point in the history
  2. Update the changelog

    ericcornelissen committed Jun 27, 2023
    Configuration menu
    Copy the full SHA
    caa2934 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    aade984 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    0601b74 View commit details
    Browse the repository at this point in the history