lib/conjur/escape.rb in conjur-api-2.0.1 vs lib/conjur/escape.rb in conjur-api-2.1.0

- old
+ new

@@ -1,19 +1,22 @@ module Conjur module Escape module ClassMethods def path_escape(str) - return "false" unless str - str = str.id if str.respond_to?(:id) - require 'uri' - URI.escape(str.to_s, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]")) + path_or_query_escape str end def query_escape(str) + path_or_query_escape str + end + + def path_or_query_escape(str) return "false" unless str str = str.id if str.respond_to?(:id) + # Leave colons and forward slashes alone require 'uri' - URI.escape(str.to_s, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]")) + pattern = URI::PATTERN::UNRESERVED + ":\\/@" + URI.escape(str.to_s, Regexp.new("[^#{pattern}]")) end end def self.included(base) base.extend ClassMethods \ No newline at end of file