[Lldb-commits] [PATCH] D104629: [lldb] Escape semicolons for all shells
Jonas Devlieghere via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Tue Apr 12 18:14:07 PDT 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG07a722c574d1: [lldb] Escape semicolons for all shells (authored by teemperor, committed by JDevlieghere).
Herald added a subscriber: lldb-commits.
Herald added a project: All.
Changed prior to commit:
https://reviews.llvm.org/D104629?vs=353318&id=422375#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D104629/new/
https://reviews.llvm.org/D104629
Files:
lldb/source/Utility/Args.cpp
lldb/unittests/Utility/ArgsTest.cpp
Index: lldb/unittests/Utility/ArgsTest.cpp
===================================================================
--- lldb/unittests/Utility/ArgsTest.cpp
+++ lldb/unittests/Utility/ArgsTest.cpp
@@ -328,14 +328,25 @@
// Normal characters and expressions that shouldn't be escaped.
EXPECT_EQ(Args::GetShellSafeArgument(zsh, "aA$1*"), "aA$1*");
- // String that doesn't need to be escaped
- EXPECT_EQ(Args::GetShellSafeArgument(bash, "a"), "a");
+ // Test escaping bash special characters.
+ EXPECT_EQ(Args::GetShellSafeArgument(bash, R"( '"<>()&;)"),
+ R"(\ \'\"\<\>\(\)\&\;)");
+ // Normal characters and globbing expressions that shouldn't be escaped.
+ EXPECT_EQ(Args::GetShellSafeArgument(bash, "aA$1*"), "aA$1*");
- // Try escaping with tcsh and the tcsh-specific "$" escape.
+ // Test escaping tcsh special characters.
FileSpec tcsh("/bin/tcsh", FileSpec::Style::posix);
- EXPECT_EQ(Args::GetShellSafeArgument(tcsh, "a$b"), "a\\$b");
- // Bash however doesn't need escaping for "$".
- EXPECT_EQ(Args::GetShellSafeArgument(bash, "a$b"), "a$b");
+ EXPECT_EQ(Args::GetShellSafeArgument(tcsh, R"( '"<>()&$;)"),
+ R"(\ \'\"\<\>\(\)\&\$\;)");
+ // Normal characters and globbing expressions that shouldn't be escaped.
+ EXPECT_EQ(Args::GetShellSafeArgument(tcsh, "aA1*"), "aA1*");
+
+ // Test escaping sh special characters.
+ FileSpec sh("/bin/sh", FileSpec::Style::posix);
+ EXPECT_EQ(Args::GetShellSafeArgument(sh, R"( '"<>()&;)"),
+ R"(\ \'\"\<\>\(\)\&\;)");
+ // Normal characters and globbing expressions that shouldn't be escaped.
+ EXPECT_EQ(Args::GetShellSafeArgument(sh, "aA$1*"), "aA$1*");
// Try escaping with an unknown shell.
FileSpec unknown_shell("/bin/unknown_shell", FileSpec::Style::posix);
Index: lldb/source/Utility/Args.cpp
===================================================================
--- lldb/source/Utility/Args.cpp
+++ lldb/source/Utility/Args.cpp
@@ -384,10 +384,10 @@
llvm::StringRef m_escapables;
};
- static ShellDescriptor g_Shells[] = {{ConstString("bash"), " '\"<>()&"},
- {ConstString("tcsh"), " '\"<>()&$"},
+ static ShellDescriptor g_Shells[] = {{ConstString("bash"), " '\"<>()&;"},
+ {ConstString("tcsh"), " '\"<>()&$;"},
{ConstString("zsh"), " '\"<>()&;\\|"},
- {ConstString("sh"), " '\"<>()&"}};
+ {ConstString("sh"), " '\"<>()&;"}};
// safe minimal set
llvm::StringRef escapables = " '\"";
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104629.422375.patch
Type: text/x-patch
Size: 2616 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220413/2ef5e3eb/attachment.bin>
More information about the lldb-commits
mailing list