Skip to content

Commit

Permalink
Added the --java option to ronin quote (closes #243).
Browse files Browse the repository at this point in the history
  • Loading branch information
postmodern committed Nov 23, 2024
1 parent 1cd2d4f commit 209f2ac
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/ronin/cli/commands/quote.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ module Commands
# -n, --keep-newlines Preserves newlines at the end of each line
# -X, --hex Quotes the data as a Hex string
# -c, --c Quotes the data as a C string
# -J, --java Quotes the data as a Java String
# -j, --js JavaScript quotes the data
# -S, --shell Quotes the data as a Shell String
# -P, --powershell Quotes the data as a PowerShell String
Expand Down Expand Up @@ -63,6 +64,12 @@ class Quote < StringMethodsCommand
@method_calls << :c_string
end

option :java, short: '-J',
desc: 'Quotes the data as a Java String' do
require 'ronin/support/encoding/java'
@method_calls << :java_string
end

option :js, short: '-j',
desc: 'JavaScript quotes the data' do
require 'ronin/support/encoding/js'
Expand Down
3 changes: 3 additions & 0 deletions man/ronin-quote.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ Produces quoted a string for a variety of programming languages.
`-c`, `--c`
: Quotes the data as a C string.

`-J`, `--java`
: Quotes the data as a Java String.

`-j`, `--js`
: quotes the data as a JavaScript string.

Expand Down
12 changes: 12 additions & 0 deletions spec/cli/commands/quote_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@
end
end

describe "--java" do
let(:argv) { %w[--java] }

it "must require 'ronin/support/encoding/java'" do
expect(require('ronin/support/encoding/java')).to be(false)
end

it "must add :java_string to #method_calls" do
expect(subject.method_calls.last).to eq(:java_string)
end
end

describe "--js" do
let(:argv) { %w[--js] }

Expand Down

0 comments on commit 209f2ac

Please sign in to comment.