Module: Plato::HeadersCodec::Sanitize

Extended by:
Sanitize
Included in:
Sanitize
Defined in:
lib/plato/headers_codec.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, value) ⇒ Object



66
67
68
69
# File 'lib/plato/headers_codec.rb', line 66

def method_missing(method, value)
  warn "Warning: not sanitizing #{method}."
  value.to_s
end

Instance Method Details

#body(body) ⇒ Object



62
63
64
# File 'lib/plato/headers_codec.rb', line 62

def body(body)
  body # do we really need to do anything here?
end

#header(header_val) ⇒ Object



54
55
56
# File 'lib/plato/headers_codec.rb', line 54

def header(header_val)
  header_val.gsub(/(\r|\n)/) {|m| {"\r" => '\r', "\n" => '\n'}[m] }
end

#path_elem(elem) ⇒ Object



58
59
60
# File 'lib/plato/headers_codec.rb', line 58

def path_elem(elem)
  elem.to_s.gsub(/\s+/, '_').gsub(/[^a-zA-Z0-9_-]/,'')
end