PHPIDS
Current file: /home/mario/workspace/php-ids.org/trunk/lib/IDS/vendors/htmlpurifier/HTMLPurifier/URIDefinition.php
Legend: executed not executed dead code

  Coverage
  Classes Methods Lines
Total
100.00 %100.00%
100.00% 1 / 1
25.00 %25.00%
25.00% 2 / 8
19.51 %19.51%
19.51% 8 / 41
 
HTMLPurifier_URIDefinition
100.00 %100.00%
100.00% 1 / 1
25.00 %25.00%
25.00% 2 / 8
19.51 %19.51%
19.51% 8 / 41
 public function __construct()
0.00 %0.00%
0.00% 0 / 1
100.00 %100.00%
100.00% 0 / 0
 public function registerFilter($filter)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 2
 public function addFilter($filter, $config)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 7
 protected function doSetup($config)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 3
 protected function setupFilters($config)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 8
 protected function setupMemberVariables($config)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 10
 public function filter(&$uri, $config, $context)
100.00 %100.00%
100.00% 1 / 1
100.00 %100.00%
100.00% 5 / 5
 public function postFilter(&$uri, $config, $context)
100.00 %100.00%
100.00% 1 / 1
40.00 %40.00%
40.00% 2 / 5


       1                 : <?php                                                                                                  
       2                 :                                                                                                        
       3               1 : class HTMLPurifier_URIDefinition extends HTMLPurifier_Definition                                       
       4                 : {                                                                                                      
       5                 :                                                                                                        
       6                 :     public $type = 'URI';                                                                              
       7                 :     protected $filters = array();                                                                      
       8                 :     protected $postFilters = array();                                                                  
       9                 :     protected $registeredFilters = array();                                                            
      10                 :                                                                                                        
      11                 :     /**                                                                                                
      12                 :      * HTMLPurifier_URI object of the base specified at %URI.Base                                      
      13                 :      */                                                                                                
      14                 :     public $base;                                                                                      
      15                 :                                                                                                        
      16                 :     /**                                                                                                
      17                 :      * String host to consider "home" base, derived off of $base                                       
      18                 :      */                                                                                                
      19                 :     public $host;                                                                                      
      20                 :                                                                                                        
      21                 :     /**                                                                                                
      22                 :      * Name of default scheme based on %URI.DefaultScheme and %URI.Base                                
      23                 :      */                                                                                                
      24                 :     public $defaultScheme;                                                                             
      25                 :                                                                                                        
      26                 :     public function __construct() {                                                                    
      27                 :         $this->registerFilter(new HTMLPurifier_URIFilter_DisableExternal());                           
      28                 :         $this->registerFilter(new HTMLPurifier_URIFilter_DisableExternalResources());                  
      29                 :         $this->registerFilter(new HTMLPurifier_URIFilter_HostBlacklist());                             
      30                 :         $this->registerFilter(new HTMLPurifier_URIFilter_MakeAbsolute());                              
      31                 :         $this->registerFilter(new HTMLPurifier_URIFilter_Munge());                                     
      32                 :     }                                                                                                  
      33                 :                                                                                                        
      34                 :     public function registerFilter($filter) {                                                          
      35               0 :         $this->registeredFilters[$filter->name] = $filter;                                             
      36               0 :     }                                                                                                  
      37                 :                                                                                                        
      38                 :     public function addFilter($filter, $config) {                                                      
      39               0 :         $r = $filter->prepare($config);                                                                
      40               0 :         if ($r === false) return; // null is ok, for backwards compat                                  
      41               0 :         if ($filter->post) {                                                                           
      42               0 :             $this->postFilters[$filter->name] = $filter;                                               
      43               0 :         } else {                                                                                       
      44               0 :             $this->filters[$filter->name] = $filter;                                                   
      45                 :         }                                                                                              
      46               0 :     }                                                                                                  
      47                 :                                                                                                        
      48                 :     protected function doSetup($config) {                                                              
      49               0 :         $this->setupMemberVariables($config);                                                          
      50               0 :         $this->setupFilters($config);                                                                  
      51               0 :     }                                                                                                  
      52                 :                                                                                                        
      53                 :     protected function setupFilters($config) {                                                         
      54               0 :         foreach ($this->registeredFilters as $name => $filter) {                                       
      55               0 :             $conf = $config->get('URI', $name);                                                        
      56               0 :             if ($conf !== false && $conf !== null) {                                                   
      57               0 :                 $this->addFilter($filter, $config);                                                    
      58               0 :             }                                                                                          
      59               0 :         }                                                                                              
      60               0 :         unset($this->registeredFilters);                                                               
      61               0 :     }                                                                                                  
      62                 :                                                                                                        
      63                 :     protected function setupMemberVariables($config) {                                                 
      64               0 :         $this->host = $config->get('URI', 'Host');                                                     
      65               0 :         $base_uri = $config->get('URI', 'Base');                                                       
      66               0 :         if (!is_null($base_uri)) {                                                                     
      67               0 :             $parser = new HTMLPurifier_URIParser();                                                    
      68               0 :             $this->base = $parser->parse($base_uri);                                                   
      69               0 :             $this->defaultScheme = $this->base->scheme;                                                
      70               0 :             if (is_null($this->host)) $this->host = $this->base->host;                                 
      71               0 :         }                                                                                              
      72               0 :         if (is_null($this->defaultScheme)) $this->defaultScheme = $config->get('URI', 'DefaultScheme');
      73               0 :     }                                                                                                  
      74                 :                                                                                                        
      75                 :     public function filter(&$uri, $config, $context) {                                                 
      76               2 :         foreach ($this->filters as $name => $f) {                                                      
      77               2 :             $result = $f->filter($uri, $config, $context);                                             
      78               2 :             if (!$result) return false;                                                                
      79               2 :         }                                                                                              
      80               2 :         return true;                                                                                   
      81                 :     }                                                                                                  
      82                 :                                                                                                        
      83                 :     public function postFilter(&$uri, $config, $context) {                                             
      84               2 :         foreach ($this->postFilters as $name => $f) {                                                  
      85               0 :             $result = $f->filter($uri, $config, $context);                                             
      86               0 :             if (!$result) return false;                                                                
      87               0 :         }                                                                                              
      88               2 :         return true;                                                                                   
      89                 :     }                                                                                                  
      90                 :                                                                                                        
      91                 : }                                                                                                      

Generated by PHPUnit 3.3.1 and Xdebug 2.0.2 at Thu Sep 25 18:42:10 CEST 2008.