File indexing completed on 2024-12-22 05:36:22

0001 <?php
0002 
0003 /**
0004  * Chainable filters for custom URI processing.
0005  *
0006  * These filters can perform custom actions on a URI filter object,
0007  * including transformation or blacklisting.  A filter named Foo
0008  * must have a corresponding configuration directive %URI.Foo,
0009  * unless always_load is specified to be true.
0010  *
0011  * The following contexts may be available while URIFilters are being
0012  * processed:
0013  *
0014  *      - EmbeddedURI: true if URI is an embedded resource that will
0015  *        be loaded automatically on page load
0016  *      - CurrentToken: a reference to the token that is currently
0017  *        being processed
0018  *      - CurrentAttr: the name of the attribute that is currently being
0019  *        processed
0020  *      - CurrentCSSProperty: the name of the CSS property that is
0021  *        currently being processed (if applicable)
0022  *
0023  * @warning This filter is called before scheme object validation occurs.
0024  *          Make sure, if you require a specific scheme object, you
0025  *          you check that it exists. This allows filters to convert
0026  *          proprietary URI schemes into regular ones.
0027  */
0028 abstract class HTMLPurifier_URIFilter
0029 {
0030 
0031     /**
0032      * Unique identifier of filter.
0033      * @type string
0034      */
0035     public $name;
0036 
0037     /**
0038      * True if this filter should be run after scheme validation.
0039      * @type bool
0040      */
0041     public $post = false;
0042 
0043     /**
0044      * True if this filter should always be loaded.
0045      * This permits a filter to be named Foo without the corresponding
0046      * %URI.Foo directive existing.
0047      * @type bool
0048      */
0049     public $always_load = false;
0050 
0051     /**
0052      * Performs initialization for the filter.  If the filter returns
0053      * false, this means that it shouldn't be considered active.
0054      * @param HTMLPurifier_Config $config
0055      * @return bool
0056      */
0057     public function prepare($config)
0058     {
0059         return true;
0060     }
0061 
0062     /**
0063      * Filter a URI object
0064      * @param HTMLPurifier_URI $uri Reference to URI object variable
0065      * @param HTMLPurifier_Config $config
0066      * @param HTMLPurifier_Context $context
0067      * @return bool Whether or not to continue processing: false indicates
0068      *         URL is no good, true indicates continue processing. Note that
0069      *         all changes are committed directly on the URI object
0070      */
0071     abstract public function filter(&$uri, $config, $context);
0072 }
0073 
0074 // vim: et sw=4 sts=4