Skip to content

Commit

Permalink
Added the --java option to ronin escape (closes #237).
Browse files Browse the repository at this point in the history
  • Loading branch information
postmodern committed Nov 23, 2024
1 parent 83e8ea1 commit 84020b2
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/escape.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ module Commands
# -H, --html HTML escapes the data
# -u, --uri URI escapes the data
# --http HTTP escapes the data
# -J, --java Java escapes the data
# -j, --js JavaScript escapes the data
# -n, --nodejs Node.js escapes the data
# -S, --shell Escapes the data as a Shell String
Expand Down Expand Up @@ -86,6 +87,12 @@ class Escape < StringMethodsCommand
@method_calls << :http_escape
end

option :java, short: '-J',
desc: 'Java escapes the data' do
require 'ronin/support/encoding/java'
@method_calls << :java_escape
end

option :js, short: '-j',
desc: 'JavaScript escapes the data' do
require 'ronin/support/encoding/js'
Expand Down
3 changes: 3 additions & 0 deletions man/ronin-escape.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ Escapes each special character for a variety of encodings.
`--http`
: HTTP escapes the data.

`-J`, `--java`
: Java escapes the data.

`-j`, `--js`
: JavaScript escapes the data.

Expand Down
12 changes: 12 additions & 0 deletions spec/cli/commands/escape_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,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_escape to #method_calls" do
expect(subject.method_calls.last).to eq(:java_escape)
end
end

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

Expand Down

0 comments on commit 84020b2

Please sign in to comment.