Skip to content

Commit a210dbe

Browse files
committed
Add comments about the special handling of the # character.
1 parent 5610d8c commit a210dbe

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/ronin/support/encoding/shell.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,8 @@ def self.quote(data)
262262
if data =~ /[^[:print:]]/
263263
"$'#{escape(data)}'"
264264
else
265+
# NOTE: '$' characters do not need to be escaped in single quoted
266+
# strings, but they *do* need to be escaped in double quoted strings.
265267
"\"#{escape(data).gsub('$','\$')}\""
266268
end
267269
end
@@ -288,6 +290,8 @@ def self.unquote(data)
288290
if (data.start_with?("$'") && data.end_with?("'"))
289291
unescape(data[2..-2])
290292
elsif (data.start_with?('"') && data.end_with?('"'))
293+
# NOTE: double quoted strings only support escaping '"', '\', and
294+
# '$' characters.
291295
data[1..-2].gsub(/\\["\$]/) do |backslash_char|
292296
backslash_char[1]
293297
end

0 commit comments

Comments
 (0)