Changeset 1256

Show
Ignore:
Timestamp:
07/02/08 00:47:42 (2 months ago)
Author:
rats
Message:

Updated HTMLpurifier to version 3.1.1

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/CHANGELOG

    r1255 r1256  
    22~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    33 
     42008-07-02 Benedikt Heintel 
     5        - TOOLS: 
     6                * Updated HTMLpurifier to version 3.1.1 
     7 
    482008-07-01 Marc Pujol 
    59        - GUI: 
     
    913        - GUI: 
    1014                * Fixed #1352 PHPmyadmin login from control panel not working (thanks Machaven) 
     15 
     162008-06-30 Benedikt Heintel 
     17        - GUI: 
     18                * Fixed #1367: Fatal Error after Login 
    1119 
    12202008-06-29 Benedikt Heintel 
  • trunk/gui/include/htmlpurifier/HTMLPurifier.includes.php

    r1241 r1256  
    88 * FILE, changes will be overwritten the next time the script is run. 
    99 *  
    10  * @version 3.1.0 
     10 * @version 3.1.1 
    1111 *  
    1212 * @warning 
     
    3030require 'HTMLPurifier/ChildDef.php'; 
    3131require 'HTMLPurifier/Config.php'; 
    32 require 'HTMLPurifier/ConfigDef.php'; 
    3332require 'HTMLPurifier/ConfigSchema.php'; 
    3433require 'HTMLPurifier/ContentSets.php'; 
     
    5352require 'HTMLPurifier/Language.php'; 
    5453require 'HTMLPurifier/LanguageFactory.php'; 
     54require 'HTMLPurifier/Length.php'; 
    5555require 'HTMLPurifier/Lexer.php'; 
    5656require 'HTMLPurifier/PercentEncoder.php'; 
     
    6767require 'HTMLPurifier/URIScheme.php'; 
    6868require 'HTMLPurifier/URISchemeRegistry.php'; 
     69require 'HTMLPurifier/UnitConverter.php'; 
    6970require 'HTMLPurifier/VarParser.php'; 
    7071require 'HTMLPurifier/VarParserException.php'; 
     
    7374require 'HTMLPurifier/AttrDef/Integer.php'; 
    7475require 'HTMLPurifier/AttrDef/Lang.php'; 
     76require 'HTMLPurifier/AttrDef/Switch.php'; 
    7577require 'HTMLPurifier/AttrDef/Text.php'; 
    7678require 'HTMLPurifier/AttrDef/URI.php'; 
     
    117119require 'HTMLPurifier/AttrTransform/Length.php'; 
    118120require 'HTMLPurifier/AttrTransform/Name.php'; 
     121require 'HTMLPurifier/AttrTransform/SafeEmbed.php'; 
     122require 'HTMLPurifier/AttrTransform/SafeObject.php'; 
     123require 'HTMLPurifier/AttrTransform/SafeParam.php'; 
    119124require 'HTMLPurifier/AttrTransform/ScriptRequired.php'; 
    120125require 'HTMLPurifier/ChildDef/Chameleon.php'; 
     
    125130require 'HTMLPurifier/ChildDef/StrictBlockquote.php'; 
    126131require 'HTMLPurifier/ChildDef/Table.php'; 
    127 require 'HTMLPurifier/ConfigDef/Directive.php'; 
    128 require 'HTMLPurifier/ConfigDef/DirectiveAlias.php'; 
    129 require 'HTMLPurifier/ConfigDef/Namespace.php'; 
    130132require 'HTMLPurifier/DefinitionCache/Decorator.php'; 
    131133require 'HTMLPurifier/DefinitionCache/Null.php'; 
     
    145147require 'HTMLPurifier/HTMLModule/Proprietary.php'; 
    146148require 'HTMLPurifier/HTMLModule/Ruby.php'; 
     149require 'HTMLPurifier/HTMLModule/SafeEmbed.php'; 
     150require 'HTMLPurifier/HTMLModule/SafeObject.php'; 
    147151require 'HTMLPurifier/HTMLModule/Scripting.php'; 
    148152require 'HTMLPurifier/HTMLModule/StyleAttribute.php'; 
     
    160164require 'HTMLPurifier/Injector/Linkify.php'; 
    161165require 'HTMLPurifier/Injector/PurifierLinkify.php'; 
     166require 'HTMLPurifier/Injector/SafeObject.php'; 
    162167require 'HTMLPurifier/Lexer/DOMLex.php'; 
    163168require 'HTMLPurifier/Lexer/DirectLex.php'; 
     
    180185require 'HTMLPurifier/URIFilter/HostBlacklist.php'; 
    181186require 'HTMLPurifier/URIFilter/MakeAbsolute.php'; 
     187require 'HTMLPurifier/URIFilter/Munge.php'; 
    182188require 'HTMLPurifier/URIScheme/ftp.php'; 
    183189require 'HTMLPurifier/URIScheme/http.php'; 
  • trunk/gui/include/htmlpurifier/HTMLPurifier.php

    r1241 r1256  
    2020 
    2121/* 
    22     HTML Purifier 3.1.0 - Standards Compliant HTML Filtering 
     22    HTML Purifier 3.1.1 - Standards Compliant HTML Filtering 
    2323    Copyright (C) 2006-2008 Edward Z. Yang 
    2424 
     
    5656     
    5757    /** Version of HTML Purifier */ 
    58     public $version = '3.1.0'; 
     58    public $version = '3.1.1'; 
    5959     
    6060    /** Constant with version of HTML Purifier */ 
    61     const VERSION = '3.1.0'; 
     61    const VERSION = '3.1.1'; 
    6262     
    6363    /** Global configuration object */ 
  • trunk/gui/include/htmlpurifier/HTMLPurifier.safe-includes.php

    r1241 r1256  
    2424require_once $__dir . '/HTMLPurifier/ChildDef.php'; 
    2525require_once $__dir . '/HTMLPurifier/Config.php'; 
    26 require_once $__dir . '/HTMLPurifier/ConfigDef.php'; 
    2726require_once $__dir . '/HTMLPurifier/ConfigSchema.php'; 
    2827require_once $__dir . '/HTMLPurifier/ContentSets.php'; 
     
    4746require_once $__dir . '/HTMLPurifier/Language.php'; 
    4847require_once $__dir . '/HTMLPurifier/LanguageFactory.php'; 
     48require_once $__dir . '/HTMLPurifier/Length.php'; 
    4949require_once $__dir . '/HTMLPurifier/Lexer.php'; 
    5050require_once $__dir . '/HTMLPurifier/PercentEncoder.php'; 
     
    6161require_once $__dir . '/HTMLPurifier/URIScheme.php'; 
    6262require_once $__dir . '/HTMLPurifier/URISchemeRegistry.php'; 
     63require_once $__dir . '/HTMLPurifier/UnitConverter.php'; 
    6364require_once $__dir . '/HTMLPurifier/VarParser.php'; 
    6465require_once $__dir . '/HTMLPurifier/VarParserException.php'; 
     
    6768require_once $__dir . '/HTMLPurifier/AttrDef/Integer.php'; 
    6869require_once $__dir . '/HTMLPurifier/AttrDef/Lang.php'; 
     70require_once $__dir . '/HTMLPurifier/AttrDef/Switch.php'; 
    6971require_once $__dir . '/HTMLPurifier/AttrDef/Text.php'; 
    7072require_once $__dir . '/HTMLPurifier/AttrDef/URI.php'; 
     
    111113require_once $__dir . '/HTMLPurifier/AttrTransform/Length.php'; 
    112114require_once $__dir . '/HTMLPurifier/AttrTransform/Name.php'; 
     115require_once $__dir . '/HTMLPurifier/AttrTransform/SafeEmbed.php'; 
     116require_once $__dir . '/HTMLPurifier/AttrTransform/SafeObject.php'; 
     117require_once $__dir . '/HTMLPurifier/AttrTransform/SafeParam.php'; 
    113118require_once $__dir . '/HTMLPurifier/AttrTransform/ScriptRequired.php'; 
    114119require_once $__dir . '/HTMLPurifier/ChildDef/Chameleon.php'; 
     
    119124require_once $__dir . '/HTMLPurifier/ChildDef/StrictBlockquote.php'; 
    120125require_once $__dir . '/HTMLPurifier/ChildDef/Table.php'; 
    121 require_once $__dir . '/HTMLPurifier/ConfigDef/Directive.php'; 
    122 require_once $__dir . '/HTMLPurifier/ConfigDef/DirectiveAlias.php'; 
    123 require_once $__dir . '/HTMLPurifier/ConfigDef/Namespace.php'; 
    124126require_once $__dir . '/HTMLPurifier/DefinitionCache/Decorator.php'; 
    125127require_once $__dir . '/HTMLPurifier/DefinitionCache/Null.php'; 
     
    139141require_once $__dir . '/HTMLPurifier/HTMLModule/Proprietary.php'; 
    140142require_once $__dir . '/HTMLPurifier/HTMLModule/Ruby.php'; 
     143require_once $__dir . '/HTMLPurifier/HTMLModule/SafeEmbed.php'; 
     144require_once $__dir . '/HTMLPurifier/HTMLModule/SafeObject.php'; 
    141145require_once $__dir . '/HTMLPurifier/HTMLModule/Scripting.php'; 
    142146require_once $__dir . '/HTMLPurifier/HTMLModule/StyleAttribute.php'; 
     
    154158require_once $__dir . '/HTMLPurifier/Injector/Linkify.php'; 
    155159require_once $__dir . '/HTMLPurifier/Injector/PurifierLinkify.php'; 
     160require_once $__dir . '/HTMLPurifier/Injector/SafeObject.php'; 
    156161require_once $__dir . '/HTMLPurifier/Lexer/DOMLex.php'; 
    157162require_once $__dir . '/HTMLPurifier/Lexer/DirectLex.php'; 
     
    174179require_once $__dir . '/HTMLPurifier/URIFilter/HostBlacklist.php'; 
    175180require_once $__dir . '/HTMLPurifier/URIFilter/MakeAbsolute.php'; 
     181require_once $__dir . '/HTMLPurifier/URIFilter/Munge.php'; 
    176182require_once $__dir . '/HTMLPurifier/URIScheme/ftp.php'; 
    177183require_once $__dir . '/HTMLPurifier/URIScheme/http.php'; 
  • trunk/gui/include/htmlpurifier/HTMLPurifier/AttrDef.php

    r1241 r1256  
    5252     * @warning This processing is inconsistent with XML's whitespace handling 
    5353     *          as specified by section 3.3.3 and referenced XHTML 1.0 section 
    54      *          4.7.  Compliant processing requires all line breaks normalized 
    55      *          to "\n", so the fix is not as simple as fixing it in this 
    56      *          function.  Trim and whitespace collapsing are supposed to only 
    57      *          occur in NMTOKENs.  However, note that we are NOT necessarily 
    58      *          parsing XML, thus, this behavior may still be correct. 
     54     *          4.7.  However, note that we are NOT necessarily 
     55     *          parsing XML, thus, this behavior may still be correct. We 
     56     *          assume that newlines have been normalized. 
    5957     */ 
    6058    public function parseCDATA($string) { 
    6159        $string = trim($string); 
    62         $string = str_replace("\n", '', $string); 
    63         $string = str_replace(array("\r", "\t"), ' ', $string); 
     60        $string = str_replace(array("\n", "\t", "\r"), ' ', $string); 
    6461        return $string; 
    6562    } 
  • trunk/gui/include/htmlpurifier/HTMLPurifier/AttrDef/CSS.php

    r1241 r1256  
    2929        $declarations = explode(';', $css); 
    3030        $propvalues = array(); 
     31         
     32        /** 
     33         * Name of the current CSS property being validated. 
     34         */ 
     35        $property = false; 
     36        $context->register('CurrentCSSProperty', $property); 
    3137         
    3238        foreach ($declarations as $declaration) { 
     
    6268        } 
    6369         
     70        $context->destroy('CurrentCSSProperty'); 
     71         
    6472        // procedure does not write the new CSS simultaneously, so it's 
    6573        // slightly inefficient, but it's the only way of getting rid of 
  • trunk/gui/include/htmlpurifier/HTMLPurifier/AttrDef/CSS/FontFamily.php

    r1241 r1256  
    1717        ); 
    1818         
    19         $string = $this->parseCDATA($string); 
    2019        // assume that no font names contain commas in them 
    2120        $fonts = explode(',', $string); 
     
    3635                if ($font[$length - 1] !== $quote) continue; 
    3736                $font = substr($font, 1, $length - 2); 
    38                 // double-backslash processing is buggy 
    39                 $font = str_replace("\\$quote", $quote, $font); // de-escape quote 
    40                 $font = str_replace("\\\n", "\n", $font);       // de-escape newlines 
     37                 
     38                $new_font = ''; 
     39                for ($i = 0, $c = strlen($font); $i < $c; $i++) { 
     40                    if ($font[$i] === '\\') { 
     41                        $i++; 
     42                        if ($i >= $c) { 
     43                            $new_font .= '\\'; 
     44                            break; 
     45                        } 
     46                        if (ctype_xdigit($font[$i])) { 
     47                            $code = $font[$i]; 
     48                            for ($a = 1, $i++; $i < $c && $a < 6; $i++, $a++) { 
     49                                if (!ctype_xdigit($font[$i])) break; 
     50                                $code .= $font[$i]; 
     51                            } 
     52                            // We have to be extremely careful when adding 
     53                            // new characters, to make sure we're not breaking 
     54                            // the encoding. 
     55                            $char = HTMLPurifier_Encoder::unichr(hexdec($code)); 
     56                            if (HTMLPurifier_Encoder::cleanUTF8($char) === '') continue; 
     57                            $new_font .= $char; 
     58                            if ($i < $c && trim($font[$i]) !== '') $i--; 
     59                            continue; 
     60                        } 
     61                        if ($font[$i] === "\n") continue; 
     62                    } 
     63                    $new_font .= $font[$i]; 
     64                } 
     65                 
     66                $font = $new_font; 
    4167            } 
    4268            // $font is a pure representation of the font name 
    4369             
    44             if (ctype_alnum($font)) { 
     70            if (ctype_alnum($font) && $font !== '') { 
    4571                // very simple font, allow it in unharmed 
    4672                $final .= $font . ', '; 
     
    5177             
    5278            // armor single quotes and new lines 
     79            $font = str_replace("\\", "\\\\", $font); 
    5380            $font = str_replace("'", "\\'", $font); 
    54             $font = str_replace("\n", "\\\n", $font); 
    5581            $final .= "'$font', "; 
    5682        } 
  • trunk/gui/include/htmlpurifier/HTMLPurifier/AttrDef/CSS/Length.php

    r1241 r1256  
    77{ 
    88     
    9     /** 
    10      * Valid unit lookup table. 
    11      * @warning The code assumes all units are two characters long.  Be careful 
    12      *          if we have to change this behavior! 
    13      */ 
    14     protected $units = array('em' => true, 'ex' => true, 'px' => true, 'in' => true, 
    15          'cm' => true, 'mm' => true, 'pt' => true, 'pc' => true); 
    16     /** 
    17      * Instance of HTMLPurifier_AttrDef_Number to defer number validation to 
    18      */ 
    19     protected $number_def; 
     9    protected $min, $max; 
    2010     
    2111    /** 
    22      * @param $non_negative Bool indication whether or not negative values are 
    23      *                      allowed
     12     * @param HTMLPurifier_Length $max Minimum length, or null for no bound. String is also acceptable. 
     13     * @param HTMLPurifier_Length $max Maximum length, or null for no bound. String is also acceptable
    2414     */ 
    25     public function __construct($non_negative = false) { 
    26         $this->number_def = new HTMLPurifier_AttrDef_CSS_Number($non_negative); 
     15    public function __construct($min = null, $max = null) { 
     16        $this->min = $min !== null ? HTMLPurifier_Length::make($min) : null; 
     17        $this->max = $max !== null ? HTMLPurifier_Length::make($max) : null; 
    2718    } 
    2819     
    29     public function validate($length, $config, $context) { 
     20    public function validate($string, $config, $context) { 
     21        $string = $this->parseCDATA($string); 
    3022         
    31         $length = $this->parseCDATA($length); 
    32         if ($length === '') return false; 
    33         if ($length === '0') return '0'; 
    34         $strlen = strlen($length); 
    35         if ($strlen === 1) return false; // impossible! 
     23        // Optimizations 
     24        if ($string === '') return false; 
     25        if ($string === '0') return '0'; 
     26        if (strlen($string) === 1) return false; 
    3627         
    37         // we assume all units are two characters 
    38         $unit = substr($length, $strlen - 2); 
    39         if (!ctype_lower($unit)) $unit = strtolower($unit); 
    40         $number = substr($length, 0, $strlen - 2); 
     28        $length = HTMLPurifier_Length::make($string); 
     29        if (!$length->isValid()) return false; 
    4130         
    42         if (!isset($this->units[$unit])) return false; 
     31        if ($this->min) { 
     32            $c = $length->compareTo($this->min); 
     33            if ($c === false) return false; 
     34            if ($c < 0) return false; 
     35        } 
     36        if ($this->max) { 
     37            $c = $length->compareTo($this->max); 
     38            if ($c === false) return false; 
     39            if ($c > 0) return false; 
     40        } 
    4341         
    44         $number = $this->number_def->validate($number, $config, $context); 
    45         if ($number === false) return false; 
    46          
    47         return $number . $unit; 
    48          
     42        return $length->toString(); 
    4943    } 
    5044     
  • trunk/gui/include/htmlpurifier/HTMLPurifier/AttrDef/CSS/Number.php

    r1241 r1256  
    1919    } 
    2020     
     21    /** 
     22     * @warning Some contexts do not pass $config, $context. These 
     23     *          variables should not be used without checking HTMLPurifier_Length 
     24     */ 
    2125    public function validate($number, $config, $context) { 
    2226         
  • trunk/gui/include/htmlpurifier/HTMLPurifier/AttrDef/CSS/TextDecoration.php

    r1241 r1256  
    1414            'line-through' => true, 
    1515            'overline' => true, 
    16             'underline' => true 
     16            'underline' => true, 
    1717        ); 
    1818         
    1919        $string = strtolower($this->parseCDATA($string)); 
     20         
     21        if ($string === 'none') return $string; 
     22         
    2023        $parts = explode(' ', $string); 
    2124        $final = ''; 
  • trunk/gui/include/htmlpurifier/HTMLPurifier/AttrDef/HTML/Pixels.php

    r1241 r1256  
    66class HTMLPurifier_AttrDef_HTML_Pixels extends HTMLPurifier_AttrDef 
    77{ 
     8     
     9    protected $max; 
     10     
     11    public function __construct($max = null) { 
     12        $this->max = $max; 
     13    } 
    814     
    915    public function validate($string, $config, $context) { 
     
    2531        // WARNING, above link WILL crash you if you're using Windows 
    2632         
    27         if ($int > 1200) return '1200'
     33        if ($this->max !== null && $int > $this->max) return (string) $this->max
    2834         
    2935        return (string) $int; 
     
    3137    } 
    3238     
     39    public function make($string) { 
     40        if ($string === '') $max = null; 
     41        else $max = (int) $string; 
     42        $class = get_class($this); 
     43        return new $class($max); 
     44    } 
     45     
    3346} 
    3447 
  • trunk/gui/include/htmlpurifier/HTMLPurifier/AttrDef/URI.php

    r1241 r1256  
    1717        $this->parser = new HTMLPurifier_URIParser(); 
    1818        $this->embedsResource = (bool) $embeds_resource; 
     19    } 
     20     
     21    public function make($string) { 
     22        $embeds = (bool) $string; 
     23        return new HTMLPurifier_AttrDef_URI($embeds); 
    1924    } 
    2025     
     
    5156            if (!$result) break; 
    5257             
     58            // Post chained filtering 
     59            $result = $uri_def->postFilter($uri, $config, $context); 
     60            if (!$result) break; 
     61             
    5362            // survived gauntlet 
    5463            $ok = true; 
     
    6069         
    6170        // back to string 
    62         $result = $uri->toString(); 
    63          
    64         // munge entire URI if necessary 
    65         if ( 
    66             !is_null($uri->host) && // indicator for authority 
    67             !empty($scheme_obj->browsable) && 
    68             !is_null($munge = $config->get('URI', 'Munge')) 
    69         ) { 
    70             $result = str_replace('%s', rawurlencode($result), $munge); 
    71         } 
    72          
    73         return $result; 
     71        return $uri->toString(); 
    7472         
    7573    } 
  • trunk/gui/include/htmlpurifier/HTMLPurifier/AttrValidator.php

    r1241 r1256  
    4444        $d_defs = $definition->info_global_attr; 
    4545         
    46         // reference attributes for easy manipulation 
    47         $attr =& $token->attr; 
     46        // don't update token until the very end, to ensure an atomic update 
     47        $attr = $token->attr; 
    4848         
    4949        // do global transformations (pre) 
     
    140140        } 
    141141         
     142        $token->attr = $attr; 
     143         
    142144        // destroy CurrentToken if we made it ourselves 
    143145        if (!$current_token) $context->destroy('CurrentToken'); 
  • trunk/gui/include/htmlpurifier/HTMLPurifier/CSSDefinition.php

    r1241 r1256  
    9191        $this->info['border-right-width'] = new HTMLPurifier_AttrDef_CSS_Composite(array( 
    9292            new HTMLPurifier_AttrDef_Enum(array('thin', 'medium', 'thick')), 
    93             new HTMLPurifier_AttrDef_CSS_Length(true) //disallow negative 
     93            new HTMLPurifier_AttrDef_CSS_Length('0') //disallow negative 
    9494        )); 
    9595         
     
    117117            new HTMLPurifier_AttrDef_Enum(array('normal')), 
    118118            new HTMLPurifier_AttrDef_CSS_Number(true), // no negatives 
    119             new HTMLPurifier_AttrDef_CSS_Length(true), 
     119            new HTMLPurifier_AttrDef_CSS_Length('0'), 
    120120            new HTMLPurifier_AttrDef_CSS_Percentage(true) 
    121121        )); 
     
    139139        $this->info['padding-left'] =  
    140140        $this->info['padding-right'] = new HTMLPurifier_AttrDef_CSS_Composite(array( 
    141             new HTMLPurifier_AttrDef_CSS_Length(true), 
     141            new HTMLPurifier_AttrDef_CSS_Length('0'), 
    142142            new HTMLPurifier_AttrDef_CSS_Percentage(true) 
    143143        )); 
     
    150150        )); 
    151151         
     152        $trusted_wh = new HTMLPurifier_AttrDef_CSS_Composite(array( 
     153            new HTMLPurifier_AttrDef_CSS_Length('0'), 
     154            new HTMLPurifier_AttrDef_CSS_Percentage(true), 
     155            new HTMLPurifier_AttrDef_Enum(array('auto')) 
     156        )); 
     157        $max = $config->get('CSS', 'MaxImgLength'); 
     158         
    152159        $this->info['width'] = 
    153160        $this->info['height'] = 
    154         new HTMLPurifier_AttrDef_CSS_DenyElementDecorator( 
    155         new HTMLPurifier_AttrDef_CSS_Composite(array( 
    156             new HTMLPurifier_AttrDef_CSS_Length(true), 
    157             new HTMLPurifier_AttrDef_CSS_Percentage(true), 
    158             new HTMLPurifier_AttrDef_Enum(array('auto')) 
    159         )), 'img'); 
     161            $max === null ? 
     162            $trusted_wh :  
     163            new HTMLPurifier_AttrDef_Switch('img', 
     164                // For img tags: 
     165                new HTMLPurifier_AttrDef_CSS_Composite(array( 
     166                    new HTMLPurifier_AttrDef_CSS_Length('0', $max), 
     167                    new HTMLPurifier_AttrDef_Enum(array('auto')) 
     168                )), 
     169                // For everyone else: 
     170                $trusted_wh 
     171            ); 
    160172         
    161173        $this->info['text-decoration'] = new HTMLPurifier_AttrDef_CSS_TextDecoration(); 
  • trunk/gui/include/htmlpurifier/HTMLPurifier/ChildDef/Required.php

    r1241 r1256  
    5656         
    5757        // generator 
    58         static $gen = null; 
    59         if ($gen === null) { 
    60             $gen = new HTMLPurifier_Generator(); 
    61         } 
     58        $gen = new HTMLPurifier_Generator($config, $context); 
    6259         
    6360        foreach ($tokens_of_children as $token) { 
     
    8481                    } elseif ($pcdata_allowed && $escape_invalid_children) { 
    8582                        $result[] = new HTMLPurifier_Token_Text( 
    86                             $gen->generateFromToken($token, $config
     83                            $gen->generateFromToken($token
    8784                        ); 
    8885                    } 
     
    9592                $result[] = 
    9693                    new HTMLPurifier_Token_Text( 
    97                         $gen->generateFromToken( $token, $config
     94                        $gen->generateFromToken($token
    9895                    ); 
    9996            } else { 
  • trunk/gui/include/htmlpurifier/HTMLPurifier/Config.php

    r1241 r1256  
    2121     * HTML Purifier's version 
    2222     */ 
    23     public $version = '3.1.0'; 
     23    public $version = '3.1.1'; 
    2424     
    2525    /** 
     
    126126            return; 
    127127        } 
    128         if ($this->def->info[$namespace][$key]->class == 'alias') { 
     128        if (isset($this->def->info[$namespace][$key]->isAlias)) { 
    129129            $d = $this->def->info[$namespace][$key]; 
    130130            trigger_error('Cannot get value from aliased directive, use real name ' . $d->namespace . '.' . $d->name, 
     
    197197            return; 
    198198        } 
    199         if ($this->def->info[$namespace][$key]->class == 'alias') { 
     199        $def = $this->def->info[$namespace][$key]; 
     200         
     201        if (isset($def->isAlias)) { 
    200202            if ($from_alias) { 
    201203                trigger_error('Double-aliases not allowed, please fix '. 
     
    203205                return; 
    204206            } 
    205             $this->set($new_ns = $this->def->info[$namespace][$key]->namespace, 
    206                        $new_dir = $this->def->info[$namespace][$key]->name, 
     207            $this->set($new_ns = $def->namespace, 
     208                       $new_dir = $def->name, 
    207209                       $value, true); 
    208210            trigger_error("$namespace.$key is an alias, preferred directive name is $new_ns.$new_dir", E_USER_NOTICE); 
    209211            return; 
    210212        } 
     213         
     214        // Raw type might be negative when using the fully optimized form 
     215        // of stdclass, which indicates allow_null == true 
     216        $rtype = is_int($def) ? $def : $def->type; 
     217        if ($rtype < 0) { 
     218            $type = -$rtype; 
     219            $allow_null = true; 
     220        } else { 
     221            $type = $rtype; 
     222            $allow_null = isset($def->allow_null); 
     223        } 
     224         
    211225        try { 
    212             $value = $this->parser->parse( 
    213                         $value, 
    214                         $type = $this->def->info[$namespace][$key]->type, 
    215                         $this->def->info[$namespace][$key]->allow_null 
    216                      ); 
     226            $value = $this->parser->parse($value, $type, $allow_null); 
    217227        } catch (HTMLPurifier_VarParserException $e) { 
    218             trigger_error('Value for ' . "$namespace.$key" . ' is of invalid type, should be ' . $type, E_USER_WARNING); 
    219             return; 
    220         } 
    221         if (is_string($value)) { 
     228            trigger_error('Value for ' . "$namespace.$key" . ' is of invalid type, should be ' . HTMLPurifier_VarParser::getTypeName($type), E_USER_WARNING); 
     229            return; 
     230        } 
     231        if (is_string($value) && is_object($def)) { 
    222232            // resolve value alias if defined 
    223             if (isset($this->def->info[$namespace][$key]->aliases[$value])) { 
    224                 $value = $this->def->info[$namespace][$key]->aliases[$value]; 
    225             } 
    226             if ($this->def->info[$namespace][$key]->allowed !== true) { 
    227                 // check to see if the value is allowed 
    228                 if (!isset($this->def->info[$namespace][$key]->allowed[$value])) { 
    229                     trigger_error('Value not supported, valid values are: ' . 
    230                         $this->_listify($this->def->info[$namespace][$key]->allowed), E_USER_WARNING); 
    231                     return; 
    232                 } 
     233            if (isset($def->aliases[$value])) { 
     234                $value = $def->aliases[$value]; 
     235            } 
     236            // check to see if the value is allowed 
     237            if (isset($def->allowed) && !isset($def->allowed[$value])) { 
     238                trigger_error('Value not supported, valid values are: ' . 
     239                    $this->_listify($def->allowed), E_USER_WARNING); 
     240                return; 
    233241            } 
    234242        } 
     
    387395                    if (!isset($allowed_directives["$ns.$directive"]) && !isset($allowed_ns[$ns])) continue; 
    388396                } 
    389                 if ($def->class == 'alias') continue; 
     397                if (isset($def->isAlias)) continue; 
    390398                if ($directive == 'DefinitionID' || $directive == 'DefinitionRev') continue; 
    391399                $ret[] = array($ns, $directive); 
  • trunk/gui/include/htmlpurifier/HTMLPurifier/ConfigSchema.php

    r1241 r1256  
    1313     
    1414    /** 
    15      * Definition of the directives. 
     15     * Definition of the directives. The structure of this is: 
     16     *  
     17     *  array( 
     18     *      'Namespace' => array( 
     19     *          'Directive' => new stdclass(), 
     20     *      ) 
     21     *  ) 
     22     *  
     23     * The stdclass may have the following properties: 
     24     *  
     25     *  - If isAlias isn't set: 
     26     *      - type: Integer type of directive, see HTMLPurifier_VarParser for definitions 
     27     *      - allow_null: If set, this directive allows null values 
     28     *      - aliases: If set, an associative array of value aliases to real values 
     29     *      - allowed: If set, a lookup array of allowed (string) values 
     30     *  - If isAlias is set: 
     31     *      - namespace: Namespace this directive aliases to 
     32