Sha256: 817c7402bb88126346c96159e02cd55a203d90613baa10458c597162db791d3c

Contents?: true

Size: 904 Bytes

Versions: 12

Compression:

Stored size: 904 Bytes

Contents

module Conjur
  module Escape
    module ClassMethods
      def fully_escape(str)
        require 'cgi'
        CGI.escape(str.to_s)
      end
      
      def path_escape(str)
        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'
        pattern = URI::PATTERN::UNRESERVED + ":\\/@"
        URI.escape(str.to_s, Regexp.new("[^#{pattern}]"))
      end
    end
    
    def self.included(base)
      base.extend ClassMethods
    end
    
    def fully_escape(str)
      self.class.fully_escape str
    end

    def path_escape(str)
      self.class.path_escape str
    end

    def query_escape(str)
      self.class.query_escape str
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
conjur-api-2.7.1 lib/conjur/escape.rb
conjur-api-2.5.1 lib/conjur/escape.rb
conjur-api-2.4.0 lib/conjur/escape.rb
conjur-api-2.3.1 lib/conjur/escape.rb
conjur-api-2.2.3 lib/conjur/escape.rb
conjur-api-2.2.2 lib/conjur/escape.rb
conjur-api-2.2.1 lib/conjur/escape.rb
conjur-api-2.1.8 lib/conjur/escape.rb
conjur-api-2.1.7 lib/conjur/escape.rb
conjur-api-2.1.6 lib/conjur/escape.rb
conjur-api-2.1.5 lib/conjur/escape.rb
conjur-api-2.1.4 lib/conjur/escape.rb