diff options
| -rw-r--r-- | apt-private/private-output.cc | 4 | ||||
| -rwxr-xr-x | test/integration/test-apt-cli-pager | 11 |
2 files changed, 14 insertions, 1 deletions
diff --git a/apt-private/private-output.cc b/apt-private/private-output.cc index e3f795cf3..4480d7382 100644 --- a/apt-private/private-output.cc +++ b/apt-private/private-output.cc @@ -165,7 +165,9 @@ bool InitOutputPager() { // If our pager name contains a space we need to invoke it in a shell. Boooo! char *cmd[] = {(char*)"/bin/sh", (char*)"-c", pager.data(), nullptr}; - if (std::none_of(pager.begin(), pager.end(), isspace_ascii)) + constexpr std::string_view allowed_chars{"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" "+-._=/"}; + static_assert(allowed_chars.size() == 26 + 26 + 10 + 6); + if (pager.find_first_not_of(allowed_chars) == pager.npos) { cmd[0] = pager.data(); cmd[1] = nullptr; diff --git a/test/integration/test-apt-cli-pager b/test/integration/test-apt-cli-pager index 6d0f88f54..d1f8c3288 100755 --- a/test/integration/test-apt-cli-pager +++ b/test/integration/test-apt-cli-pager @@ -17,6 +17,13 @@ setupaptarchive APTARCHIVE=$(readlink -f ./aptarchive) +cat >> head3 << EOF +#!/bin/sh +exec head -3 +EOF + +chmod +x head3 + for show in info show; do msgmsg "$show supports pager" PAGER=cat testsuccessequal "Package: multi @@ -36,6 +43,10 @@ PAGER="head -3" testsuccessequal "Package: multi Version: 2.0 Priority: optional" runapt --unbuffer apt $show multi -o TestPager="head -3" +PAGER="cat|./head3" testsuccessequal "Package: multi +Version: 2.0 +Priority: optional" runapt --unbuffer apt $show multi -o TestPager="head -3" + # Test that we are not blocking PAGER=more testsuccessequal "Package: multi Version: 2.0 |
