kses
[ class tree: kses ] [ index: kses ] [ all elements ]

Class: kses5

Source Location: /main/inc/lib/kses-0.2.2/oop/php5.class.kses.php

Class Overview


Kses strips evil scripts!


Author(s):

  • Richard R. Vásquez, Jr. (Original procedural code by Ulf Härnhammar)

Version:

  • PHP5 OOP 1.0.2

Copyright:

  • Richard R. Vásquez, Jr. 2005

Methods



Class Details

[line 107]
Kses strips evil scripts!

This class provides the capability for removing unwanted HTML/XHTML, attributes from tags, and protocols contained in links. The net result is a much more powerful tool than the PHP internal strip_tags()

This is a fork of a slick piece of procedural code called 'kses' written by Ulf Harnhammar.

The original class for PHP4 was basically a wrapper around all of the functions in the procedural code written by Ulf, and was released 7/25/2003.

This version is a bit of a rewrite to match my own coding style and use some of the capabilities allowed in PHP5. Since this was a significant rewrite, but it still maintains backward compatibility syntax-wise, the version number is now 1.0.0. Any minor changes that do not break compatibility will be indicated in the second or third digits. Anything that breaks compatibility will change the major version number.

PHP5 specific changes:

  • Private methods are now in place
  • __construct() is now used rather then the standard class name 'kses()'
  • Kses5 will not load in any version less that PHP5
Other modifications:
  • PHPdoc style documentation has been added to the class. See http://www.phpdoc.org/ for more info.
  • Method names have been changed to reflect status as verbs
  • One line methods have been folded into the code
  • Some methods are now deprecated due to nomenclature style change. See method documentation for specifics.
  • Kses now works in E_STRICT
  • Initial Version number set to 1.0.0 to reflect serious code changes
  • Addition of methods AddProtocols(), filterKsestextHook(), RemoveProtocol(), RemoveProtocols() and SetProtocols()
  • Deprecated _hook(), Protocols()
  • Integrated code from kses 0.2.2 into class.
  • Added methods DumpProtocols(), DumpMethods()




Tags:

author:  Richard R. Vásquez, Jr. (Original procedural code by Ulf Härnhammar)
version:  PHP5 OOP 1.0.2
copyright:  Richard R. Vásquez, Jr. 2005
link:  http://chaos.org/contact/ Contact page with current email address for Richard Vasquez
link:  http://sourceforge.net/projects/kses/ Home Page for Kses
license:  GNU Public License


[ Top ]


Class Methods


constructor __construct [line 124]

kses5 __construct( )

Constructor for kses.

This sets a default collection of protocols allowed in links, and creates an empty set of allowed HTML tags.




Tags:

since:  PHP5 OOP 1.0.0
access:  public


[ Top ]

method AddHTML [line 448]

bool AddHTML( [string $tag = ""], [array $attribs = array()])

Adds valid (X)HTML with corresponding attributes that will be kept when stripping 'evil scripts'.

This method accepts one argument that can be either a string or an array of strings. Invalid data will be ignored.




Tags:

return:  Status of Adding (X)HTML and attributes.
since:  PHP4 OOP 0.0.1
access:  public


Parameters:

string   $tag   (X)HTML tag that will be allowed after stripping text.
array   $attribs   Associative array of allowed attributes - key => attribute name - value => attribute parameter

[ Top ]

method AddProtocol [line 240]

bool AddProtocol( [string $protocol = ""])

Adds a single protocol to $this->allowed_protocols.

This method accepts a string argument and adds it to the list of allowed protocols to keep when performing Parse().




Tags:

return:  Status of adding valid protocol.
since:  PHP4 OOP 0.0.1
access:  public


Parameters:

string   $protocol   The name of the protocol to be added.

[ Top ]

method AddProtocols [line 177]

bool AddProtocols( mixed 0)

Allows for single/batch addition of protocols

This method accepts one argument that can be either a string or an array of strings. Invalid data will be ignored.

The argument will be processed, and each string will be added via AddProtocol().




Tags:

return:  Status of adding valid protocols.
see:  kses5::AddProtocol()
since:  PHP5 OOP 1.0.0
access:  public


Parameters:

mixed   0   , A string or array of protocols that will be added to the internal list of allowed protocols.

[ Top ]

method DumpElements [line 430]

array DumpElements( )

Raw dump of allowed (X)HTML elements

This returns an indexed array of allowed (X)HTML elements and attributes for a particular KSES instantiation.




Tags:

return:  The list of allowed elements.
since:  PHP5 OOP 1.0.2
access:  public


[ Top ]

method DumpProtocols [line 415]

array DumpProtocols( )

Raw dump of allowed protocols

This returns an indexed array of allowed protocols for a particular KSES instantiation.




Tags:

return:  The list of allowed protocols.
since:  PHP5 OOP 1.0.2
access:  public


[ Top ]

method Parse [line 147]

string Parse( [string $string = ""])

Basic task of kses - parses $string and strips it as required.

This method strips all the disallowed (X)HTML tags, attributes and protocols from the input $string.




Tags:

return:  The stripped string
since:  PHP4 OOP 0.0.1
access:  public


Parameters:

string   $string   String to be stripped of 'evil scripts'

[ Top ]

method Protocols [line 216]

bool Protocols( )

Allows for single/batch addition of protocols



Tags:

see:  kses5::AddProtocols()
deprecated:  Use AddProtocols()
since:  PHP4 OOP 0.0.1
access:  public


[ Top ]

method RemoveProtocol [line 282]

bool RemoveProtocol( [string $protocol = ""])

Removes a single protocol from $this->allowed_protocols.

This method accepts a string argument and removes it from the list of allowed protocols to keep when performing Parse().




Tags:

return:  Status of removing valid protocol.
since:  PHP5 OOP 1.0.0
access:  public


Parameters:

string   $protocol   The name of the protocol to be removed.

[ Top ]

method RemoveProtocols [line 328]

bool RemoveProtocols( mixed 0)

Allows for single/batch removal of protocols

This method accepts one argument that can be either a string or an array of strings. Invalid data will be ignored.

The argument will be processed, and each string will be removed via RemoveProtocol().




Tags:

return:  Status of removing valid protocols.
see:  kses5::RemoveProtocol()
since:  PHP5 OOP 1.0.0
access:  public


Parameters:

mixed   0   , A string or array of protocols that will be removed from the internal list of allowed protocols.

[ Top ]

method SetProtocols [line 372]

bool SetProtocols( mixed 0)

Allows for single/batch replacement of protocols

This method accepts one argument that can be either a string or an array of strings. Invalid data will be ignored.

Existing protocols will be removed, then the argument will be processed, and each string will be added via AddProtocol().




Tags:

return:  Status of replacing valid protocols.
see:  kses5::AddProtocol()
since:  PHP5 OOP 1.0.1
access:  public


Parameters:

mixed   0   , A string or array of protocols that will be the new internal list of allowed protocols.

[ Top ]

method Version [line 1166]

string Version( )

Returns PHP5 OOP version # of kses.

Since this class has been refactored and documented and proven to work, I'm fixing the version number at 1.0.0.

This version is syntax compatible with the PHP4 OOP version 0.0.2. Future versions may not be syntax compatible.




Tags:

return:  Version number
since:  PHP4 OOP 0.0.1
access:  public


[ Top ]


Documentation generated on Wed, 05 Sep 2007 06:15:00 +0200 by phpDocumentor 1.4.0