Module: AntiSamy

Defined in:
lib/antisamy.rb,
lib/antisamy/policy.rb,
lib/antisamy/model/tag.rb,
lib/antisamy/html/handler.rb,
lib/antisamy/html/scanner.rb,
lib/antisamy/scan_results.rb,
lib/antisamy/css/css_filter.rb,
lib/antisamy/css/css_scanner.rb,
lib/antisamy/html/sax_filter.rb,
lib/antisamy/model/attribute.rb,
lib/antisamy/css/css_validator.rb,
lib/antisamy/model/css_property.rb

Defined Under Namespace

Classes: Attribute, CssFilter, CssProperty, CssScanner, CssValidator, Handler, Policy, PolicyError, SaxFilter, ScanError, ScanMessage, ScanResults, Scanner, SchemaError, Stack, Tag

Class Method Summary collapse

Class Method Details

.input_encoding=(encoding) ⇒ Object

Setup the input encoding, defaults to UTF-8



19
20
21
# File 'lib/antisamy.rb', line 19

def input_encoding=(encoding)
  @@input_encoding = encoding
end

.output_encoding=(encoding) ⇒ Object

Setup the output encoding defaults to UTF-8



24
25
26
# File 'lib/antisamy.rb', line 24

def output_encoding=(encoding)
  @@output_encoding = encoding
end

.policy(policy_file) ⇒ Object

Create a policy out of the provided file will use a string or any IO object that can be read will raise an exception if the policy fails to validate



41
42
43
# File 'lib/antisamy.rb', line 41

def policy(policy_file)
  Policy.new(policy_file)
end

.scan(input, policy) ⇒ Object

Scan the input using the provided policy. will raise an exception if there is some form of scannign error



30
31
32
33
34
35
36
# File 'lib/antisamy.rb', line 30

def scan(input,policy)
  scanner = Scanner.new(policy)
  @@input_encoding ||= Scanner::DEFAULT_ENCODE
  @@output_encoding ||=  Scanner::DEFAULT_ENCODE
  clean = scanner.scan(input,@@input_encoding, @output_encoding)
  clean
end