Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

CommandBuilder: Use more robust quoting #1540

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

Open
Artoria2e5 wants to merge 11 commits into HMCL-dev:main
base: main
Choose a base branch
Loading
from Artoria2e5:patch-5
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.function.Predicate;
import java.util.regex.Matcher;
Expand Down Expand Up @@ -297,7 +299,14 @@ private static String escape(String str, char... escapeChars) {
}

public static String toBatchStringLiteral(String s) {
return containsEscape(s, " \t\"^&<>|") ? '"' + escape(s, '\\', '"') + '"' : s;
String escape = " \t\"^&<>|?*";
if (containsEscape(s, escape))
// The argument has not been quoted, add quotes.
// See explanation at https://github.com/Artoria2e5/node/blob/fix!/child-process-args/lib/child_process.js
// about making the string "inert to CMD", and associated unit tests
return '"' + s.replaceAll("(\\\\*)($|\")\"", "1ドル1ドル2ドル").replace("\"", "\"\"") + '"';
else
return s;
}

public static String toShellStringLiteral(String s) {
Expand Down

AltStyle によって変換されたページ (->オリジナル) /