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

  Coverage
  Classes Methods Lines
Total
100.00 %100.00%
100.00% 1 / 1
33.33 %33.33%
33.33% 1 / 3
88.46 %88.46%
88.46% 23 / 26
 
HTMLPurifier_AttrDef_URI
100.00 %100.00%
100.00% 1 / 1
33.33 %33.33%
33.33% 1 / 3
88.46 %88.46%
88.46% 23 / 26
 public function __construct($embeds_resource = false)
0.00 %0.00%
0.00% 0 / 1
100.00 %100.00%
100.00% 0 / 0
 public function make($string)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 2
 public function validate($uri, $config, $context)
100.00 %100.00%
100.00% 1 / 1
95.65 %95.65%
95.65% 22 / 23


       1                 : <?php                                                                                     
       2                 :                                                                                           
       3                 : /**                                                                                       
       4                 :  * Validates a URI as defined by RFC 3986.                                                
       5                 :  * @note Scheme-specific mechanics deferred to HTMLPurifier_URIScheme                     
       6                 :  */                                                                                       
       7               1 : class HTMLPurifier_AttrDef_URI extends HTMLPurifier_AttrDef                               
       8                 : {                                                                                         
       9                 :                                                                                           
      10                 :     protected $parser;                                                                    
      11                 :     protected $embedsResource;                                                            
      12                 :                                                                                           
      13                 :     /**                                                                                   
      14                 :      * @param $embeds_resource_resource Does the URI here result in an extra HTTP request?
      15                 :      */                                                                                   
      16                 :     public function __construct($embeds_resource = false) {                               
      17                 :         $this->parser = new HTMLPurifier_URIParser();                                     
      18                 :         $this->embedsResource = (bool) $embeds_resource;                                  
      19                 :     }                                                                                     
      20                 :                                                                                           
      21                 :     public function make($string) {                                                       
      22               0 :         $embeds = (bool) $string;                                                         
      23               0 :         return new HTMLPurifier_AttrDef_URI($embeds);                                     
      24                 :     }                                                                                     
      25                 :                                                                                           
      26                 :     public function validate($uri, $config, $context) {                                   
      27                 :                                                                                           
      28               2 :         if ($config->get('URI', 'Disable')) return false;                                 
      29                 :                                                                                           
      30               2 :         $uri = $this->parseCDATA($uri);                                                   
      31                 :                                                                                           
      32                 :         // parse the URI                                                                  
      33               2 :         $uri = $this->parser->parse($uri);                                                
      34               2 :         if ($uri === false) return false;                                                 
      35                 :                                                                                           
      36                 :         // add embedded flag to context for validators                                    
      37               2 :         $context->register('EmbeddedURI', $this->embedsResource);                         
      38                 :                                                                                           
      39               2 :         $ok = false;                                                                      
      40                 :         do {                                                                              
      41                 :                                                                                           
      42                 :             // generic validation                                                         
      43               2 :             $result = $uri->validate($config, $context);                                  
      44               2 :             if (!$result) break;                                                          
      45                 :                                                                                           
      46                 :             // chained filtering                                                          
      47               2 :             $uri_def = $config->getDefinition('URI');                                     
      48               2 :             $result = $uri_def->filter($uri, $config, $context);                          
      49               2 :             if (!$result) break;                                                          
      50                 :                                                                                           
      51                 :             // scheme-specific validation                                                 
      52               2 :             $scheme_obj = $uri->getSchemeObj($config, $context);                          
      53               2 :             if (!$scheme_obj) break;                                                      
      54               2 :             if ($this->embedsResource && !$scheme_obj->browsable) break;                  
      55               2 :             $result = $scheme_obj->validate($uri, $config, $context);                     
      56               2 :             if (!$result) break;                                                          
      57                 :                                                                                           
      58                 :             // Post chained filtering                                                     
      59               2 :             $result = $uri_def->postFilter($uri, $config, $context);                      
      60               2 :             if (!$result) break;                                                          
      61                 :                                                                                           
      62                 :             // survived gauntlet                                                          
      63               2 :             $ok = true;                                                                   
      64                 :                                                                                           
      65               0 :         } while (false);                                                                  
      66                 :                                                                                           
      67               2 :         $context->destroy('EmbeddedURI');                                                 
      68               2 :         if (!$ok) return false;                                                           
      69                 :                                                                                           
      70                 :         // back to string                                                                 
      71               2 :         return $uri->toString();                                                          
      72                 :                                                                                           
      73                 :     }                                                                                     
      74                 :                                                                                           
      75                 : }                                                                                         
      76                 :                                                                                           
      77                 :                                                                                           

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