-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18865 from Homebrew/systemd-quote
Fix systemd command line quoting
- Loading branch information
Showing
4 changed files
with
53 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# frozen_string_literal: true | ||
|
||
require "utils/service" | ||
|
||
RSpec.describe Utils::Service do | ||
describe "::systemd_quote" do | ||
it "quotes empty strings correctly" do | ||
expect(described_class.systemd_quote("")).to eq '""' | ||
end | ||
|
||
it "quotes strings with special characters escaped correctly" do | ||
expect(described_class.systemd_quote("\a\b\f\n\r\t\v\\")) | ||
.to eq '"\\a\\b\\f\\n\\r\\t\\v\\\\"' | ||
expect(described_class.systemd_quote("\"' ")).to eq "\"\\\"' \"" | ||
end | ||
|
||
it "does not escape characters that do not need escaping" do | ||
expect(described_class.systemd_quote("daemon off;")).to eq '"daemon off;"' | ||
expect(described_class.systemd_quote("--timeout=3")).to eq '"--timeout=3"' | ||
expect(described_class.systemd_quote("--answer=foo bar")) | ||
.to eq '"--answer=foo bar"' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters