Skip to content

Commit 1f7e27c

Browse files
committed
- Sanitize percent signs in help messages
1 parent 234fa84 commit 1f7e27c

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/bashly/extensions/string.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class String
22
def sanitize_for_print
3-
gsub("\n", '\\n').gsub('"', '\"').gsub('`', '\\\\`')
3+
gsub("\n", '\\n').gsub('"', '\"').gsub('`', '\\\\`').gsub('%', '%%')
44
end
55

66
def for_markdown

spec/bashly/extensions/string_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
describe String do
22
describe '#sanitize_for_print' do
3-
subject { "this is\na \"new line\" with `backticks`" }
3+
subject { "this is\na \"new line\" with `backticks` and % symbol" }
44

55
it 'escapes newlines and quotes' do
6-
expect(subject.sanitize_for_print).to eq 'this is\\na \"new line\" with \`backticks\`'
6+
expect(subject.sanitize_for_print).to eq 'this is\\na \"new line\" with \`backticks\` and %% symbol'
77
end
88
end
99

0 commit comments

Comments
 (0)