Class: SecureHeaders::XXssProtection

Inherits:
Header
  • Object
show all
Includes:
Constants
Defined in:
lib/secure_headers/headers/x_xss_protection.rb

Defined Under Namespace

Modules: Constants

Constant Summary

Constants included from Constants

Constants::CONFIG_KEY, Constants::DEFAULT_VALUE, Constants::VALID_X_XSS_HEADER, Constants::X_XSS_PROTECTION_HEADER_NAME

Instance Method Summary collapse

Constructor Details

#initialize(config = nil) ⇒ XXssProtection

Returns a new instance of XXssProtection.



12
13
14
15
# File 'lib/secure_headers/headers/x_xss_protection.rb', line 12

def initialize(config=nil)
  @config = config
  validate_config unless @config.nil?
end

Instance Method Details

#nameObject



17
18
19
# File 'lib/secure_headers/headers/x_xss_protection.rb', line 17

def name
  X_XSS_PROTECTION_HEADER_NAME
end

#valueObject



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/secure_headers/headers/x_xss_protection.rb', line 21

def value
  case @config
  when NilClass
    DEFAULT_VALUE
  when String
    @config
  else
    value = @config[:value].to_s
    value += "; mode=#{@config[:mode]}" if @config[:mode]
    value += "; report=#{@config[:report_uri]}" if @config[:report_uri]
    value
  end
end