diff --git a/lib/ronin/cli/commands/quote.rb b/lib/ronin/cli/commands/quote.rb index fd25d579d..c30ec2260 100644 --- a/lib/ronin/cli/commands/quote.rb +++ b/lib/ronin/cli/commands/quote.rb @@ -38,6 +38,7 @@ module Commands # -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 + # -n, --nodejs Quotes the data as a Node.js string # -S, --shell Quotes the data as a Shell string # -P, --powershell Quotes the data as a PowerShell string # --perl Quotes the data as a Perl string @@ -70,6 +71,12 @@ class Quote < StringMethodsCommand @method_calls << :java_string end + option :nodejs, short: '-n', + desc: 'Quotes the data as a Node.js string' do + require 'ronin/support/encoding/node_js' + @method_calls << :node_js_string + end + option :js, short: '-j', desc: 'Quotes the data as a JavaScript string' do require 'ronin/support/encoding/js' diff --git a/man/ronin-quote.1.md b/man/ronin-quote.1.md index ae1baf80a..d7fac7db5 100644 --- a/man/ronin-quote.1.md +++ b/man/ronin-quote.1.md @@ -44,6 +44,9 @@ Produces quoted a string for a variety of programming languages. `-j`, `--js` : Quotes the data as a JavaScript string. +`-n`, `--nodejs` +: Quotes the data as a Node.js string. + `-S`, `--shell` : Quotes the data as a Shell string. diff --git a/spec/cli/commands/quote_spec.rb b/spec/cli/commands/quote_spec.rb index 30660f326..ef1c40da8 100644 --- a/spec/cli/commands/quote_spec.rb +++ b/spec/cli/commands/quote_spec.rb @@ -56,6 +56,18 @@ end end + describe "--nodejs" do + let(:argv) { %w[--nodejs] } + + it "must require 'ronin/support/encoding/node_js'" do + expect(require('ronin/support/encoding/node_js')).to be(false) + end + + it "must add :node_js_string to #method_calls" do + expect(subject.method_calls.last).to eq(:node_js_string) + end + end + describe "--shell" do let(:argv) { %w[--shell] }