PHPIDS
Current file: /home/mario/workspace/php-ids.org/trunk/lib/IDS/vendors/htmlpurifier/HTMLPurifier/AttrDef/HTML/Pixels.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
64.71 %64.71%
64.71% 11 / 17
 
HTMLPurifier_AttrDef_HTML_Pixels
100.00 %100.00%
100.00% 1 / 1
33.33 %33.33%
33.33% 1 / 3
64.71 %64.71%
64.71% 11 / 17
 public function __construct($max = NULL)
0.00 %0.00%
0.00% 0 / 1
100.00 %100.00%
100.00% 0 / 0
 public function validate($string, $config, $context)
100.00 %100.00%
100.00% 1 / 1
83.33 %83.33%
83.33% 10 / 12
 public function make($string)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 4


       1                 : <?php                                                                            
       2                 :                                                                                  
       3                 : /**                                                                              
       4                 :  * Validates an integer representation of pixels according to the HTML spec.     
       5                 :  */                                                                              
       6               1 : class HTMLPurifier_AttrDef_HTML_Pixels extends HTMLPurifier_AttrDef              
       7                 : {                                                                                
       8                 :                                                                                  
       9                 :     protected $max;                                                              
      10                 :                                                                                  
      11                 :     public function __construct($max = null) {                                   
      12                 :         $this->max = $max;                                                       
      13                 :     }                                                                            
      14                 :                                                                                  
      15                 :     public function validate($string, $config, $context) {                       
      16                 :                                                                                  
      17               2 :         $string = trim($string);                                                 
      18               2 :         if ($string === '0') return $string;                                     
      19               2 :         if ($string === '')  return false;                                       
      20               2 :         $length = strlen($string);                                               
      21               2 :         if (substr($string, $length - 2) == 'px') {                              
      22               0 :             $string = substr($string, 0, $length - 2);                           
      23               0 :         }                                                                        
      24               2 :         if (!is_numeric($string)) return false;                                  
      25               2 :         $int = (int) $string;                                                    
      26                 :                                                                                  
      27               2 :         if ($int < 0) return '0';                                                
      28                 :                                                                                  
      29                 :         // upper-bound value, extremely high values can                          
      30                 :         // crash operating systems, see <http://ha.ckers.org/imagecrash.html>    
      31                 :         // WARNING, above link WILL crash you if you're using Windows            
      32                 :                                                                                  
      33               2 :         if ($this->max !== null && $int > $this->max) return (string) $this->max;
      34                 :                                                                                  
      35               2 :         return (string) $int;                                                    
      36                 :                                                                                  
      37                 :     }                                                                            
      38                 :                                                                                  
      39                 :     public function make($string) {                                              
      40               0 :         if ($string === '') $max = null;                                         
      41               0 :         else $max = (int) $string;                                               
      42               0 :         $class = get_class($this);                                               
      43               0 :         return new $class($max);                                                 
      44                 :     }                                                                            
      45                 :                                                                                  
      46                 : }                                                                                
      47                 :                                                                                  

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