Class: HomographicSpoofing::Sanitizer::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/homographic_spoofing/sanitizer/base.rb

Direct Known Subclasses

EmailAddress, Idn, QuotedString

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(field) ⇒ Base

Returns a new instance of Base.



8
9
10
# File 'lib/homographic_spoofing/sanitizer/base.rb', line 8

def initialize(field)
  @field = field
end

Class Method Details

.sanitize(field) ⇒ Object



4
5
6
# File 'lib/homographic_spoofing/sanitizer/base.rb', line 4

def self.sanitize(field)
  new(field).sanitize
end

Instance Method Details

#sanitizeObject



12
13
14
15
16
17
18
19
# File 'lib/homographic_spoofing/sanitizer/base.rb', line 12

def sanitize
  result = field.dup
  detector_class.new(field).detections.each do |detection|
    log(detection.reason, detection.label)
    result = punycode(result, detection.label)
  end
  result
end