From 15cb99977b7067abf7e9e89bd48e009ee0216b8a Mon Sep 17 00:00:00 2001 From: erwanlr Date: Sat, 28 Dec 2019 13:10:57 +0000 Subject: [PATCH] Fixes #1444 --- app/models/wp_item.rb | 11 +++-------- .../target/platform/wordpress/custom_directories.rb | 4 ++-- spec/app/models/wp_item_spec.rb | 2 +- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/app/models/wp_item.rb b/app/models/wp_item.rb index e001946b..ad67bd20 100644 --- a/app/models/wp_item.rb +++ b/app/models/wp_item.rb @@ -23,7 +23,7 @@ module WPScan # @option opts [ Hash ] :version_detection The options to use when looking for the version # @option opts [ String ] :url The URL of the item def initialize(slug, blog, opts = {}) - @slug = URI.decode(slug) + @slug = Addressable::URI.unencode(slug) @blog = blog @uri = Addressable::URI.parse(opts[:url]) if opts[:url] @@ -83,11 +83,6 @@ module WPScan end end - # URI.encode is preferered over Addressable::URI.encode as it will encode - # leading # character: - # URI.encode('#t#') => %23t%23 - # Addressable::URI.encode('#t#') => #t%23 - # # @param [ String ] path Optional path to merge with the uri # # @return [ String ] @@ -95,7 +90,7 @@ module WPScan return unless @uri return @uri.to_s unless path - @uri.join(URI.encode(path)).to_s + @uri.join(Addressable::URI.encode(path)).to_s end # @return [ Boolean ] @@ -166,7 +161,7 @@ module WPScan # @return [ Typhoeus::Response ] def head_and_get(path, codes = [200], params = {}) final_path = +@path_from_blog - final_path << URI.encode(path) unless path.nil? + final_path << path unless path.nil? blog.head_and_get(final_path, codes, params) end diff --git a/lib/wpscan/target/platform/wordpress/custom_directories.rb b/lib/wpscan/target/platform/wordpress/custom_directories.rb index 3ca40412..d0d85f65 100644 --- a/lib/wpscan/target/platform/wordpress/custom_directories.rb +++ b/lib/wpscan/target/platform/wordpress/custom_directories.rb @@ -71,7 +71,7 @@ module WPScan # # @return [ String ] def plugin_url(slug) - plugins_uri.join("#{URI.encode(slug)}/").to_s + plugins_uri.join("#{Addressable::URI.encode(slug)}/").to_s end # @return [ String ] @@ -93,7 +93,7 @@ module WPScan # # @return [ String ] def theme_url(slug) - themes_uri.join("#{URI.encode(slug)}/").to_s + themes_uri.join("#{Addressable::URI.encode(slug)}/").to_s end # @return [ String, False ] String of the sub_dir found, false otherwise diff --git a/spec/app/models/wp_item_spec.rb b/spec/app/models/wp_item_spec.rb index 38641737..a982575b 100644 --- a/spec/app/models/wp_item_spec.rb +++ b/spec/app/models/wp_item_spec.rb @@ -46,7 +46,7 @@ describe WPScan::Model::WpItem do end it 'encodes the path' do - expect(wp_item.url('#t#')).to eql "#{item_url}%23t%23" + expect(wp_item.url('#t#')).to eql "#{item_url}#t%23" expect(wp_item.url('t .txt')).to eql "#{item_url}t%20.txt" end end