AMP_Blacklist_Sanitizer::sanitize PHP Method

sanitize() public method

public sanitize ( )
    public function sanitize()
    {
        $blacklisted_tags = $this->get_blacklisted_tags();
        $blacklisted_attributes = $this->get_blacklisted_attributes();
        $blacklisted_protocols = $this->get_blacklisted_protocols();
        $body = $this->get_body_node();
        $this->strip_tags($body, $blacklisted_tags);
        $this->strip_attributes_recursive($body, $blacklisted_attributes, $blacklisted_protocols);
    }

Usage Example

 /**
  * @dataProvider get_data
  */
 public function test_sanitizer($source, $expected)
 {
     $dom = AMP_DOM_Utils::get_dom_from_content($source);
     $sanitizer = new AMP_Blacklist_Sanitizer($dom);
     $sanitizer->sanitize();
     $content = AMP_DOM_Utils::get_content_from_dom($dom);
     $this->assertEquals($expected, $content);
 }