diff --git a/Doxyfile b/Doxyfile index 62e0c5be..0095a193 100644 --- a/Doxyfile +++ b/Doxyfile @@ -14,75 +14,75 @@ # Project related configuration options #--------------------------------------------------------------------------- -# This tag specifies the encoding used for all characters in the config file that -# follow. The default is UTF-8 which is also the encoding used for all text before -# the first occurrence of this tag. Doxygen uses libiconv (or the iconv built into -# libc) for the transcoding. See http://www.gnu.org/software/libiconv for the list of +# This tag specifies the encoding used for all characters in the config file that +# follow. The default is UTF-8 which is also the encoding used for all text before +# the first occurrence of this tag. Doxygen uses libiconv (or the iconv built into +# libc) for the transcoding. See http://www.gnu.org/software/libiconv for the list of # possible encodings. DOXYFILE_ENCODING = UTF-8 -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded # by quotes) that should identify the project. PROJECT_NAME = HTMLPurifier -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or # if some version control system is used. PROJECT_NUMBER = 3.2.0 -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. OUTPUT_DIRECTORY = "docs/doxygen " -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 4096 sub-directories (in 2 levels) under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of -# source files, where putting all generated files in the same directory would +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would # otherwise cause performance problems for the file system. CREATE_SUBDIRS = NO -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, -# Croatian, Czech, Danish, Dutch, Finnish, French, German, Greek, Hungarian, -# Italian, Japanese, Japanese-en (Japanese with English messages), Korean, -# Korean-en, Lithuanian, Norwegian, Polish, Portuguese, Romanian, Russian, +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Finnish, French, German, Greek, Hungarian, +# Italian, Japanese, Japanese-en (Japanese with English messages), Korean, +# Korean-en, Lithuanian, Norwegian, Polish, Portuguese, Romanian, Russian, # Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian. OUTPUT_LANGUAGE = English -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). # Set to NO to disable this. BRIEF_MEMBER_DESC = YES -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. REPEAT_BRIEF = YES -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" # "represents" "a" "an" "the" ABBREVIATE_BRIEF = "The $name class " \ @@ -97,126 +97,126 @@ ABBREVIATE_BRIEF = "The $name class " \ an \ the -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief # description. ALWAYS_DETAILED_SEC = NO -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. INLINE_INHERITED_MEMB = NO -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. FULL_PATH_NAMES = YES -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the # path to strip. STRIP_FROM_PATH = "C:/Users/Edward/Webs/htmlpurifier " \ "C:/Documents and Settings/Edward/My Documents/My Webs/htmlpurifier " -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that # are normally passed to the compiler using the -I flag. -STRIP_FROM_INC_PATH = +STRIP_FROM_INC_PATH = -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful is your file systems +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful is your file systems # doesn't support long names like on DOS, Mac, or CD-ROM. SHORT_NAMES = NO -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like regular Qt-style comments +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments # (thus requiring an explicit @brief command for a brief description.) JAVADOC_AUTOBRIEF = YES -# If the QT_AUTOBRIEF tag is set to YES then Doxygen will -# interpret the first line (until the first dot) of a Qt-style -# comment as the brief description. If set to NO, the comments -# will behave just like regular Qt-style comments (thus requiring +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring # an explicit \brief command for a brief description.) QT_AUTOBRIEF = NO -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed # description. Set this tag to YES if you prefer the old behaviour instead. MULTILINE_CPP_IS_BRIEF = NO -# If the DETAILS_AT_TOP tag is set to YES then Doxygen +# If the DETAILS_AT_TOP tag is set to YES then Doxygen # will output the detailed description near the top, like JavaDoc. -# If set to NO, the detailed description appears after the member +# If set to NO, the detailed description appears after the member # documentation. DETAILS_AT_TOP = NO -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it # re-implements. INHERIT_DOCS = YES -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will # be part of the file/class/namespace that contains it. SEPARATE_MEMBER_PAGES = NO -# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# The TAB_SIZE tag can be used to set the number of spaces in a tab. # Doxygen uses this value to replace tabs by spaces in code fragments. TAB_SIZE = 4 -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". # You can put \n's in the value part of an alias to insert newlines. -ALIASES = +ALIASES = -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list # of all members will be omitted, etc. OPTIMIZE_OUTPUT_FOR_C = NO -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java -# sources only. Doxygen will then generate output that is more tailored for Java. -# For instance, namespaces will be presented as packages, qualified scopes +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for Java. +# For instance, namespaces will be presented as packages, qualified scopes # will look different, etc. OPTIMIZE_OUTPUT_JAVA = NO -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want to -# include (a tag file for) the STL sources as input, then you should -# set this tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. -# func(std::string) {}). This also make the inheritance and collaboration +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want to +# include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also make the inheritance and collaboration # diagrams that involve STL classes more complete and accurate. BUILTIN_STL_SUPPORT = NO @@ -226,17 +226,17 @@ BUILTIN_STL_SUPPORT = NO CPP_CLI_SUPPORT = NO -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. DISTRIBUTE_GROUP_DOC = NO -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using # the \nosubgrouping command. SUBGROUPING = YES @@ -245,289 +245,289 @@ SUBGROUPING = YES # Build related configuration options #--------------------------------------------------------------------------- -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES EXTRACT_ALL = YES -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. EXTRACT_PRIVATE = YES -# If the EXTRACT_STATIC tag is set to YES all static members of a file +# If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. EXTRACT_STATIC = YES -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. # If set to NO only classes defined in header files are included. EXTRACT_LOCAL_CLASSES = YES -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. # If set to NO (the default) only methods in the interface are included. EXTRACT_LOCAL_METHODS = NO -# If this flag is set to YES, the members of anonymous namespaces will be extracted -# and appear in the documentation as a namespace called 'anonymous_namespace{file}', -# where file will be replaced with the base name of the file that contains the anonymous +# If this flag is set to YES, the members of anonymous namespaces will be extracted +# and appear in the documentation as a namespace called 'anonymous_namespace{file}', +# where file will be replaced with the base name of the file that contains the anonymous # namespace. By default anonymous namespace are hidden. EXTRACT_ANON_NSPACES = NO -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. # This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_MEMBERS = NO -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_CLASSES = NO -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the # documentation. HIDE_FRIEND_COMPOUNDS = NO -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the # function's detailed documentation block. HIDE_IN_BODY_DOCS = NO -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. # Set it to YES to include the internal documentation. INTERNAL_DOCS = NO -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows # and Mac users are advised to set this option to NO. CASE_SENSE_NAMES = YES -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the # documentation. If set to YES the scope will be hidden. HIDE_SCOPE_NAMES = NO -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation # of that file. SHOW_INCLUDE_FILES = YES -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] # is inserted in the documentation for inline members. INLINE_INFO = YES -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in # declaration order. SORT_MEMBER_DOCS = YES -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in # declaration order. SORT_BRIEF_DOCS = NO -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the +# Note: This option applies only to the class list, not to the # alphabetical list. SORT_BY_SCOPE_NAME = NO -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo # commands in the documentation. GENERATE_TODOLIST = YES -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test # commands in the documentation. GENERATE_TESTLIST = YES -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug # commands in the documentation. GENERATE_BUGLIST = YES -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting # \deprecated commands in the documentation. GENERATE_DEPRECATEDLIST= YES -# The ENABLED_SECTIONS tag can be used to enable conditional +# The ENABLED_SECTIONS tag can be used to enable conditional # documentation sections, marked by \if sectionname ... \endif. -ENABLED_SECTIONS = +ENABLED_SECTIONS = -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or define consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and defines in the -# documentation can be controlled using \showinitializer or \hideinitializer +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or define consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and defines in the +# documentation can be controlled using \showinitializer or \hideinitializer # command in the documentation regardless of this setting. MAX_INITIALIZER_LINES = 30 -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the # list will mention the files that were used to generate the documentation. SHOW_USED_FILES = YES -# If the sources in your project are distributed over multiple directories -# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy +# If the sources in your project are distributed over multiple directories +# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy # in the documentation. The default is NO. SHOW_DIRECTORIES = NO -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from the -# version control system). Doxygen will invoke the program by executing (via -# popen()) the command , where is the value of -# the FILE_VERSION_FILTER tag, and is the name of an input file -# provided by doxygen. Whatever the program writes to standard output +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from the +# version control system). Doxygen will invoke the program by executing (via +# popen()) the command , where is the value of +# the FILE_VERSION_FILTER tag, and is the name of an input file +# provided by doxygen. Whatever the program writes to standard output # is used as the file version. See the manual for examples. -FILE_VERSION_FILTER = +FILE_VERSION_FILTER = #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- -# The QUIET tag can be used to turn on/off the messages that are generated +# The QUIET tag can be used to turn on/off the messages that are generated # by doxygen. Possible values are YES and NO. If left blank NO is used. QUIET = NO -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank # NO is used. WARNINGS = YES -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will # automatically be disabled. WARN_IF_UNDOCUMENTED = YES -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that # don't exist or using markup commands wrongly. WARN_IF_DOC_ERROR = YES -# This WARN_NO_PARAMDOC option can be abled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of +# This WARN_NO_PARAMDOC option can be abled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of # documentation. WARN_NO_PARAMDOC = NO -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could # be obtained via FILE_VERSION_FILTER) WARN_FORMAT = "$file:$line: $text " -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written # to stderr. -WARN_LOGFILE = +WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories # with spaces. INPUT = ". " -# This tag can be used to specify the character encoding of the source files that -# doxygen parses. Internally doxygen uses the UTF-8 encoding, which is also the default -# input encoding. Doxygen uses libiconv (or the iconv built into libc) for the transcoding. +# This tag can be used to specify the character encoding of the source files that +# doxygen parses. Internally doxygen uses the UTF-8 encoding, which is also the default +# input encoding. Doxygen uses libiconv (or the iconv built into libc) for the transcoding. # See http://www.gnu.org/software/libiconv for the list of possible encodings. INPUT_ENCODING = UTF-8 -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx # *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py FILE_PATTERNS = *.php -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. RECURSIVE = YES -# The EXCLUDE tag can be used to specify files and/or directories that should -# excluded from the INPUT source files. This way you can easily exclude a +# The EXCLUDE tag can be used to specify files and/or directories that should +# excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. -EXCLUDE = +EXCLUDE = -# The EXCLUDE_SYMLINKS tag can be used select whether or not files or -# directories that are symbolic links (a Unix filesystem feature) are excluded +# The EXCLUDE_SYMLINKS tag can be used select whether or not files or +# directories that are symbolic links (a Unix filesystem feature) are excluded # from the input. EXCLUDE_SYMLINKS = NO -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories # for example use the pattern */test/* EXCLUDE_PATTERNS = */tests/* \ @@ -542,60 +542,60 @@ EXCLUDE_PATTERNS = */tests/* \ */.svn* \ */conf/* -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the output. -# The symbol name can be a fully qualified name, a word, or if the wildcard * is used, +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the output. +# The symbol name can be a fully qualified name, a word, or if the wildcard * is used, # a substring. Examples: ANamespace, AClass, AClass::ANamespace, ANamespace::*Test -EXCLUDE_SYMBOLS = +EXCLUDE_SYMBOLS = -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see # the \include command). -EXAMPLE_PATH = +EXAMPLE_PATH = -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left # blank all files are included. EXAMPLE_PATTERNS = * -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. EXAMPLE_RECURSIVE = NO -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see # the \image command). -IMAGE_PATH = +IMAGE_PATH = -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. If FILTER_PATTERNS is specified, this tag will be +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. If FILTER_PATTERNS is specified, this tag will be # ignored. -INPUT_FILTER = +INPUT_FILTER = -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER # is applied to all files. -FILTER_PATTERNS = +FILTER_PATTERNS = -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source # files to browse (i.e. when SOURCE_BROWSER is set to YES). FILTER_SOURCE_FILES = NO @@ -604,34 +604,34 @@ FILTER_SOURCE_FILES = NO # configuration options related to source browsing #--------------------------------------------------------------------------- -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also -# VERBATIM_HEADERS is set to NO. If you have enabled CALL_GRAPH or CALLER_GRAPH -# then you must also enable this option. If you don't then doxygen will produce +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. If you have enabled CALL_GRAPH or CALLER_GRAPH +# then you must also enable this option. If you don't then doxygen will produce # a warning and turn it on anyway SOURCE_BROWSER = YES -# Setting the INLINE_SOURCES tag to YES will include the body +# Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation. INLINE_SOURCES = NO -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code # fragments. Normal C and C++ comments will always remain visible. STRIP_CODE_COMMENTS = YES -# If the REFERENCED_BY_RELATION tag is set to YES (the default) -# then for each documented function all documented +# If the REFERENCED_BY_RELATION tag is set to YES (the default) +# then for each documented function all documented # functions referencing it will be listed. REFERENCED_BY_RELATION = YES -# If the REFERENCES_RELATION tag is set to YES (the default) -# then for each documented function all documented entities +# If the REFERENCES_RELATION tag is set to YES (the default) +# then for each documented function all documented entities # called/used by that function will be listed. REFERENCES_RELATION = YES @@ -643,16 +643,16 @@ REFERENCES_RELATION = YES REFERENCES_LINK_SOURCE = YES -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You # will need version 4.8.6 or higher. USE_HTAGS = NO -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for # which an include is specified. Set to NO to disable this. VERBATIM_HEADERS = YES @@ -661,141 +661,141 @@ VERBATIM_HEADERS = YES # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project # contains a lot of classes, structs, unions or interfaces. ALPHABETICAL_INDEX = NO -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) COLS_IN_ALPHA_INDEX = 5 -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that # should be ignored while generating the index headers. -IGNORE_PREFIX = +IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will # generate HTML output. GENERATE_HTML = YES -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `html' will be used as the default path. HTML_OUTPUT = html -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank # doxygen will generate files with .html extension. HTML_FILE_EXTENSION = .html -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a # standard header. -HTML_HEADER = +HTML_HEADER = -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a # standard footer. -HTML_FOOTER = +HTML_FOOTER = -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet. Note that doxygen will try to copy -# the style sheet file to the HTML output directory, so don't put your own +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own # stylesheet in the HTML output directory as well, or it will be erased! -HTML_STYLESHEET = +HTML_STYLESHEET = -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, +# files or namespaces will be aligned in HTML using tables. If set to # NO a bullet list will be used. HTML_ALIGN_MEMBERS = YES -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) # of the generated HTML documentation. GENERATE_HTMLHELP = NO -# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML -# documentation will contain sections that can be hidden and shown after the -# page has loaded. For this to work a browser that supports -# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. For this to work a browser that supports +# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox # Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). HTML_DYNAMIC_SECTIONS = NO -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be # written to the html output directory. -CHM_FILE = +CHM_FILE = -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run # the HTML help compiler on the generated index.hhp. -HHC_LOCATION = +HHC_LOCATION = -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that # it should be included in the master .chm file (NO). GENERATE_CHI = NO -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a # normal table of contents (NO) in the .chm file. BINARY_TOC = NO -# The TOC_EXPAND flag can be set to YES to add extra items for group members +# The TOC_EXPAND flag can be set to YES to add extra items for group members # to the contents of the HTML help documentation and to the tree view. TOC_EXPAND = NO -# The DISABLE_INDEX tag can be used to turn on/off the condensed index at -# top of each HTML page. The value NO (the default) enables the index and +# The DISABLE_INDEX tag can be used to turn on/off the condensed index at +# top of each HTML page. The value NO (the default) enables the index and # the value YES disables it. DISABLE_INDEX = NO -# This tag can be used to set the number of enum values (range [1..20]) +# This tag can be used to set the number of enum values (range [1..20]) # that doxygen will group on one line in the generated HTML documentation. ENUM_VALUES_PER_LINE = 4 # If the GENERATE_TREEVIEW tag is set to YES, a side panel will be -# generated containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, -# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are +# generated containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, +# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are # probably better off using the HTML help feature. GENERATE_TREEVIEW = YES -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree # is shown. TREEVIEW_WIDTH = 250 @@ -804,74 +804,74 @@ TREEVIEW_WIDTH = 250 # configuration options related to the LaTeX output #--------------------------------------------------------------------------- -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. GENERATE_LATEX = NO -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `latex' will be used as the default path. LATEX_OUTPUT = latex -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. If left blank `latex' will be used as the default command name. LATEX_CMD_NAME = latex -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the # default command name. MAKEINDEX_CMD_NAME = makeindex -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_LATEX = NO -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, a4wide, letter, legal and +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, a4wide, letter, legal and # executive. If left blank a4wide will be used. PAPER_TYPE = a4wide -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX # packages that should be included in the LaTeX output. -EXTRA_PACKAGES = +EXTRA_PACKAGES = -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a # standard header. Notice: only use this tag if you know what you are doing! -LATEX_HEADER = +LATEX_HEADER = -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references # This makes the output suitable for online browsing using a pdf viewer. PDF_HYPERLINKS = YES -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a # higher quality PDF documentation. USE_PDFLATEX = YES -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. # This option is also used when generating formulas in HTML. LATEX_BATCHMODE = NO -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) # in the output. LATEX_HIDE_INDICES = NO @@ -880,68 +880,68 @@ LATEX_HIDE_INDICES = NO # configuration options related to the RTF output #--------------------------------------------------------------------------- -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimized for Word 97 and may not look very pretty with +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with # other RTF readers or editors. GENERATE_RTF = NO -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `rtf' will be used as the default path. RTF_OUTPUT = rtf -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_RTF = NO -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. # Note: wordpad (write) and others do not support links. RTF_HYPERLINKS = NO -# Load stylesheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assignments. You only have to provide +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide # replacements, missing definitions are set to their default value. -RTF_STYLESHEET_FILE = +RTF_STYLESHEET_FILE = -# Set optional variables used in the generation of an rtf document. +# Set optional variables used in the generation of an rtf document. # Syntax is similar to doxygen's config file. -RTF_EXTENSIONS_FILE = +RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will # generate man pages GENERATE_MAN = NO -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `man' will be used as the default path. MAN_OUTPUT = man -# The MAN_EXTENSION tag determines the extension that is added to +# The MAN_EXTENSION tag determines the extension that is added to # the generated man pages (default is the subroutine's section .3) MAN_EXTENSION = .3 -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command # would be unable to find the correct page. The default is NO. MAN_LINKS = NO @@ -950,33 +950,33 @@ MAN_LINKS = NO # configuration options related to the XML output #--------------------------------------------------------------------------- -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of # the code including all documentation. GENERATE_XML = NO -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `xml' will be used as the default path. XML_OUTPUT = xml -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the # syntax of the XML files. -XML_SCHEMA = +XML_SCHEMA = -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the # syntax of the XML files. -XML_DTD = +XML_DTD = -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that # enabling this will significantly increase the size of the XML output. XML_PROGRAMLISTING = YES @@ -985,10 +985,10 @@ XML_PROGRAMLISTING = YES # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental # and incomplete at the moment. GENERATE_AUTOGEN_DEF = NO @@ -997,319 +997,319 @@ GENERATE_AUTOGEN_DEF = NO # configuration options related to the Perl module output #--------------------------------------------------------------------------- -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the # moment. GENERATE_PERLMOD = NO -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able # to generate PDF and DVI output from the Perl module output. PERLMOD_LATEX = NO -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. This is useful -# if you want to understand what is going on. On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. This is useful +# if you want to understand what is going on. On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller # and Perl will parse it just the same. PERLMOD_PRETTY = YES -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same # Makefile don't overwrite each other's variables. -PERLMOD_MAKEVAR_PREFIX = +PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- -# Configuration options related to the preprocessor +# Configuration options related to the preprocessor #--------------------------------------------------------------------------- -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include # files. ENABLE_PREPROCESSING = YES -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled # way by setting EXPAND_ONLY_PREDEF to YES. MACRO_EXPANSION = NO -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the # PREDEFINED and EXPAND_AS_DEFINED tags. EXPAND_ONLY_PREDEF = NO -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files # in the INCLUDE_PATH (see below) will be search if a #include is found. SEARCH_INCLUDES = YES -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by # the preprocessor. -INCLUDE_PATH = +INCLUDE_PATH = -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will # be used. -INCLUDE_FILE_PATTERNS = +INCLUDE_FILE_PATTERNS = -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. To prevent a macro definition from being -# undefined via #undef or recursively expanded use the := operator +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator # instead of the = operator. -PREDEFINED = +PREDEFINED = -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. # Use the PREDEFINED tag if you want to use a different macro definition. -EXPAND_AS_DEFINED = +EXPAND_AS_DEFINED = -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all function-like macros that are alone -# on a line, have an all uppercase name, and do not end with a semicolon. Such -# function macros are typically used for boiler-plate code, and will confuse +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all function-like macros that are alone +# on a line, have an all uppercase name, and do not end with a semicolon. Such +# function macros are typically used for boiler-plate code, and will confuse # the parser if not removed. SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- -# Configuration::additions related to external references +# Configuration::additions related to external references #--------------------------------------------------------------------------- -# The TAGFILES option can be used to specify one or more tagfiles. -# Optionally an initial location of the external documentation -# can be added for each tagfile. The format of a tag file without -# this location is as follows: -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths or -# URLs. If a location is present for each tag, the installdox tool +# The TAGFILES option can be used to specify one or more tagfiles. +# Optionally an initial location of the external documentation +# can be added for each tagfile. The format of a tag file without +# this location is as follows: +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths or +# URLs. If a location is present for each tag, the installdox tool # does not have to be run to correct the links. # Note that each tag file must have a unique name # (where the name does NOT include the path) -# If a tag file is not located in the directory in which doxygen +# If a tag file is not located in the directory in which doxygen # is run, you must also specify the path to the tagfile here. -TAGFILES = +TAGFILES = -# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# When a file name is specified after GENERATE_TAGFILE, doxygen will create # a tag file that is based on the input files it reads. -GENERATE_TAGFILE = +GENERATE_TAGFILE = -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes # will be listed. ALLEXTERNALS = NO -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will # be listed. EXTERNAL_GROUPS = YES -# The PERL_PATH should be the absolute path and name of the perl script +# The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- -# Configuration options related to the dot tool +# Configuration options related to the dot tool #--------------------------------------------------------------------------- -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base -# or super classes. Setting the tag to NO turns the diagrams off. Note that -# this option is superseded by the HAVE_DOT option below. This is only a -# fallback. It is recommended to install and use dot, since it yields more +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option is superseded by the HAVE_DOT option below. This is only a +# fallback. It is recommended to install and use dot, since it yields more # powerful graphs. CLASS_DIAGRAMS = YES -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see http://www.mcternan.me.uk/mscgen/) to -# produce the chart and insert it in the documentation. The MSCGEN_PATH tag allows you to -# specify the directory where the mscgen tool resides. If left empty the tool is assumed to +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see http://www.mcternan.me.uk/mscgen/) to +# produce the chart and insert it in the documentation. The MSCGEN_PATH tag allows you to +# specify the directory where the mscgen tool resides. If left empty the tool is assumed to # be found in the default search path. -MSCGEN_PATH = +MSCGEN_PATH = -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented # or is not a class. HIDE_UNDOC_RELATIONS = YES -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) HAVE_DOT = NO -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the # the CLASS_DIAGRAMS tag to NO. CLASS_GRAPH = YES -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and # class references variables) of the class with other documented classes. COLLABORATION_GRAPH = YES -# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen # will generate a graph for groups, showing the direct groups dependencies GROUP_GRAPHS = YES -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling # Language. UML_LOOK = NO -# If set to YES, the inheritance and collaboration graphs will show the +# If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. TEMPLATE_RELATIONS = NO -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with # other documented files. INCLUDE_GRAPH = YES -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or # indirectly include this file. INCLUDED_BY_GRAPH = YES -# If the CALL_GRAPH, SOURCE_BROWSER and HAVE_DOT tags are set to YES then doxygen will -# generate a call dependency graph for every global function or class method. -# Note that enabling this option will significantly increase the time of a run. -# So in most cases it will be better to enable call graphs for selected +# If the CALL_GRAPH, SOURCE_BROWSER and HAVE_DOT tags are set to YES then doxygen will +# generate a call dependency graph for every global function or class method. +# Note that enabling this option will significantly increase the time of a run. +# So in most cases it will be better to enable call graphs for selected # functions only using the \callgraph command. CALL_GRAPH = NO -# If the CALLER_GRAPH, SOURCE_BROWSER and HAVE_DOT tags are set to YES then doxygen will -# generate a caller dependency graph for every global function or class method. -# Note that enabling this option will significantly increase the time of a run. -# So in most cases it will be better to enable caller graphs for selected +# If the CALLER_GRAPH, SOURCE_BROWSER and HAVE_DOT tags are set to YES then doxygen will +# generate a caller dependency graph for every global function or class method. +# Note that enabling this option will significantly increase the time of a run. +# So in most cases it will be better to enable caller graphs for selected # functions only using the \callergraph command. CALLER_GRAPH = NO -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen # will graphical hierarchy of all classes instead of a textual one. GRAPHICAL_HIERARCHY = YES -# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES -# then doxygen will show the dependencies a directory has on other directories +# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories # in a graphical way. The dependency relations are determined by the #include # relations between the files in the directories. DIRECTORY_GRAPH = YES -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images # generated by dot. Possible values are png, jpg, or gif # If left blank png will be used. DOT_IMAGE_FORMAT = png -# The tag DOT_PATH can be used to specify the path where the dot tool can be +# The tag DOT_PATH can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found in the path. -DOT_PATH = +DOT_PATH = -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the # \dotfile command). -DOTFILE_DIRS = +DOTFILE_DIRS = -# The MAX_DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of -# nodes that will be shown in the graph. If the number of nodes in a graph -# becomes larger than this value, doxygen will truncate the graph, which is -# visualized by representing a node as a red box. Note that doxygen if the number -# of direct children of the root node in a graph is already larger than -# MAX_DOT_GRAPH_NOTES then the graph will not be shown at all. Also note +# The MAX_DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the number +# of direct children of the root node in a graph is already larger than +# MAX_DOT_GRAPH_NOTES then the graph will not be shown at all. Also note # that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. DOT_GRAPH_MAX_NODES = 50 -# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the -# graphs generated by dot. A depth value of 3 means that only nodes reachable -# from the root by following a path via at most 3 edges will be shown. Nodes -# that lay further from the root node will be omitted. Note that setting this -# option to 1 or 2 may greatly reduce the computation time needed for large -# code bases. Also note that the size of a graph can be further restricted by +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by # DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. MAX_DOT_GRAPH_DEPTH = 1000 -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, which results in a white background. -# Warning: Depending on the platform used, enabling this option may lead to -# badly anti-aliased labels on the edges of a graph (i.e. they become hard to +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, which results in a white background. +# Warning: Depending on the platform used, enabling this option may lead to +# badly anti-aliased labels on the edges of a graph (i.e. they become hard to # read). DOT_TRANSPARENT = NO -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output -# files in one run (i.e. multiple -o and -T options on the command line). This -# makes dot run faster, but since only newer versions of dot (>1.8.10) +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) # support this, this feature is disabled by default. DOT_MULTI_TARGETS = NO -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and # arrows in the dot generated graphs. GENERATE_LEGEND = YES -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate # the various graphs. DOT_CLEANUP = YES #--------------------------------------------------------------------------- -# Configuration::additions related to the search engine +# Configuration::additions related to the search engine #--------------------------------------------------------------------------- -# The SEARCHENGINE tag specifies whether or not a search engine should be +# The SEARCHENGINE tag specifies whether or not a search engine should be # used. If set to NO the values of all tags below this one will be ignored. SEARCHENGINE = NO diff --git a/INSTALL b/INSTALL index 5d3ace64..0a21da73 100644 --- a/INSTALL +++ b/INSTALL @@ -2,8 +2,8 @@ Install How to install HTML Purifier -HTML Purifier is designed to run out of the box, so actually using the -library is extremely easy. (Although... if you were looking for a +HTML Purifier is designed to run out of the box, so actually using the +library is extremely easy. (Although... if you were looking for a step-by-step installation GUI, you've downloaded the wrong software!) While the impatient can get going immediately with some of the sample @@ -15,9 +15,9 @@ with these contents. --------------------------------------------------------------------------- 1. Compatibility -HTML Purifier is PHP 5 only, and is actively tested from PHP 5.0.5 and -up. It has no core dependencies with other libraries. PHP -4 support was deprecated on December 31, 2007 with HTML Purifier 3.0.0. +HTML Purifier is PHP 5 only, and is actively tested from PHP 5.0.5 and +up. It has no core dependencies with other libraries. PHP +4 support was deprecated on December 31, 2007 with HTML Purifier 3.0.0. These optional extensions can enhance the capabilities of HTML Purifier: @@ -94,32 +94,32 @@ Autoload compatibility HTML Purifier attempts to be as smart as possible when registering an autoloader, but there are some cases where you will need to change your own code to accomodate HTML Purifier. These are those cases: - + PHP VERSION IS LESS THAN 5.1.2, AND YOU'VE DEFINED __autoload Because spl_autoload_register() doesn't exist in early versions of PHP 5, HTML Purifier has no way of adding itself to the autoload stack. Modify your __autoload function to test HTMLPurifier_Bootstrap::autoload($class) - + For example, suppose your autoload function looks like this: - + function __autoload($class) { require str_replace('_', '/', $class) . '.php'; return true; } - + A modified version with HTML Purifier would look like this: - + function __autoload($class) { if (HTMLPurifier_Bootstrap::autoload($class)) return true; require str_replace('_', '/', $class) . '.php'; return true; } - + Note that there *is* some custom behavior in our autoloader; the original autoloader in our example would work for 99% of the time, but would fail when including language files. - + AN __autoload FUNCTION IS DECLARED AFTER OUR AUTOLOADER IS REGISTERED spl_autoload_register() has the curious behavior of disabling the existing __autoload() handler. Users need to explicitly @@ -129,14 +129,14 @@ Autoload compatibility HTML Purifier will register the function for you. But if it is declared afterwards, it will mysteriously not work. This snippet of code (after your autoloader is defined) will fix it: - + spl_autoload_register('__autoload') - + Users should also be on guard if they use a version of PHP previous to 5.1.2 without an autoloader--HTML Purifier will define __autoload() for you, which can collide with an autoloader that was added by *you* later. - + For better performance ---------------------- @@ -145,18 +145,18 @@ For better performance with large amounts of code (HTML Purifier included), don't like autoloaders. We offer an include file that includes all of HTML Purifier's files in one go in an opcode cache friendly manner: - + // If /path/to/library isn't already in your include path, uncomment // the below line: // require '/path/to/library/HTMLPurifier.path.php'; - + require 'HTMLPurifier.includes.php'; - + Optional components still need to be included--you'll know if you try to use a feature and you get a class doesn't exists error! The autoloader can be used in conjunction with this approach to catch classes that are missing. Simply add this afterwards: - + require 'HTMLPurifier.autoload.php'; Standalone version @@ -167,22 +167,22 @@ Standalone version maintenance/generate-standalone.php . The standalone version has the benefit of having most of its code in one file, so parsing is much faster and the library is easier to manage. - + If HTMLPurifier.standalone.php exists in the library directory, you can use it like this: - + require '/path/to/HTMLPurifier.standalone.php'; - + This is equivalent to including HTMLPurifier.includes.php, except that the contents of standalone/ will be added to your path. To override this behavior, specify a new HTMLPURIFIER_PREFIX where standalone files can be found (usually, this will be one directory up, the "true" library directory in full distributions). Don't forget to set your path too! - + The autoloader can be added to the end to ensure the classes are loaded when necessary; otherwise you can manually include them. To use the autoloader, use this: - + require 'HTMLPurifier.autoload.php'; For advanced users @@ -190,14 +190,14 @@ For advanced users HTMLPurifier.auto.php performs a number of operations that can be done individually. These are: - + HTMLPurifier.path.php Puts /path/to/library in the include path. For high performance, this should be done in php.ini. - + HTMLPurifier.autoload.php Registers our autoload handler HTMLPurifier_Bootstrap::autoload($class). - + You can do these operations by yourself--in fact, you must modify your own autoload handler if you are using a version of PHP earlier than PHP 5.1.2 (See "Autoload compatibility" above). @@ -352,7 +352,7 @@ If your website is in UTF-8 and XHTML Transitional, use this code: purify($dirty_html); ?> @@ -361,12 +361,12 @@ If your website is in a different encoding or doctype, use this code: set('Core', 'Encoding', 'ISO-8859-1'); // replace with your encoding $config->set('HTML', 'Doctype', 'HTML 4.01 Transitional'); // replace with your doctype $purifier = new HTMLPurifier($config); - + $clean_html = $purifier->purify($dirty_html); ?> diff --git a/INSTALL.fr.utf8 b/INSTALL.fr.utf8 index 187848ff..ae0fcd20 100644 --- a/INSTALL.fr.utf8 +++ b/INSTALL.fr.utf8 @@ -20,7 +20,7 @@ ce document pour quelques choses. HTML Purifier fonctionne dans PHP 5. PHP 5.0.5 est le dernier version que je le testais. Il ne dépend de les autre librairies. -Les extensions optionnel est iconv (en général déjà installer) et +Les extensions optionnel est iconv (en général déjà installer) et tidy (répandu aussi). Si vous utilisez UTF-8 et ne voulez pas l'indentation, vous pouvez utiliser HTML Purifier sans ces extensions. @@ -48,7 +48,7 @@ Si votre site web est en UTF-8 et XHTML Transitional, utilisez: purify($html_salle); ?> @@ -57,11 +57,11 @@ Sinon, utilisez: set('Core', 'Encoding', 'ISO-8859-1'); //remplacez avec votre encoding $config->set('Core', 'XHTML', true); //remplacez avec false si HTML 4.01 $purificateur = new HTMLPurifier($config); - + $html_propre = $purificateur->purify($html_salle); ?> \ No newline at end of file diff --git a/LICENSE b/LICENSE index 5ab7695a..602bfc94 100644 --- a/LICENSE +++ b/LICENSE @@ -146,7 +146,7 @@ such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. - + 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an diff --git a/NEWS b/NEWS index 1d3b5877..af367417 100644 --- a/NEWS +++ b/NEWS @@ -34,7 +34,7 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier deal with a bug in FCKEditor. Requested by frank farmer. ! Enable HTML comments when %HTML.Trusted is on. Requested by Waldo Jaquith. ! Proper support for name attribute. It is now allowed and equivalent to the id - attribute in a and img tags, and is only converted to id when %HTML.TidyLevel + attribute in a and img tags, and is only converted to id when %HTML.TidyLevel is heavy (for all doctypes). ! %AutoFormat.RemoveEmpty to remove some empty tags from documents. Please don't use on hand-written HTML. @@ -45,7 +45,7 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier ! Test scripts now have a 'type' parameter, which lets you say 'htmlpurifier', 'phpt', 'vtest', etc. in order to only execute those tests. This supercedes the --only-phpt parameter, although for backwards-compatibility the flag - will still work. + will still work. ! AutoParagraph auto-formatter will now preserve double-newlines upon output. Users who are not performing inbound filtering, this may seem a little useless, but as a bonus, the test suite and handling of edge cases is also @@ -89,7 +89,7 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier for more interesting filter-backtracking . New HTMLPurifier_Injector->rewind() functionality, allows injectors to rewind index to reprocess tokens. -. StringHashParser now allows for multiline sections with "empty" content; +. StringHashParser now allows for multiline sections with "empty" content; previously the section would remain undefined. . Added --quick option to multitest.php, which tests only the most recent release for each series. @@ -98,7 +98,7 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier 3.1.1, released 2008-06-19 # %URI.Munge now, by default, does not munge resources (for example, ) - In order to enable this again, please set %URI.MungeResources to true. + In order to enable this again, please set %URI.MungeResources to true. ! More robust imagecrash protection with height/width CSS with %CSS.MaxImgLength, and height/width HTML with %HTML.MaxImgLength. ! %URI.MungeSecretKey for secure URI munging. Thanks Chris @@ -108,7 +108,7 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier %URI.MungeSecretKey and and %URI.SecureMunge => %URI.Munge) ! Implemented post URI filtering. Set member variable $post to true to set a URIFilter as such. -! Allow modules to define injectors via $info_injector. Injectors are +! Allow modules to define injectors via $info_injector. Injectors are automatically disabled if injector's needed elements are not found. ! Support for "safe" objects added, use %HTML.SafeObject and %HTML.SafeEmbed. Thanks Chris for sponsoring. If you've been using ad hoc code from the @@ -155,10 +155,10 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier consult changes to HTMLPurifier_Config for details. . Variable parsing types now are magic integers instead of strings . Added benchmark for ConfigSchema -. HTMLPurifier_Generator requires $config and $context parameters. If you +. HTMLPurifier_Generator requires $config and $context parameters. If you don't know what they should be, use HTMLPurifier_Config::createDefault() and new HTMLPurifier_Context(). -. Printers now properly distinguish between output configuration, and +. Printers now properly distinguish between output configuration, and target configuration. This is not applicable to scripts using the Printers for HTML Purifier related tasks. . HTML/CSS Printers must be primed with prepareGenerator($gen_config), otherwise @@ -245,7 +245,7 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier enabled using %Filter.$filter_name or by setting your own filters using %Filter.Custom # Directive-level safety properties superceded in favor of module-level - safety. Internal method HTMLModule->addElement() has changed, although + safety. Internal method HTMLModule->addElement() has changed, although the externally visible HTMLDefinition->addElement has *not* changed. ! Extra utility classes for testing and non-library operations can be found in extras/. Specifically, these are FSTools and ConfigDoc. @@ -285,7 +285,7 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier . Dry runs now supported in SimpleTest; testing facilities improved . Bootstrap class added for handling autoloading functionality . Implemented recursive glob at FSTools->globr -. ConfigSchema now has instance methods for all corresponding define* +. ConfigSchema now has instance methods for all corresponding define* static methods. . A couple of new historical maintenance scripts were added. . HTMLPurifier/HTMLModule/Tidy/XHTMLAndHTML4.php split into two files @@ -306,7 +306,7 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier . HTMLPurifier_ConfigSchema->validate() deprecated in favor of HTMLPurifier_VarParser->parse() . Integers auto-cast into float type by VarParser. -. HTMLPURIFIER_STRICT removed; no validation is performed on runtime, only +. HTMLPURIFIER_STRICT removed; no validation is performed on runtime, only during cache generation . Reordered script calls in maintenance/flush.php . Command line scripts now honor exit codes @@ -348,7 +348,7 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier script (you must provide this script!) - Fixed poor include ordering for Email URI AttrDefs, causes fatal errors on some systems. -- Injector algorithm further refined: off-by-one error regarding skip +- Injector algorithm further refined: off-by-one error regarding skip counts for dormant injectors fixed - Corrective blockquote definition now enabled for HTML 4.01 Strict - Fatal error when tag (or any other element with required attributes) @@ -373,7 +373,7 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier facilities in PHP 5 - Make ErrorCollectorEMock work in both PHP 4 and PHP 5 - Make PH5P work with PHP 5.0 by removing unnecessary array parameter typedef -. %Core.AcceptFullDocuments renamed to %Core.ConvertDocumentToFragment +. %Core.AcceptFullDocuments renamed to %Core.ConvertDocumentToFragment to better communicate its purpose . Error unit tests can now specify the expectation of no errors. Future iterations of the harness will be extremely strict about what errors @@ -532,7 +532,7 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier and better modularization # Configuration object now finalizes itself when a read operation is performed on it, ensuring that its internal state stays consistent. - To revert this behavior, you can set the $autoFinalize member variable + To revert this behavior, you can set the $autoFinalize member variable off, but it's not recommended. # New compact syntax for AttrDef objects that can be used to instantiate new objects via make() @@ -616,7 +616,7 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier AttrTransform_EnumToCSS, refer to HTMLModule/TransformToStrict.php to see how the new equivalent is implemented . Unit tests now use exclusively assertIdentical - + 1.6.0, released 2007-04-01 ! Support for most common deprecated attributes via transformations: + bgcolor in td, th, tr and table diff --git a/README b/README index 5bfd5e40..dacaceb0 100644 --- a/README +++ b/README @@ -2,15 +2,15 @@ README All about HTML Purifier -HTML Purifier is an HTML filtering solution that uses a unique combination -of robust whitelists and agressive parsing to ensure that not only are -XSS attacks thwarted, but the resulting HTML is standards compliant. +HTML Purifier is an HTML filtering solution that uses a unique combination +of robust whitelists and agressive parsing to ensure that not only are +XSS attacks thwarted, but the resulting HTML is standards compliant. -HTML Purifier is oriented towards richly formatted documents from -untrusted sources that require CSS and a full tag-set. This library can -be configured to accept a more restrictive set of tags, but it won't be -as efficient as more bare-bones parsers. It will, however, do the job -right, which may be more important. +HTML Purifier is oriented towards richly formatted documents from +untrusted sources that require CSS and a full tag-set. This library can +be configured to accept a more restrictive set of tags, but it won't be +as efficient as more bare-bones parsers. It will, however, do the job +right, which may be more important. Places to go: diff --git a/TODO b/TODO index 34754bf5..0860c6a1 100644 --- a/TODO +++ b/TODO @@ -65,7 +65,7 @@ FUTURE VERSIONS - Lots of documentation and samples Ongoing - - More refactoring to take advantage of PHP5's facilities + - More refactoring to take advantage of PHP5's facilities - Refactor unit tests into lots of test methods - Plugins for major CMSes (COMPLEX) - phpBB diff --git a/WHATSNEW b/WHATSNEW index e7852737..bfd98d02 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -1,6 +1,6 @@ HTML Purifier 3.2.0 is an amalgamation of new features and fixes that have accumulated over a four month period. Some notable features -include %AutoFormat.RemoveEmpty, column tracking for tokens, +include %AutoFormat.RemoveEmpty, column tracking for tokens, %AutoFormat.DisplayLinkURI and %Attr.DefaultImageAlt. There were also major improvements to the test suite interface, error collection output and the auto-formatter framework. diff --git a/benchmarks/Lexer.php b/benchmarks/Lexer.php index 8edd0921..07a83618 100644 --- a/benchmarks/Lexer.php +++ b/benchmarks/Lexer.php @@ -9,7 +9,7 @@ require_once 'Text/Password.php'; // for generating random input $LEXERS = array(); $RUNS = isset($GLOBALS['HTMLPurifierTest']['Runs']) - ? $GLOBALS['HTMLPurifierTest']['Runs'] : 2; + ? $GLOBALS['HTMLPurifierTest']['Runs'] : 2; require_once 'HTMLPurifier/Lexer/DirectLex.php'; $LEXERS['DirectLex'] = new HTMLPurifier_Lexer_DirectLex(); @@ -22,48 +22,48 @@ if (version_compare(PHP_VERSION, '5', '>=')) { // custom class to aid unit testing class RowTimer extends Benchmark_Timer { - + var $name; - + function RowTimer($name, $auto = false) { $this->name = htmlentities($name); $this->Benchmark_Timer($auto); } - + function getOutput() { $total = $this->TimeElapsed(); $result = $this->getProfiling(); $dashes = ''; - + $out = ''; - + $out .= "{$this->name}"; - + $standard = false; - + foreach ($result as $k => $v) { if ($v['name'] == 'Start' || $v['name'] == 'Stop') continue; - + //$perc = (($v['diff'] * 100) / $total); //$tperc = (($v['total'] * 100) / $total); - + //$out .= '' . $v['diff'] . ''; - + if ($standard == false) $standard = $v['diff']; - + $perc = $v['diff'] * 100 / $standard; $bad_run = ($v['diff'] < 0); - + $out .= '' . number_format($perc, 2, '.', '') . '%'.number_format($v['diff'],4,'.','').''; - + } - + $out .= ''; - + return $out; } } @@ -80,18 +80,18 @@ function print_lexers() { function do_benchmark($name, $document) { global $LEXERS, $RUNS; - + $config = HTMLPurifier_Config::createDefault(); $context = new HTMLPurifier_Context(); - + $timer = new RowTimer($name); $timer->start(); - + foreach($LEXERS as $key => $lexer) { for ($i=0; $i<$RUNS; $i++) $tokens = $lexer->tokenizeHTML($document, $config, $context); $timer->setMarker($key); } - + $timer->stop(); $timer->display(); } @@ -118,11 +118,11 @@ foreach ($LEXERS as $key => $value) { $dir = 'samples/Lexer'; $dh = opendir($dir); while (false !== ($filename = readdir($dh))) { - + if (strpos($filename, '.html') !== strlen($filename) - 5) continue; $document = file_get_contents($dir . '/' . $filename); do_benchmark("File: $filename", $document); - + } // crashers, caused infinite loops before diff --git a/benchmarks/samples/Lexer/1.html b/benchmarks/samples/Lexer/1.html index 43130c01..2b173a1c 100644 --- a/benchmarks/samples/Lexer/1.html +++ b/benchmarks/samples/Lexer/1.html @@ -28,7 +28,7 @@
  • HX Edison Taiji Club by-law effective 3/28/2006
  • A new email account for our club: HXEdisontaijiclub@yahoo.com
  • - +
  • Workshop conducted by ????? Li Deyin is set on June 4, 2006 at Clarion Hotel in Edison from 9:30am-12pm; Registration
  • @@ -36,7 +36,7 @@ -

    Taiji is an ancient Chinese tradition of movement systems that is associated with philosophy, physiology, psychology, geometry and dynamics. It is the slowest form of martial arts and is meant to improve the internal spirit. It is soothing to the soul and extremely invigorating.

    +

    Taiji is an ancient Chinese tradition of movement systems that is associated with philosophy, physiology, psychology, geometry and dynamics. It is the slowest form of martial arts and is meant to improve the internal spirit. It is soothing to the soul and extremely invigorating.

    The founder of Taiji was Zhang Sanfeng (Chang San-feng), who was a monk of the Wu Dang (Wu Tang) Monastery and lived in the period from 1391 to 1459. His exercises stressed suppleness and elasticity as opposed to the hardness and force of other martial art styles. Several centuries old, Taiji was originally developed as a form of self-defense, emphasizing strength, balance, flexibility and speed. Tai Chi also differs from other martial arts in that it is based on the Taoist religion and aims to avoid aggressive forces.

    diff --git a/benchmarks/samples/Lexer/3.html b/benchmarks/samples/Lexer/3.html index c76c5cfb..c8e823a3 100644 --- a/benchmarks/samples/Lexer/3.html +++ b/benchmarks/samples/Lexer/3.html @@ -67,21 +67,21 @@ if (objAdMgr.isSlotAvailable("leaderboard")) { - -
    +

    May 1, 2000

    Pop Culture

    by. H. Finkelstein

    -

    Welcome to the Anime Digi-Lib, a virtual index to anime on the - internet. This site strives to house a comprehensive index to both personal - and commercial websites and provides reviews to these sites. We hope to - be a gateway for people who've never imagined they'd ever be interested +

    +

    Welcome to the Anime Digi-Lib, a virtual index to anime on the + internet. This site strives to house a comprehensive index to both personal + and commercial websites and provides reviews to these sites. We hope to + be a gateway for people who've never imagined they'd ever be interested in Japanese Animation.

    - - - +
    +

     

     

    @@ -107,15 +107,15 @@ if (objAdMgr.isSlotAvailable("leaderboard")) { -
    +
    What is better, subtitled or dubbed anime?
    Subtitled
    Current results
    Free +
    Free Web Polls
    diff --git a/benchmarks/samples/Lexer/4.html b/benchmarks/samples/Lexer/4.html index 095a1d35..1f764581 100644 --- a/benchmarks/samples/Lexer/4.html +++ b/benchmarks/samples/Lexer/4.html @@ -138,7 +138,7 @@

    @@ -279,19 +279,19 @@ Yang Small Frame | Wu Ta-kuei Sun Hsing-i -1923-1970 1891-1929 - -MODERN FORMS - -from Yang Ch`eng-fu - | - | - | - +--------------+ - | | - Cheng Man-ch'ing | - 1901-1975 | - Short (37) Form | +1923-1970 1891-1929 + +MODERN FORMS + +from Yang Ch`eng-fu + | + | + | + +--------------+ + | | + Cheng Man-ch'ing | + 1901-1975 | + Short (37) Form | | Chinese Sports Commission 1956 diff --git a/configdoc/styles/plain.xsl b/configdoc/styles/plain.xsl index 8bbc11e7..b0f46f29 100644 --- a/configdoc/styles/plain.xsl +++ b/configdoc/styles/plain.xsl @@ -14,13 +14,13 @@ /> - + - + - + @@ -45,7 +45,7 @@ - + @@ -83,9 +83,9 @@ - + - +
    @@ -102,7 +102,7 @@
    - +
    - + @@ -179,7 +179,7 @@ - + @@ -229,5 +229,5 @@
  • - + diff --git a/configdoc/usage.xml b/configdoc/usage.xml index 9a5770b2..f89637d6 100644 --- a/configdoc/usage.xml +++ b/configdoc/usage.xml @@ -302,7 +302,7 @@ - 55 + 62 diff --git a/docs/dev-advanced-api.html b/docs/dev-advanced-api.html index 450840bf..a06ac297 100644 --- a/docs/dev-advanced-api.html +++ b/docs/dev-advanced-api.html @@ -164,7 +164,7 @@ to make things simpler. It can be a literal object or:

    class with that function registered as a callback.-->
  • String attribute type: We'll use HTMLPurifier_AttrTypes to resolve it for you. Any data that follows a hash mark (#) will - be used to customize the attribute type: in the example above, + be used to customize the attribute type: in the example above, we specify which values for Enum to allow.
  • diff --git a/docs/dev-config-schema.html b/docs/dev-config-schema.html index 8239bf5a..a76bcbba 100644 --- a/docs/dev-config-schema.html +++ b/docs/dev-config-schema.html @@ -9,29 +9,29 @@ Config Schema - HTML Purifier - +

    Config Schema

    - +
    Filed under Development
    Return to the index.
    HTML Purifier End-User Documentation
    - +

    HTML Purifier has a fairly complex system for configuration. Users interact with a HTMLPurifier_Config object to set configuration directives. The values they set are validated according to a configuration schema, HTMLPurifier_ConfigSchema.

    - +

    The schema is mostly transparent to end-users, but if you're doing development work for HTML Purifier and need to define a new configuration directive, you'll need to interact with it. We'll also talk about how to define userspace configuration directives at the very end.

    - +

    Write a directive file

    - +

    Directive files define configuration directives to be used by HTML Purifier. They are placed in library/HTMLPurifier/ConfigSchema/schema/ @@ -42,7 +42,7 @@ PHPT tests. Here's a sample directive file, Test.Sample.txt:

    - +
    Test.Sample
     TYPE: string/null
     DEFAULT: NULL
    @@ -54,11 +54,11 @@ This is a sample configuration directive for the purposes of the
     <code>dev-config-schema.html<code> documentation.
     --ALIASES--
     Test.Example
    - +

    Each of these segments has a specific meaning:

    - +
    Version added
    @@ -143,11 +143,11 @@ Test.Example
    - +

    Some notes on format and style:

    - +
    • Each of these keys can be expressed in the short format @@ -162,11 +162,11 @@ Test.Example not rely on editor word-wrapping.
    - +

    Also, as promised, here is the set of possible types:

    - + @@ -233,7 +233,7 @@ Test.Example
    - +

    The examples represent what will be returned out of the configuration object; users have a little bit of leeway when setting configuration @@ -242,7 +242,7 @@ Test.Example in library/HTMLPurifier/VarParser.php.

    - +

    For more information on what values are allowed, and how they are parsed, consult @@ -251,9 +251,9 @@ Test.Example library/HTMLPurifier/ConfigSchema/Interchange/Directive.php for the semantics of the parsed values.

    - +

    Refreshing the cache

    - +

    You may have noticed that your directive file isn't doing anything yet. That's because it hasn't been added to the runtime @@ -262,14 +262,14 @@ Test.Example If there were no errors, you're good to go! Don't forget to add some unit tests for your functionality!

    - +

    If you ever make changes to your configuration directives, you will need to run this script again.

    - +

    Errors

    - +

    All directive files go through a rigorous validation process through @@ -279,16 +279,16 @@ Test.Example can give some general tips for interpreting error messages. There are two types of errors: builder errors and validation errors.

    - +

    Builder errors

    - +

    Exception: Expected type string, got integer in DEFAULT in directive hash 'Ns.Dir'

    - +

    You can identify a builder error by the keyword "directive hash." These are the easiest to deal with, because they directly correspond @@ -298,28 +298,28 @@ Test.Example This particular error would occur if your default value is not the same type as TYPE.

    - +

    Validation errors

    - +

    Exception: Alias 3 in valueAliases in directive 'Ns.Dir' must be a string

    - +

    These are a little trickier, because we're not actually validating your directive file, or even the direct string hash representation. We're validating an Interchange object, and the error messages do not mention any string hash keys.

    - +

    Nevertheless, it's not difficult to figure out what went wrong. Read the "context" statements in reverse:

    - +
    in directive 'Ns.Dir'
    This means we need to look at the directive file Ns.Dir.txt
    @@ -329,12 +329,12 @@ Test.Example
    Alias 3
    The value alias that is equal to 3 is the culprit.
    - +

    In this particular case, you're not allowed to alias integers values to strings values.

    - +

    The most difficult part is translating the Interchange member variable (valueAliases) into a directive file key (VALUE-ALIASES), but there's a one-to-one @@ -342,9 +342,9 @@ Test.Example will be described in library/HTMLPurifier/ConfigSchema/InterchangeBuilder.php.

    - +

    Internals

    - +

    Much of the configuration schema framework's codebase deals with shuffling data from one format to another, and doing validation on this @@ -352,7 +352,7 @@ Test.Example The keystone of all of this is the HTMLPurifier_ConfigSchema_Interchange class, which represents the purest, parsed representation of the schema.

    - +

    Hand-writing this data is unwieldy, however, so we write directive files. These directive files are parsed by HTMLPurifier_StringHashParser @@ -360,7 +360,7 @@ Test.Example are run through HTMLPurifier_ConfigSchema_InterchangeBuilder to construct the interchange object.

    - +

    From the interchange object, the data can be siphoned into other forms using HTMLPurifier_ConfigSchema_Builder subclasses. diff --git a/docs/dev-includes.txt b/docs/dev-includes.txt index 3db489df..ac05f8d2 100644 --- a/docs/dev-includes.txt +++ b/docs/dev-includes.txt @@ -91,14 +91,14 @@ use the stub for all cases (which might not be a bad idea). Deprecated ---------- One of the things I'd like to do is have the code search for any classes - that are explicitly mentioned in the code. If a class isn't mentioned, I + that are explicitly mentioned in the code. If a class isn't mentioned, I get to assume that it is "optional," i.e. included via introspection. The choice is either to use PHP's tokenizer or use regexps; regexps would be faster but a tokenizer would be more correct. If this ends up being unfeasible, adding dependency comments isn't a bad idea. (This could even be done automatically by search/replacing require_once, although we'd have to manually inspect the results for the optional requires.) - + NOTE: This ends up not being necessary, as we're going to make the user figure out all the extra classes they need, and only include the core which is predetermined. @@ -193,7 +193,7 @@ configuration directives would be used to generate our key (meta-directives!) mechanism works better. However, we can uniquely identify the schema based on the directories they loaded, so there's no need for a DefinitionId until we give them full programmatic control. - + These variables should be directly incorporated into ConfigSchema, and ConfigSchema should handle serialization. Some refactoring will be necessary for the DefinitionCache classes, as they are built with diff --git a/docs/dev-naming.html b/docs/dev-naming.html index faf8e9f3..2761b843 100644 --- a/docs/dev-naming.html +++ b/docs/dev-naming.html @@ -35,7 +35,7 @@ help you find the correct functionality more quickly. Here they are:

    Harness and Test are reserved class names for unit tests
    The suffix Test indicates that the class is a subclass of UnitTestCase (of the Simpletest library) and is testable. "Harness" indicates a subclass - of UnitTestCase that is not meant to be run but to be extended into + of UnitTestCase that is not meant to be run but to be extended into concrete test cases and contains custom test methods (i.e. assert*())
    Class names do not necessarily represent inheritance hierarchies
    @@ -51,7 +51,7 @@ help you find the correct functionality more quickly. Here they are:

    all must be present in order for proper functioning.
    Abbreviations are avoided
    -
    We try to avoid abbreviations as much as possible, but in some cases, +
    We try to avoid abbreviations as much as possible, but in some cases, abbreviated version is more readable than the full version. Here, we list common abbreviations:
      diff --git a/docs/enduser-customize.html b/docs/enduser-customize.html index d4f251e0..15cf5c7a 100644 --- a/docs/enduser-customize.html +++ b/docs/enduser-customize.html @@ -206,7 +206,7 @@ $def = $config->getHTMLDefinition(true);

      Turn off caching

      - To make development easier, we're going to temporarily turn off + To make development easier, we're going to temporarily turn off definition caching:

      @@ -401,8 +401,8 @@ $def = $config->getHTMLDefinition(true);

      Adding attributes is really small-fry stuff, though, and it was possible - to add them (albeit a bit more wordy) prior to 2.0. The real gem of - the Advanced API is adding elements. There are five questions to + to add them (albeit a bit more wordy) prior to 2.0. The real gem of + the Advanced API is adding elements. There are five questions to ask when adding a new element:

      @@ -493,9 +493,9 @@ $def = $config->getHTMLDefinition(true);

      The (%flow;)* indicates the allowed children of the li tag: li allows any number of flow - elements as its children. (The - O allows the closing tag to be - omitted, though in XML this is not allowed.) In HTML Purifier, - we'd write it like Flow (here's where the content sets + elements as its children. (The - O allows the closing tag to be + omitted, though in XML this is not allowed.) In HTML Purifier, + we'd write it like Flow (here's where the content sets we were discussing earlier come into play). There are three shorthand content models you can specify:

      @@ -596,7 +596,7 @@ $def = $config->getHTMLDefinition(true); be nuked. This is why there is are specific content model types like Optional and Required: while they could be implemented as Custom: (valid | elements)*, the custom classes contain special recovery - measures that make sure as much of the user's original content gets + measures that make sure as much of the user's original content gets through. HTML Purifier's core, as a rule, does not use Custom.

      @@ -676,7 +676,7 @@ $def = $config->getHTMLDefinition(true); href="http://www.w3.org/TR/xhtml-modularization/abstract_modules.html#s_commonatts">abstract modules of the XHTML Modularization 1.1. We believe this section to be in error, as br permits the use of the style - attribute even though it uses the Core collection, and + attribute even though it uses the Core collection, and the DTD and XML Schemas supplied by W3C support our interpretation.

      diff --git a/docs/enduser-slow.html b/docs/enduser-slow.html index 12bdff1d..a86967ce 100644 --- a/docs/enduser-slow.html +++ b/docs/enduser-slow.html @@ -17,25 +17,25 @@
      Return to the index.
      HTML Purifier End-User Documentation
      -

      HTML Purifier is a very powerful library. But with power comes great -responsibility, in the form of longer execution times. Remember, this -library isn't lightly grazing over submitted HTML: it's deconstructing -the whole thing, rigorously checking the parts, and then putting it back +

      HTML Purifier is a very powerful library. But with power comes great +responsibility, in the form of longer execution times. Remember, this +library isn't lightly grazing over submitted HTML: it's deconstructing +the whole thing, rigorously checking the parts, and then putting it back together.

      -

      So, if it so turns out that HTML Purifier is kinda too slow for outbound +

      So, if it so turns out that HTML Purifier is kinda too slow for outbound filtering, you've got a few options:

      Inbound filtering

      -

      Perform filtering of HTML when it's submitted by the user. Since the -user is already submitting something, an extra half a second tacked on -to the load time probably isn't going to be that huge of a problem. -Then, displaying the content is a simple a manner of outputting it -directly from your database/filesystem. The trouble with this method is -that your user loses the original text, and when doing edits, will be -handling the filtered text. While this may be a good thing, especially -if you're using a WYSIWYG editor, it can also result in data-loss if a +

      Perform filtering of HTML when it's submitted by the user. Since the +user is already submitting something, an extra half a second tacked on +to the load time probably isn't going to be that huge of a problem. +Then, displaying the content is a simple a manner of outputting it +directly from your database/filesystem. The trouble with this method is +that your user loses the original text, and when doing edits, will be +handling the filtered text. While this may be a good thing, especially +if you're using a WYSIWYG editor, it can also result in data-loss if a user makes a typo.

      Example (non-functional):

      @@ -66,14 +66,14 @@ user makes a typo.

      Caching the filtered output

      -

      Accept the submitted text and put it unaltered into the database, but -then also generate a filtered version and stash that in the database. -Serve the filtered version to readers, and the unaltered version to -editors. If need be, you can invalidate the cache and have the cached -filtered version be regenerated on the first page view. Pros? Full data -retention. Cons? It's more complicated, and opens other editors up to -XSS if they are using a WYSIWYG editor (to fix that, they'd have to be -able to get their hands on the *really* original text served in +

      Accept the submitted text and put it unaltered into the database, but +then also generate a filtered version and stash that in the database. +Serve the filtered version to readers, and the unaltered version to +editors. If need be, you can invalidate the cache and have the cached +filtered version be regenerated on the first page view. Pros? Full data +retention. Cons? It's more complicated, and opens other editors up to +XSS if they are using a WYSIWYG editor (to fix that, they'd have to be +able to get their hands on the *really* original text served in plaintext mode).

      Example (non-functional):

      @@ -108,9 +108,9 @@ plaintext mode).

      In short, inbound filtering is the simple option and caching is the robust option (albeit with bigger storage requirements).

      -

      There is a third option, independent of the two we've discussed: profile -and optimize HTMLPurifier yourself. Be sure to report back your results -if you decide to do that! Especially if you port HTML Purifier to C++. +

      There is a third option, independent of the two we've discussed: profile +and optimize HTMLPurifier yourself. Be sure to report back your results +if you decide to do that! Especially if you port HTML Purifier to C++. ;-)

      diff --git a/docs/enduser-tidy.html b/docs/enduser-tidy.html index fd811efc..c7415996 100644 --- a/docs/enduser-tidy.html +++ b/docs/enduser-tidy.html @@ -50,7 +50,7 @@ not need Tidy installed on your PHP to use these features!

      What are levels?

      -

      Levels describe how aggressive the Tidy module should be when +

      Levels describe how aggressive the Tidy module should be when cleaning up HTML. There are four levels to pick: none, light, medium and heavy. Each of these levels has a well-defined set of behavior associated with it, although it may change depending on your doctype.

      diff --git a/docs/enduser-uri-filter.html b/docs/enduser-uri-filter.html index 9eceac62..6b041305 100644 --- a/docs/enduser-uri-filter.html +++ b/docs/enduser-uri-filter.html @@ -92,7 +92,7 @@

      - Because the URI is presented to us in this form, and not + Because the URI is presented to us in this form, and not http://bob@example.com:8080/foo.php?q=string#hash, it saves us a lot of trouble in having to parse the URI every time we want to filter it. For the record, the above URI has the following components: diff --git a/docs/enduser-utf8.html b/docs/enduser-utf8.html index 6882c7a4..62eba90f 100644 --- a/docs/enduser-utf8.html +++ b/docs/enduser-utf8.html @@ -106,7 +106,7 @@ there are now many character encodings floating around.

      interpret raw zeroes and ones into real characters. It usually does this by pairing numbers with characters.

      There are many different types of character encodings floating - around, but the ones we deal most frequently with are ASCII, + around, but the ones we deal most frequently with are ASCII, 8-bit encodings, and Unicode-based encodings.

      • ASCII is a 7-bit encoding based on the @@ -306,7 +306,7 @@ languages. The appropriate code is:

        ...replacing UTF-8 with whatever your embedded encoding is. This code must come before any output, so be careful about -stray whitespace in your application (i.e., any whitespace before +stray whitespace in your application (i.e., any whitespace before output excluding whitespace within <?php ?> tags).

        PHP ini directive

        @@ -366,9 +366,9 @@ to send anything at all:

        AddDefaultCharset Off

        ...making your internal charset declaration (usually the META tags) -the sole source of character encoding -information. In these cases, it is especially important to make -sure you have valid META tags on your pages and all the +the sole source of character encoding +information. In these cases, it is especially important to make +sure you have valid META tags on your pages and all the text before them is ASCII.

        These directives can also be @@ -443,9 +443,9 @@ Declarations. They look like:

        For XHTML, this XML Declaration theoretically overrides the META tag. In reality, this happens only when the XHTML is actually served as legit XML and not HTML, which is almost always -never due to Internet Explorer's lack of support for +never due to Internet Explorer's lack of support for application/xhtml+xml (even though doing so is often -argued to be good +argued to be good practice and is required by the XHTML 1.1 specification).

        For XML, however, this XML Declaration is extremely important. @@ -456,7 +456,7 @@ ISO-8859-1 encoding (you see this in garbled RSS feeds).

        In short, if you use XHTML and have gone through the trouble of adding the XML Declaration, make sure it jives -with your META tags (which should only be present +with your META tags (which should only be present if served in text/html) and HTTP headers.

        Inside the process

        @@ -489,7 +489,7 @@ it gets to the Content-Type tag, extract the character encoding tag, then re-parse the document according to this new information.

        Obviously this is complicated, so browsers prefer the simpler -and more efficient solution: get the character encoding from a +and more efficient solution: get the character encoding from a somewhere other than the document itself, i.e. the HTTP headers, much to the chagrin of HTML authors who can't set these headers.

        @@ -578,7 +578,7 @@ files.

        FORM submission and i18n. That document contains lots of useful information, but is written in a rambly manner, so -here I try to get right to the point. (Note: the original has +here I try to get right to the point. (Note: the original has disappeared off the web, so I am linking to the Web Archive copy.)

        application/x-www-form-urlencoded

        @@ -886,7 +886,7 @@ sure the page is saved WITHOUT the BOM.

        If you are reading in text files to insert into the middle of another -page, it is strongly advised (but not strictly necessary) that you replace out the UTF-8 byte +page, it is strongly advised (but not strictly necessary) that you replace out the UTF-8 byte sequence for BOM "\xEF\xBB\xBF" before inserting it in, via:

        @@ -949,7 +949,7 @@ to known good Unicode fonts.

        heavy lifting for you. Get the CSS from the horses mouth here: Common.css, and search for ".IPA" There are also a smattering of -other classes you can use for other purposes, check out +other classes you can use for other purposes, check out this page for more details. For you lazy ones, this should work:

        diff --git a/docs/proposal-errors.txt b/docs/proposal-errors.txt index 0a501951..1c3db8d5 100644 --- a/docs/proposal-errors.txt +++ b/docs/proposal-errors.txt @@ -2,7 +2,7 @@ Considerations for ErrorCollection Presently, HTML Purifier takes a code-execution centric approach to handling errors. Errors are organized and grouped according to which segment of the -code triggers them, not necessarily the portion of the input document that +code triggers them, not necessarily the portion of the input document that triggered the error. This means that errors are pseudo-sorted by category, rather than location in the document. @@ -13,7 +13,7 @@ can report errors still process the document mostly linearly. Furthermore, not only do they process linearly, but the way they pass off operations to sub-systems mirrors that of the document. For example, AttrValidator will linearly proceed through elements, and on each element will use AttrDef to -validate those contents. From there, the attribute might have more +validate those contents. From there, the attribute might have more sub-components, which have execution passed off accordingly. In fact, each strategy handles a very specific class of "error." @@ -56,7 +56,7 @@ set it as a document-wide error. And actually, nothing needs to be done here. Something interesting to consider is whether or not we care about the locations of attributes and CSS properties, i.e. the sub-objects that compose these things. In terms of consistency, at the very least attributes should have column/line -numbers attached to them. However, this may be overkill, as attributes are +numbers attached to them. However, this may be overkill, as attributes are uniquely identifiable. You could go even further, with CSS, but they are also uniquely identifiable. @@ -80,12 +80,12 @@ cases). 4. Setup ErrorCollector to use context information to setup hierarchies. This may require a different internal format. Use objects if it gets complex. [DONE] - + ASIDE More on this topic: since we are now binding errors to lines and columns, a particular error can have three relationships to that specific location: - + 1. The token at that location directly RemoveForeignElements AttrValidator (transforms) @@ -95,50 +95,50 @@ cases). 3. A modification to that node (i.e. contents from start to end token) as a whole FixNesting - + This needs to be marked accordingly. In the presentation, it might make sense keep (3) separate, have (2) a sublist of (1). (1) can be a closing tag, in which case (3) makes no sense at all, OR it should be related with its opening tag (this may not necessarily be possible before MakeWellFormed is run). - + So, the line and column counts as our identifier, so: - + $errors[$line][$col] = ... - + Then, we need to identify case 1, 2 or 3. They are identified as such: - + 1. Need some sort of semaphore in RemoveForeignElements, etc. 2. If CurrentAttr/CurrentCssProperty is non-null 3. Default (FixNesting, MakeWellFormed) - + One consideration about (1) is that it usually is actually a (3) modification, but we have no way of knowing about that because of various optimizations. However, they can probably be treated the same. The other difficulty is that (3) is never a line and column; rather, it is a range (i.e. a duple) and telling the user the very start of the range may confuse them. For example, - + Foo
        bar
        ^ ^ - + The node being operated on is , so the error would be assigned to the first caret, with a "node reorganized" error. Then, the ChildDef would have submitted its own suggestions and errors with regard to what's going in the internals. So I suppose this is ok. :-) - + Now, the structure of the earlier mentioned ... would be something like this: - + object { type = (token|attr|property), value, // appropriate for type errors => array(), sub-errors = [recursive], } - + This helps us keep things agnostic. It is also sufficiently complex enough to warrant an object. @@ -173,7 +173,7 @@ Then we setup suggestions. 5. Setup a separate error class which tells the user any modifications HTML Purifier made. - + Some information about this: Our current paradigm is to tell the user what HTML Purifier did to the HTML. @@ -187,7 +187,7 @@ the correct version isn't a bad idea, but problems arise when: - The user has such bad HTML we do something odd, when we should have just flagged the HTML as an error. Such examples are when we do things like remove text from directly inside a tag. It was probably meant to - be in a '); } - + function testPreserveId() { $this->config->set('Attr', 'EnableID', true); $this->assertResult(''); } - + function testPreserveName() { $this->config->set('Attr', 'EnableID', true); $this->assertResult(''); } - + function testRemoveNested() { $this->assertResult('', ''); } - + function testRemoveNested2() { $this->assertResult('', ''); } - + function testRemoveNested3() { $this->assertResult(' ', ''); } - + } diff --git a/tests/HTMLPurifier/Injector/SafeObjectTest.php b/tests/HTMLPurifier/Injector/SafeObjectTest.php index 010f0707..8e12d8e3 100644 --- a/tests/HTMLPurifier/Injector/SafeObjectTest.php +++ b/tests/HTMLPurifier/Injector/SafeObjectTest.php @@ -7,81 +7,81 @@ */ class HTMLPurifier_Injector_SafeObjectTest extends HTMLPurifier_InjectorHarness { - + function setup() { parent::setup(); // there is no AutoFormat.SafeObject directive $this->config->set('AutoFormat', 'Custom', array(new HTMLPurifier_Injector_SafeObject())); $this->config->set('HTML', 'Trusted', true); } - + function testPreserve() { $this->assertResult( 'asdf' ); } - + function testRemoveStrayParam() { $this->assertResult( '', '' ); } - + function testEditObjectParam() { $this->assertResult( '', '' ); } - + function testIgnoreStrayParam() { $this->assertResult( '', '' ); } - + function testIgnoreDuplicates() { $this->assertResult( '' ); } - + function testIgnoreBogusData() { $this->assertResult( '', '' ); } - + function testIgnoreInvalidData() { $this->assertResult( '', '' ); } - + function testKeepValidData() { $this->assertResult( '', '' ); } - + function testNested() { $this->assertResult( '', '' ); } - + function testNotActuallyNested() { $this->assertResult( '

        ', '

        ' ); } - + } diff --git a/tests/HTMLPurifier/InjectorHarness.php b/tests/HTMLPurifier/InjectorHarness.php index 01cd3271..763d0bf6 100644 --- a/tests/HTMLPurifier/InjectorHarness.php +++ b/tests/HTMLPurifier/InjectorHarness.php @@ -2,11 +2,11 @@ class HTMLPurifier_InjectorHarness extends HTMLPurifier_StrategyHarness { - + function setUp() { parent::setUp(); $this->obj = new HTMLPurifier_Strategy_MakeWellFormed(); } - + } diff --git a/tests/HTMLPurifier/LanguageFactoryTest.php b/tests/HTMLPurifier/LanguageFactoryTest.php index 0d699dfe..3ad3f3ac 100644 --- a/tests/HTMLPurifier/LanguageFactoryTest.php +++ b/tests/HTMLPurifier/LanguageFactoryTest.php @@ -2,50 +2,50 @@ class HTMLPurifier_LanguageFactoryTest extends HTMLPurifier_Harness { - + /** * Protected reference of global factory we're testing. */ protected $factory; - + public function setUp() { $this->factory = HTMLPurifier_LanguageFactory::instance(); parent::setUp(); } - + function test() { - + $this->config->set('Core', 'Language', 'en'); $language = $this->factory->create($this->config, $this->context); - + $this->assertIsA($language, 'HTMLPurifier_Language'); $this->assertIdentical($language->code, 'en'); - + // lazy loading test $this->assertIdentical(count($language->messages), 0); $language->load(); $this->assertNotEqual(count($language->messages), 0); - + } - + function testFallback() { - + $this->config->set('Core', 'Language', 'en-x-test'); $language = $this->factory->create($this->config, $this->context); - + $this->assertIsA($language, 'HTMLPurifier_Language_en_x_test'); $this->assertIdentical($language->code, 'en-x-test'); - + $language->load(); - + // test overloaded message $this->assertIdentical($language->getMessage('HTMLPurifier'), 'HTML Purifier X'); - + // test inherited message $this->assertIdentical($language->getMessage('LanguageFactoryTest: Pizza'), 'Pizza'); - + } - + function testFallbackWithNoClass() { $this->config->set('Core', 'Language', 'en-x-testmini'); $language = $this->factory->create($this->config, $this->context); @@ -56,7 +56,7 @@ class HTMLPurifier_LanguageFactoryTest extends HTMLPurifier_Harness $this->assertIdentical($language->getMessage('LanguageFactoryTest: Pizza'), 'Pizza'); $this->assertIdentical($language->error, false); } - + function testNoSuchLanguage() { $this->config->set('Core', 'Language', 'en-x-testnone'); $language = $this->factory->create($this->config, $this->context); @@ -64,6 +64,6 @@ class HTMLPurifier_LanguageFactoryTest extends HTMLPurifier_Harness $this->assertIdentical($language->code, 'en-x-testnone'); $this->assertIdentical($language->error, true); } - + } diff --git a/tests/HTMLPurifier/LanguageTest.php b/tests/HTMLPurifier/LanguageTest.php index de0e981a..06eed1af 100644 --- a/tests/HTMLPurifier/LanguageTest.php +++ b/tests/HTMLPurifier/LanguageTest.php @@ -1,20 +1,20 @@ _loaded using something else */ class HTMLPurifier_LanguageTest extends HTMLPurifier_Harness { - + protected $lang; - + protected function generateEnLanguage() { $factory = HTMLPurifier_LanguageFactory::instance(); $config = HTMLPurifier_Config::create(array('Core.Language' => 'en')); $context = new HTMLPurifier_Context(); return $factory->create($config, $context); } - + function test_getMessage() { $config = HTMLPurifier_Config::createDefault(); $context = new HTMLPurifier_Context(); @@ -24,7 +24,7 @@ class HTMLPurifier_LanguageTest extends HTMLPurifier_Harness $this->assertIdentical($lang->getMessage('HTMLPurifier'), 'HTML Purifier'); $this->assertIdentical($lang->getMessage('LanguageTest: Totally non-existent key'), '[LanguageTest: Totally non-existent key]'); } - + function test_formatMessage() { $config = HTMLPurifier_Config::createDefault(); $context = new HTMLPurifier_Context(); @@ -33,7 +33,7 @@ class HTMLPurifier_LanguageTest extends HTMLPurifier_Harness $lang->messages['LanguageTest: Error'] = 'Error is $1 on line $2'; $this->assertIdentical($lang->formatMessage('LanguageTest: Error', array(1=>'fatal', 32)), 'Error is fatal on line 32'); } - + function test_formatMessage_tokenParameter() { $config = HTMLPurifier_Config::createDefault(); $context = new HTMLPurifier_Context(); @@ -50,29 +50,29 @@ class HTMLPurifier_LanguageTest extends HTMLPurifier_Harness array(1=>new HTMLPurifier_Token_Text('data>', 23))), 'Data Token: data>, data>, data>, 23'); } - + function test_listify() { $lang = $this->generateEnLanguage(); $this->assertEqual($lang->listify(array('Item')), 'Item'); $this->assertEqual($lang->listify(array('Item', 'Item2')), 'Item and Item2'); $this->assertEqual($lang->listify(array('Item', 'Item2', 'Item3')), 'Item, Item2 and Item3'); } - + function test_formatMessage_arrayParameter() { $lang = $this->generateEnLanguage(); - + $array = array('Item1', 'Item2', 'Item3'); $this->assertIdentical( $lang->formatMessage('LanguageTest: List', array(1=>$array)), 'Item1, Item2 and Item3' ); - + $array = array('Key1' => 'Value1', 'Key2' => 'Value2'); $this->assertIdentical( $lang->formatMessage('LanguageTest: Hash', array(1=>$array)), 'Key1 and Key2; Value1 and Value2' ); } - + } diff --git a/tests/HTMLPurifier/LengthTest.php b/tests/HTMLPurifier/LengthTest.php index 39381176..3868823d 100644 --- a/tests/HTMLPurifier/LengthTest.php +++ b/tests/HTMLPurifier/LengthTest.php @@ -2,24 +2,24 @@ class HTMLPurifier_LengthTest extends HTMLPurifier_Harness { - + function testConstruct() { $l = new HTMLPurifier_Length('23', 'in'); $this->assertIdentical($l->getN(), '23'); $this->assertIdentical($l->getUnit(), 'in'); } - + function testMake() { $l = HTMLPurifier_Length::make('+23.4in'); $this->assertIdentical($l->getN(), '+23.4'); $this->assertIdentical($l->getUnit(), 'in'); } - + function testToString() { $l = new HTMLPurifier_Length('23', 'in'); $this->assertIdentical($l->toString(), '23in'); } - + protected function assertValidate($string, $expect = true) { if ($expect === true) $expect = $string; $l = HTMLPurifier_Length::make($string); @@ -27,7 +27,7 @@ class HTMLPurifier_LengthTest extends HTMLPurifier_Harness if ($result === false) $this->assertIdentical($expect, false); else $this->assertIdentical($l->toString(), $expect); } - + function testValidate() { $this->assertValidate('0'); $this->assertValidate('+0', '0'); @@ -46,7 +46,7 @@ class HTMLPurifier_LengthTest extends HTMLPurifier_Harness $this->assertValidate('3', false); $this->assertValidate('3miles', false); } - + /** * @param $s1 First string to compare * @param $s2 Second string to compare @@ -60,12 +60,12 @@ class HTMLPurifier_LengthTest extends HTMLPurifier_Harness $this->assertIdentical($r1 == 0 ? 0 : ($r1 > 0 ? 1 : -1), $expect); $this->assertIdentical($r2 == 0 ? 0 : ($r2 > 0 ? 1 : -1), - $expect); } - + function testCompareTo() { $this->assertComparison('12in', '12in'); $this->assertComparison('12in', '12mm', 1); $this->assertComparison('1px', '1mm', -1); $this->assertComparison(str_repeat('2', 38) . 'in', '100px', 1); } - + } diff --git a/tests/HTMLPurifier/Lexer/DirectLexTest.php b/tests/HTMLPurifier/Lexer/DirectLexTest.php index a9fd49e5..745cd51f 100644 --- a/tests/HTMLPurifier/Lexer/DirectLexTest.php +++ b/tests/HTMLPurifier/Lexer/DirectLexTest.php @@ -2,67 +2,67 @@ class HTMLPurifier_Lexer_DirectLexTest extends HTMLPurifier_Harness { - + protected $DirectLex; - + function setUp() { $this->DirectLex = new HTMLPurifier_Lexer_DirectLex(); } - + // internals testing function test_parseAttributeString() { - + $input[0] = 'href="about:blank" rel="nofollow"'; $expect[0] = array('href'=>'about:blank', 'rel'=>'nofollow'); - + $input[1] = "href='about:blank'"; $expect[1] = array('href'=>'about:blank'); - + // note that the single quotes aren't /really/ escaped $input[2] = 'onclick="javascript:alert(\'asdf\');"'; $expect[2] = array('onclick' => "javascript:alert('asdf');"); - + $input[3] = 'selected'; $expect[3] = array('selected'=>'selected'); - + // [INVALID] $input[4] = '="nokey"'; $expect[4] = array(); - + // [SIMPLE] $input[5] = 'color=blue'; $expect[5] = array('color' => 'blue'); - + // [INVALID] $input[6] = 'href="about:blank'; $expect[6] = array('href' => 'about:blank'); - + // [INVALID] $input[7] = '"='; $expect[7] = array('"' => ''); // we ought to get array() - + $input[8] = 'href ="about:blank"rel ="nofollow"'; $expect[8] = array('href' => 'about:blank', 'rel' => 'nofollow'); - + $input[9] = 'two bool'; $expect[9] = array('two' => 'two', 'bool' => 'bool'); - + $input[10] = 'name="input" selected'; $expect[10] = array('name' => 'input', 'selected' => 'selected'); - + $input[11] = '=""'; $expect[11] = array(); - + $input[12] = '="" =""'; $expect[12] = array('"' => ''); // tough to say, just don't throw a loop - + $input[13] = 'href="'; $expect[13] = array('href' => ''); - + $input[14] = 'href=" <'; $expect[14] = array('href' => ' <'); - + $config = HTMLPurifier_Config::createDefault(); $context = new HTMLPurifier_Context(); $size = count($input); @@ -70,15 +70,15 @@ class HTMLPurifier_Lexer_DirectLexTest extends HTMLPurifier_Harness $result = $this->DirectLex->parseAttributeString($input[$i], $config, $context); $this->assertIdentical($expect[$i], $result, 'Test ' . $i . ': %s'); } - + } - + function testLineNumbers() { - + // . . . . . . . . . . // 01234567890123 01234567890123 0123456789012345 0123456789012 012345 $html = "Line 1\nLine 2\nStill Line 2Now Line 4\n\n
        "; - + $expect = array( // line 1 0 => new HTMLPurifier_Token_Start('b') @@ -97,13 +97,13 @@ class HTMLPurifier_Lexer_DirectLexTest extends HTMLPurifier_Harness // line SIX ,10 => new HTMLPurifier_Token_Empty('br') ); - + $context = new HTMLPurifier_Context(); $config = HTMLPurifier_Config::createDefault(); $output = $this->DirectLex->tokenizeHTML($html, $config, $context); - + $this->assertIdentical($output, $expect); - + $context = new HTMLPurifier_Context(); $config = HTMLPurifier_Config::create(array( 'Core.MaintainLineNumbers' => true @@ -119,11 +119,11 @@ class HTMLPurifier_Lexer_DirectLexTest extends HTMLPurifier_Harness $expect[8]->position(3, 12); $expect[9]->position(4, 2); $expect[10]->position(6, 0); - + $output = $this->DirectLex->tokenizeHTML($html, $config, $context); $this->assertIdentical($output, $expect); - + } - + } diff --git a/tests/HTMLPurifier/Lexer/DirectLex_ErrorsTest.php b/tests/HTMLPurifier/Lexer/DirectLex_ErrorsTest.php index 31951a34..c7a8f8a2 100644 --- a/tests/HTMLPurifier/Lexer/DirectLex_ErrorsTest.php +++ b/tests/HTMLPurifier/Lexer/DirectLex_ErrorsTest.php @@ -2,51 +2,51 @@ class HTMLPurifier_Lexer_DirectLex_ErrorsTest extends HTMLPurifier_ErrorsHarness { - + function invoke($input) { $lexer = new HTMLPurifier_Lexer_DirectLex(); $lexer->tokenizeHTML($input, $this->config, $this->context); } - + function invokeAttr($input) { $lexer = new HTMLPurifier_Lexer_DirectLex(); $lexer->parseAttributeString($input, $this->config, $this->context); } - + function testUnclosedComment() { $this->expectErrorCollection(E_WARNING, 'Lexer: Unclosed comment'); $this->expectContext('CurrentLine', 1); $this->invoke('', @@ -277,7 +277,7 @@ class HTMLPurifier_LexerTest extends HTMLPurifier_Harness ) ); } - + function test_tokenizeHTML_malformedComment() { $this->assertTokenization( '', @@ -287,7 +287,7 @@ class HTMLPurifier_LexerTest extends HTMLPurifier_Harness ) ); } - + function test_tokenizeHTML_unterminatedTag() { $this->assertTokenization( 'assertTokenization( '<b>', @@ -318,7 +318,7 @@ class HTMLPurifier_LexerTest extends HTMLPurifier_Harness ) ); } - + function test_tokenizeHTML_earlyQuote() { $this->assertTokenization( '', @@ -333,7 +333,7 @@ class HTMLPurifier_LexerTest extends HTMLPurifier_Harness ) ); } - + function test_tokenizeHTML_earlyQuote_PH5P() { if (!class_exists('DOMDocument')) return; $lexer = new HTMLPurifier_Lexer_PH5P(); @@ -348,14 +348,14 @@ class HTMLPurifier_LexerTest extends HTMLPurifier_Harness ), $result); } } - + function test_tokenizeHTML_unescapedQuote() { $this->assertTokenization( '"', array( new HTMLPurifier_Token_Text('"') ) ); } - + function test_tokenizeHTML_escapedQuote() { $this->assertTokenization( '"', @@ -365,7 +365,7 @@ class HTMLPurifier_LexerTest extends HTMLPurifier_Harness ) ); } - + function test_tokenizeHTML_cdata() { $this->assertTokenization( 'can't get me!]]>', @@ -389,14 +389,14 @@ class HTMLPurifier_LexerTest extends HTMLPurifier_Harness ) ); } - + function test_tokenizeHTML_characterEntity() { $this->assertTokenization( 'θ', array( new HTMLPurifier_Token_Text("\xCE\xB8") ) ); } - + function test_tokenizeHTML_characterEntityInCDATA() { $this->assertTokenization( '', @@ -410,7 +410,7 @@ class HTMLPurifier_LexerTest extends HTMLPurifier_Harness ) ); } - + function test_tokenizeHTML_entityInAttribute() { $this->assertTokenization( 'Link', @@ -421,21 +421,21 @@ class HTMLPurifier_LexerTest extends HTMLPurifier_Harness ) ); } - + function test_tokenizeHTML_preserveUTF8() { $this->assertTokenization( "\xCE\xB8", array( new HTMLPurifier_Token_Text("\xCE\xB8") ) ); } - + function test_tokenizeHTML_specialEntityInAttribute() { $this->assertTokenization( '
        ', array( new HTMLPurifier_Token_Empty('br', array('test' => 'x < 6')) ) ); } - + function test_tokenizeHTML_emoticonProtection() { $this->assertTokenization( 'Whoa! <3 That\'s not good >.>', @@ -464,7 +464,7 @@ class HTMLPurifier_LexerTest extends HTMLPurifier_Harness ) ); } - + function test_tokenizeHTML_commentWithFunkyChars() { $this->assertTokenization( '
        ', @@ -477,7 +477,7 @@ class HTMLPurifier_LexerTest extends HTMLPurifier_Harness ) ); } - + function test_tokenizeHTML_unterminatedComment() { $this->assertTokenization( '', @@ -517,7 +517,7 @@ class HTMLPurifier_LexerTest extends HTMLPurifier_Harness ) ); } - + function test_tokenizeHTML_attributeWithSpecialCharacters() { $this->assertTokenization( '', @@ -532,14 +532,14 @@ class HTMLPurifier_LexerTest extends HTMLPurifier_Harness ) ); } - + function test_tokenizeHTML_emptyTagWithSlashInAttribute() { $this->assertTokenization( '', array( new HTMLPurifier_Token_Empty('param', array('name' => 'src', 'value' => 'http://example.com/video.wmv')) ) ); } - + function test_tokenizeHTML_style() { $extra = array( // PH5P doesn't seem to like style tags @@ -573,7 +573,7 @@ div {} $extra ); } - + function test_tokenizeHTML_tagWithAtSignAndExtraGt() { $this->assertTokenization( '>', @@ -593,7 +593,7 @@ div {} ) ); } - + function test_tokenizeHTML_emoticonHeart() { $this->assertTokenization( '
        <3
        ', @@ -612,7 +612,7 @@ div {} ) ); } - + function test_tokenizeHTML_emoticonShiftyEyes() { $this->assertTokenization( '<<', @@ -631,7 +631,7 @@ div {} ) ); } - + function test_tokenizeHTML_eon1996() { $this->assertTokenization( '< test', @@ -652,7 +652,7 @@ div {} ) ); } - + function test_tokenizeHTML_bodyInCDATA() { $this->assertTokenization( 'Foo]]>', @@ -672,18 +672,18 @@ div {} ) ); } - + /* - + function test_tokenizeHTML_() { $this->assertTokenization( , array( - + ) ); } */ - + } diff --git a/tests/HTMLPurifier/PercentEncoderTest.php b/tests/HTMLPurifier/PercentEncoderTest.php index 6df8eb7a..4c0f2637 100644 --- a/tests/HTMLPurifier/PercentEncoderTest.php +++ b/tests/HTMLPurifier/PercentEncoderTest.php @@ -2,23 +2,23 @@ class HTMLPurifier_PercentEncoderTest extends HTMLPurifier_Harness { - + protected $PercentEncoder; protected $func; - + function setUp() { $this->PercentEncoder = new HTMLPurifier_PercentEncoder(); $this->func = ''; } - + function assertDecode($string, $expect = true) { if ($expect === true) $expect = $string; $this->assertIdentical($this->PercentEncoder->{$this->func}($string), $expect); } - + function test_normalize() { $this->func = 'normalize'; - + $this->assertDecode('Aw.../-$^8'); // no change $this->assertDecode('%41%77%7E%2D%2E%5F', 'Aw~-._'); // decode unreserved chars $this->assertDecode('%3A%2F%3F%23%5B%5D%40%21%24%26%27%28%29%2A%2B%2C%3B%3D'); // preserve reserved chars @@ -28,35 +28,35 @@ class HTMLPurifier_PercentEncoderTest extends HTMLPurifier_Harness $this->assertDecode('%', '%25'); // normalize stray percent sign $this->assertDecode('%5%25', '%255%25'); // permaturely terminated encoding $this->assertDecode('%GJ', '%25GJ'); // invalid hexadecimal chars - + // contested behavior, if this changes, we'll also have to have // outbound encoding $this->assertDecode('%FC'); // not reserved or unreserved, preserve - + } - + function assertEncode($string, $expect = true, $preserve = false) { if ($expect === true) $expect = $string; $encoder = new HTMLPurifier_PercentEncoder($preserve); $result = $encoder->encode($string); $this->assertIdentical($result, $expect); } - + function test_encode_noChange() { $this->assertEncode('abc012-_~.'); } - + function test_encode_encode() { $this->assertEncode('>', '%3E'); } - + function test_encode_preserve() { $this->assertEncode('<>', '<%3E', '<'); } - + function test_encode_low() { $this->assertEncode("\1", '%01'); } - + } diff --git a/tests/HTMLPurifier/PropertyListTest.php b/tests/HTMLPurifier/PropertyListTest.php index 3c8fed02..99862698 100644 --- a/tests/HTMLPurifier/PropertyListTest.php +++ b/tests/HTMLPurifier/PropertyListTest.php @@ -2,19 +2,19 @@ class HTMLPurifier_PropertyListTest extends UnitTestCase { - + function testBasic() { $plist = new HTMLPurifier_PropertyList(); $plist->set('key', 'value'); $this->assertIdentical($plist->get('key'), 'value'); } - + function testNotFound() { $this->expectException(new HTMLPurifier_Exception("Key 'key' not found")); $plist = new HTMLPurifier_PropertyList(); $plist->get('key'); } - + function testRecursion() { $parent_plist = new HTMLPurifier_PropertyList(); $parent_plist->set('key', 'value'); @@ -22,7 +22,7 @@ class HTMLPurifier_PropertyListTest extends UnitTestCase $plist->setParent($parent_plist); $this->assertIdentical($plist->get('key'), 'value'); } - + function testOverride() { $parent_plist = new HTMLPurifier_PropertyList(); $parent_plist->set('key', 'value'); @@ -31,7 +31,7 @@ class HTMLPurifier_PropertyListTest extends UnitTestCase $plist->set('key', 'value2'); $this->assertIdentical($plist->get('key'), 'value2'); } - + function testRecursionNotFound() { $this->expectException(new HTMLPurifier_Exception("Key 'key' not found")); $parent_plist = new HTMLPurifier_PropertyList(); @@ -39,14 +39,14 @@ class HTMLPurifier_PropertyListTest extends UnitTestCase $plist->setParent($parent_plist); $this->assertIdentical($plist->get('key'), 'value'); } - + function testHas() { $plist = new HTMLPurifier_PropertyList(); $this->assertIdentical($plist->has('key'), false); $plist->set('key', 'value'); $this->assertIdentical($plist->has('key'), true); } - + function testReset() { $plist = new HTMLPurifier_PropertyList(); $plist->set('key1', 'value'); @@ -64,7 +64,7 @@ class HTMLPurifier_PropertyListTest extends UnitTestCase $this->assertIdentical($plist->has('key2'), false); $this->assertIdentical($plist->has('key3'), false); } - + function testIterator() { $plist = new HTMLPurifier_PropertyList(); $plist->set('nkey1', 'v'); @@ -81,5 +81,5 @@ class HTMLPurifier_PropertyListTest extends UnitTestCase } $this->assertIdentical($a, array('nkey1' => 'v', 'nkey2' => 'v')); } - + } diff --git a/tests/HTMLPurifier/SimpleTest/Reporter.php b/tests/HTMLPurifier/SimpleTest/Reporter.php index 2dcff79e..10e52bc1 100644 --- a/tests/HTMLPurifier/SimpleTest/Reporter.php +++ b/tests/HTMLPurifier/SimpleTest/Reporter.php @@ -2,14 +2,14 @@ class HTMLPurifier_SimpleTest_Reporter extends HTMLReporter { - + protected $ac; - + public function __construct($encoding, $ac) { $this->ac = $ac; parent::__construct($encoding); } - + public function paintHeader($test_name) { parent::paintHeader($test_name); ?> @@ -28,7 +28,7 @@ class HTMLPurifier_SimpleTest_Reporter extends HTMLReporter strategies =& $strategies; } - + } // doesn't use Strategy harness class HTMLPurifier_Strategy_CompositeTest extends HTMLPurifier_Harness { - + function test() { - + generate_mock_once('HTMLPurifier_Strategy'); generate_mock_once('HTMLPurifier_Config'); generate_mock_once('HTMLPurifier_Context'); - + // setup a bunch of mock strategies to inject into our composite test - + $mock_1 = new HTMLPurifier_StrategyMock(); $mock_2 = new HTMLPurifier_StrategyMock(); $mock_3 = new HTMLPurifier_StrategyMock(); - + // setup the object - + $strategies = array(&$mock_1, &$mock_2, &$mock_3); $composite = new HTMLPurifier_Strategy_Composite_Test($strategies); - + // setup expectations - + $input_1 = 'This is raw data'; $input_2 = 'Processed by 1'; $input_3 = 'Processed by 1 and 2'; $input_4 = 'Processed by 1, 2 and 3'; // expected output - + $config = new HTMLPurifier_ConfigMock(); $context = new HTMLPurifier_ContextMock(); - + $params_1 = array($input_1, $config, $context); $params_2 = array($input_2, $config, $context); $params_3 = array($input_3, $config, $context); - + $mock_1->expectOnce('execute', $params_1); $mock_1->setReturnValue('execute', $input_2, $params_1); - + $mock_2->expectOnce('execute', $params_2); $mock_2->setReturnValue('execute', $input_3, $params_2); - + $mock_3->expectOnce('execute', $params_3); $mock_3->setReturnValue('execute', $input_4, $params_3); - + // perform test - + $output = $composite->execute($input_1, $config, $context); $this->assertIdentical($input_4, $output); - + } - + } diff --git a/tests/HTMLPurifier/Strategy/CoreTest.php b/tests/HTMLPurifier/Strategy/CoreTest.php index d5f9e27e..932f38ec 100644 --- a/tests/HTMLPurifier/Strategy/CoreTest.php +++ b/tests/HTMLPurifier/Strategy/CoreTest.php @@ -2,43 +2,43 @@ class HTMLPurifier_Strategy_CoreTest extends HTMLPurifier_StrategyHarness { - + function setUp() { parent::setUp(); $this->obj = new HTMLPurifier_Strategy_Core(); } - + function testBlankInput() { $this->assertResult(''); } - + function testMakeWellFormed() { $this->assertResult( 'Make well formed.', 'Make well formed.' ); } - + function testFixNesting() { $this->assertResult( '
        Fix nesting.
        ', '
        Fix nesting.
        ' ); } - + function testRemoveForeignElements() { $this->assertResult( 'Foreign element removal.', 'Foreign element removal.' ); } - + function testFirstThree() { $this->assertResult( '
        All three.
        ', '
        All three.
        ' ); } - + } diff --git a/tests/HTMLPurifier/Strategy/ErrorsHarness.php b/tests/HTMLPurifier/Strategy/ErrorsHarness.php index b2b5d5c7..2d51f7e2 100644 --- a/tests/HTMLPurifier/Strategy/ErrorsHarness.php +++ b/tests/HTMLPurifier/Strategy/ErrorsHarness.php @@ -2,16 +2,16 @@ class HTMLPurifier_Strategy_ErrorsHarness extends HTMLPurifier_ErrorsHarness { - + // needs to be defined protected function getStrategy() {} - + protected function invoke($input) { $strategy = $this->getStrategy(); $lexer = new HTMLPurifier_Lexer_DirectLex(); $tokens = $lexer->tokenizeHTML($input, $this->config, $this->context); $strategy->execute($tokens, $this->config, $this->context); } - + } diff --git a/tests/HTMLPurifier/Strategy/FixNestingTest.php b/tests/HTMLPurifier/Strategy/FixNestingTest.php index 8035faf6..20febddb 100644 --- a/tests/HTMLPurifier/Strategy/FixNestingTest.php +++ b/tests/HTMLPurifier/Strategy/FixNestingTest.php @@ -2,27 +2,27 @@ class HTMLPurifier_Strategy_FixNestingTest extends HTMLPurifier_StrategyHarness { - + function setUp() { parent::setUp(); $this->obj = new HTMLPurifier_Strategy_FixNesting(); } - + function testPreserveInlineInRoot() { $this->assertResult('Bold text'); } - + function testPreserveInlineAndBlockInRoot() { $this->assertResult('
        Blank
        Block
        '); } - + function testRemoveBlockInInline() { $this->assertResult( '
        Illegal div.
        ', 'Illegal div.' ); } - + function testEscapeBlockInInline() { $this->config->set('Core', 'EscapeInvalidChildren', true); $this->assertResult( @@ -30,53 +30,53 @@ class HTMLPurifier_Strategy_FixNestingTest extends HTMLPurifier_StrategyHarness '<div>Illegal div.</div>' ); } - + function testRemoveNodeWithMissingRequiredElements() { $this->assertResult('
          ', ''); } - + function testRemoveIllegalPCDATA() { $this->assertResult( '
            Illegal text
          • Legal item
          ', '
          • Legal item
          ' ); } - + function testCustomTableDefinition() { $this->assertResult('
          tag or be outside the table, but we're not smart enough to + be in a tag or be outside the table, but we're not smart enough to realize this so we just remove it. In such a case, we should tell the user that there was foreign data in the table, but then we shouldn't "demand" the user remove the data; it's more of a "here's a possible way of @@ -204,6 +204,6 @@ Don't forget to spruce up output. 6. Output needs to automatically give line and column numbers, basically "at line" on steroids. Look at W3C's output; it's ok. [PARTIALLY DONE] - + - We need a standard CSS to apply (check demo.css for some starting styling; some buttons would also be hip) diff --git a/docs/proposal-new-directives.txt b/docs/proposal-new-directives.txt index 1ce1b93b..c53ee75a 100644 --- a/docs/proposal-new-directives.txt +++ b/docs/proposal-new-directives.txt @@ -16,7 +16,7 @@ implemented, give us a ring, and we'll move it up the priority chain. %Attr.ClassBlacklist. When it's Whitelist, only allow those in %Attr.ClassWhitelist. -%Attr.MaxWidth, +%Attr.MaxWidth, %Attr.MaxHeight - caps for width and height related checks. (the hack in Pixels for an image crashing attack could be replaced by this) diff --git a/docs/ref-css-length.txt b/docs/ref-css-length.txt index 284ec8b2..d32ee108 100644 --- a/docs/ref-css-length.txt +++ b/docs/ref-css-length.txt @@ -22,7 +22,7 @@ Relative: 1 ex ~= 0.5 em, though Mozilla Firefox says 1 ex = 6px 1 px ~= 1 pt -Watch out: font-sizes can also be nested to get successively larger +Watch out: font-sizes can also be nested to get successively larger (although I do not relish having to keep track of context font-sizes, this may be necessary, especially for some of the more advanced features for preventing things like white on white). diff --git a/docs/ref-html-modularization.txt b/docs/ref-html-modularization.txt index c6faf721..1ac8c433 100644 --- a/docs/ref-html-modularization.txt +++ b/docs/ref-html-modularization.txt @@ -121,7 +121,7 @@ a proprietary system called ChildDef for performance and flexibility reasons, but this does not line up very well with W3C's notion of regexps for defining the allowed children of an element. -HTMLPurifier->elements[$element]->content_model and +HTMLPurifier->elements[$element]->content_model and HTMLPurifier->elements[$element]->content_model_type store information about the final ChildDef that will be stored in HTMLPurifier->elements[$element]->child (we use a different variable diff --git a/docs/ref-whatwg.txt b/docs/ref-whatwg.txt index 070d8e88..73d21f60 100644 --- a/docs/ref-whatwg.txt +++ b/docs/ref-whatwg.txt @@ -18,7 +18,7 @@ committing ourselves till the spec stabilizes, though. More immediately speaking though, however, is the well-defined parsing behavior that HTML 5 adds. While I have little interest in writing -another DirectLex parser, other parsers like ph5p +another DirectLex parser, other parsers like ph5p can be adapted to DOMLex to support much more flexible HTML parsing (a cool feature I've seen is how they resolve boldbothitalic). diff --git a/docs/specimens/windows-live-mail-desktop-beta.html b/docs/specimens/windows-live-mail-desktop-beta.html index f09cc322..f1d4faf9 100644 --- a/docs/specimens/windows-live-mail-desktop-beta.html +++ b/docs/specimens/windows-live-mail-desktop-beta.html @@ -4,71 +4,71 @@ - -
          Play -slideshow | Download the highest quality version of a picture by +
          Play +slideshow | Download the highest quality version of a picture by clicking the + above it
          -
            -
          1. Angry smile emoticonUn ka Tev iet, un ko tu dari? +
          2. Angry smile emoticonUn ka Tev iet, un ko tu dari?
          3. Aha!
          Sarakstucitis
          - -
          -
          This - is title for this +
          This + is title for this picture
          -
           
          -
          Online -pictures are available for 30 days. Get Windows Live Mail desktop to create + \ No newline at end of file diff --git a/extras/ConfigDoc/HTMLXSLTProcessor.php b/extras/ConfigDoc/HTMLXSLTProcessor.php index c09cca62..15120760 100644 --- a/extras/ConfigDoc/HTMLXSLTProcessor.php +++ b/extras/ConfigDoc/HTMLXSLTProcessor.php @@ -5,17 +5,17 @@ */ class ConfigDoc_HTMLXSLTProcessor { - + /** * Instance of XSLTProcessor */ protected $xsltProcessor; - + public function __construct($proc = false) { if ($proc === false) $proc = new XSLTProcessor(); $this->xsltProcessor = $proc; } - + /** * @note Allows a string $xsl filename to be passed */ @@ -27,7 +27,7 @@ class ConfigDoc_HTMLXSLTProcessor } return $this->xsltProcessor->importStylesheet($xsl); } - + /** * Transforms an XML file into compatible XHTML based on the stylesheet * @param $xml XML DOM tree, or string filename @@ -42,12 +42,12 @@ class ConfigDoc_HTMLXSLTProcessor $dom = $xml; } $out = $this->xsltProcessor->transformToXML($dom); - + // fudges for HTML backwards compatibility // assumes that document is XHTML $out = str_replace('/>', ' />', $out); //
          not
          $out = str_replace(' xmlns=""', '', $out); // rm unnecessary xmlns - + if (class_exists('Tidy')) { // cleanup output $config = array( @@ -60,10 +60,10 @@ class ConfigDoc_HTMLXSLTProcessor $tidy->cleanRepair(); $out = (string) $tidy; } - + return $out; } - + /** * Bulk sets parameters for the XSL stylesheet * @param array $options Associative array of options to set @@ -73,13 +73,13 @@ class ConfigDoc_HTMLXSLTProcessor $this->xsltProcessor->setParameter('', $name, $value); } } - + /** * Forward any other calls to the XSLT processor */ public function __call($name, $arguments) { call_user_func_array(array($this->xsltProcessor, $name), $arguments); } - + } diff --git a/extras/FSTools.php b/extras/FSTools.php index a37273a5..3b1ebb85 100644 --- a/extras/FSTools.php +++ b/extras/FSTools.php @@ -3,15 +3,15 @@ /** * Filesystem tools not provided by default; can recursively create, copy * and delete folders. Some template methods are provided for extensibility. - * + * * @note This class must be instantiated to be used, although it does * not maintain state. */ class FSTools { - + private static $singleton; - + /** * Returns a global instance of FSTools */ @@ -19,7 +19,7 @@ class FSTools if (empty(FSTools::$singleton)) FSTools::$singleton = new FSTools(); return FSTools::$singleton; } - + /** * Sets our global singleton to something else; useful for overloading * functions. @@ -27,7 +27,7 @@ class FSTools static public function setSingleton($singleton) { FSTools::$singleton = $singleton; } - + /** * Recursively creates a directory * @param string $folder Name of folder to create @@ -51,7 +51,7 @@ class FSTools $base .= DIRECTORY_SEPARATOR; } } - + /** * Copy a file, or recursively copy a folder and its contents; modified * so that copied files, if PHP, have includes removed @@ -85,17 +85,17 @@ class FSTools $dir->close(); return true; } - + /** * Overloadable function that tests a filename for copyability. By * default, everything should be copied; you can restrict things to - * ignore hidden files, unreadable files, etc. This function + * ignore hidden files, unreadable files, etc. This function * applies to copyr(). */ public function copyable($file) { return true; } - + /** * Delete a file, or a folder and its contents * @note Adapted from http://aidanlister.com/repos/v/function.rmdirr.php @@ -106,12 +106,12 @@ class FSTools if (!$this->file_exists($dirname)) { return false; } - + // Simple delete for a file if ($this->is_file($dirname) || $this->is_link($dirname)) { return $this->unlink($dirname); } - + // Loop through the folder $dir = $this->dir($dirname); while (false !== $entry = $dir->read()) { @@ -122,12 +122,12 @@ class FSTools // Recurse $this->rmdirr($dirname . DIRECTORY_SEPARATOR . $entry); } - + // Clean up $dir->close(); return $this->rmdir($dirname); } - + /** * Recursively globs a directory. */ @@ -140,9 +140,9 @@ class FSTools $sub_files = $this->globr($sub_dir, $pattern, $flags); $files = array_merge($files, $sub_files); } - return $files; + return $files; } - + /** * Allows for PHP functions to be called and be stubbed. * @warning This function will not work for functions that need @@ -151,5 +151,5 @@ class FSTools public function __call($name, $args) { return call_user_func_array($name, $args); } - + } diff --git a/extras/FSTools/File.php b/extras/FSTools/File.php index a9103098..59956a75 100644 --- a/extras/FSTools/File.php +++ b/extras/FSTools/File.php @@ -9,16 +9,16 @@ */ class FSTools_File { - + /** Filename of file this object represents */ protected $name; - + /** Handle for the file */ protected $handle = false; - + /** Instance of FSTools for interfacing with filesystem */ protected $fs; - + /** * Filename of file you wish to instantiate. * @note This file need not exist @@ -27,13 +27,13 @@ class FSTools_File $this->name = $name; $this->fs = $fs ? $fs : FSTools::singleton(); } - + /** Returns the filename of the file. */ public function getName() {return $this->name;} - + /** Returns directory of the file without trailing slash */ public function getDirectory() {return $this->fs->dirname($this->name);} - + /** * Retrieves the contents of a file * @todo Throw an exception if file doesn't exist @@ -41,27 +41,27 @@ class FSTools_File public function get() { return $this->fs->file_get_contents($this->name); } - + /** Writes contents to a file, creates new file if necessary */ public function write($contents) { return $this->fs->file_put_contents($this->name, $contents); } - + /** Deletes the file */ public function delete() { return $this->fs->unlink($this->name); } - + /** Returns true if file exists and is a file. */ public function exists() { return $this->fs->is_file($this->name); } - + /** Returns last file modification time */ public function getMTime() { return $this->fs->filemtime($this->name); } - + /** * Chmod a file * @note We ignore errors because of some weird owner trickery due @@ -70,14 +70,14 @@ class FSTools_File public function chmod($octal_code) { return @$this->fs->chmod($this->name, $octal_code); } - + /** Opens file's handle */ public function open($mode) { if ($this->handle) $this->close(); $this->handle = $this->fs->fopen($this->name, $mode); return true; } - + /** Closes file's handle */ public function close() { if (!$this->handle) return false; @@ -85,40 +85,40 @@ class FSTools_File $this->handle = false; return $status; } - + /** Retrieves a line from an open file, with optional max length $length */ public function getLine($length = null) { if (!$this->handle) $this->open('r'); if ($length === null) return $this->fs->fgets($this->handle); else return $this->fs->fgets($this->handle, $length); } - + /** Retrieves a character from an open file */ public function getChar() { if (!$this->handle) $this->open('r'); return $this->fs->fgetc($this->handle); } - + /** Retrieves an $length bytes of data from an open data */ public function read($length) { if (!$this->handle) $this->open('r'); return $this->fs->fread($this->handle, $length); } - + /** Writes to an open file */ public function put($string) { if (!$this->handle) $this->open('a'); return $this->fs->fwrite($this->handle, $string); } - + /** Returns TRUE if the end of the file has been reached */ public function eof() { if (!$this->handle) return true; return $this->fs->feof($this->handle); } - + public function __destruct() { if ($this->handle) $this->close(); } - + } diff --git a/extras/HTMLPurifierExtras.autoload.php b/extras/HTMLPurifierExtras.autoload.php index d4909ccd..e1bd2749 100644 --- a/extras/HTMLPurifierExtras.autoload.php +++ b/extras/HTMLPurifierExtras.autoload.php @@ -3,7 +3,7 @@ /** * @file * Convenience file that registers autoload handler for HTML Purifier. - * + * * @warning * This autoloader does not contain the compatibility code seen in * HTMLPurifier_Bootstrap; the user is expected to make any necessary diff --git a/extras/HTMLPurifierExtras.php b/extras/HTMLPurifierExtras.php index c79ae9c6..f4e3e8df 100644 --- a/extras/HTMLPurifierExtras.php +++ b/extras/HTMLPurifierExtras.php @@ -6,14 +6,14 @@ */ class HTMLPurifierExtras { - + public static function autoload($class) { $path = HTMLPurifierExtras::getPath($class); if (!$path) return false; require $path; return true; } - + public static function getPath($class) { if ( strncmp('FSTools', $class, 7) !== 0 && @@ -23,5 +23,5 @@ class HTMLPurifierExtras // Standard implementation: return str_replace('_', '/', $class) . '.php'; } - + } diff --git a/extras/README b/extras/README index 6ed42151..9d6fbc32 100644 --- a/extras/README +++ b/extras/README @@ -24,7 +24,7 @@ the filesystem. It currently consists of two classes: to call arbitrary native PHP functions through it like $FS->fopen(...). This makes it a lot simpler to mock these filesystem calls for unit testing. -- FSTools_File: This object represents a single file, and has almost any +- FSTools_File: This object represents a single file, and has almost any method imaginable one would need. Check the files themselves for more information. diff --git a/library/HTMLPurifier.includes.php b/library/HTMLPurifier.includes.php index 7ebbb592..56e5effa 100644 --- a/library/HTMLPurifier.includes.php +++ b/library/HTMLPurifier.includes.php @@ -6,13 +6,13 @@ * the core files required by HTML Purifier. Use this if performance is a * primary concern and you are using an opcode cache. PLEASE DO NOT EDIT THIS * FILE, changes will be overwritten the next time the script is run. - * + * * @version 3.2.0 - * + * * @warning * You must *not* include any other HTML Purifier files before this file, * because 'require' not 'require_once' is used. - * + * * @warning * This file requires that the include path contains the HTML Purifier * library directory; this is not auto-set. @@ -55,6 +55,8 @@ require 'HTMLPurifier/LanguageFactory.php'; require 'HTMLPurifier/Length.php'; require 'HTMLPurifier/Lexer.php'; require 'HTMLPurifier/PercentEncoder.php'; +require 'HTMLPurifier/PropertyList.php'; +require 'HTMLPurifier/PropertyListIterator.php'; require 'HTMLPurifier/Strategy.php'; require 'HTMLPurifier/StringHash.php'; require 'HTMLPurifier/StringHashParser.php'; diff --git a/library/HTMLPurifier.php b/library/HTMLPurifier.php index 629f3b26..a94bf5ba 100644 --- a/library/HTMLPurifier.php +++ b/library/HTMLPurifier.php @@ -1,11 +1,11 @@ config = HTMLPurifier_Config::create($config); - + $this->strategy = new HTMLPurifier_Strategy_Core(); - + } - + /** * Adds a filter to process the output. First come first serve * @param $filter HTMLPurifier_Filter object @@ -101,10 +101,10 @@ class HTMLPurifier trigger_error('HTMLPurifier->addFilter() is deprecated, use configuration directives in the Filter namespace or Filter.Custom', E_USER_WARNING); $this->filters[] = $filter; } - + /** * Filters an HTML snippet/document to be XSS-free and standards-compliant. - * + * * @param $html String of HTML to purify * @param $config HTMLPurifier_Config object for this operation, if omitted, * defaults to the config object specified during this @@ -113,38 +113,38 @@ class HTMLPurifier * @return Purified HTML */ public function purify($html, $config = null) { - + // :TODO: make the config merge in, instead of replace $config = $config ? HTMLPurifier_Config::create($config) : $this->config; - + // implementation is partially environment dependant, partially // configuration dependant $lexer = HTMLPurifier_Lexer::create($config); - + $context = new HTMLPurifier_Context(); - + // setup HTML generator $this->generator = new HTMLPurifier_Generator($config, $context); $context->register('Generator', $this->generator); - + // set up global context variables if ($config->get('Core', 'CollectErrors')) { // may get moved out if other facilities use it $language_factory = HTMLPurifier_LanguageFactory::instance(); $language = $language_factory->create($config, $context); $context->register('Locale', $language); - + $error_collector = new HTMLPurifier_ErrorCollector($context); $context->register('ErrorCollector', $error_collector); } - + // setup id_accumulator context, necessary due to the fact that // AttrValidator can be called from many places $id_accumulator = HTMLPurifier_IDAccumulator::build($config, $context); $context->register('IDAccumulator', $id_accumulator); - + $html = HTMLPurifier_Encoder::convertToUTF8($html, $config, $context); - + // setup filters $filter_flags = $config->getBatch('Filter'); $custom_filters = $filter_flags['Custom']; @@ -161,13 +161,13 @@ class HTMLPurifier } $filters = array_merge($filters, $this->filters); // maybe prepare(), but later - + for ($i = 0, $filter_size = count($filters); $i < $filter_size; $i++) { $html = $filters[$i]->preFilter($html, $config, $context); } - + // purified HTML - $html = + $html = $this->generator->generateFromTokens( // list of tokens $this->strategy->execute( @@ -179,16 +179,16 @@ class HTMLPurifier $config, $context ) ); - + for ($i = $filter_size - 1; $i >= 0; $i--) { $html = $filters[$i]->postFilter($html, $config, $context); } - + $html = HTMLPurifier_Encoder::convertFromUTF8($html, $config, $context); $this->context =& $context; return $html; } - + /** * Filters an array of HTML snippets * @param $config Optional HTMLPurifier_Config object for this operation. @@ -204,7 +204,7 @@ class HTMLPurifier $this->context = $context_array; return $array_of_html; } - + /** * Singleton for enforcing just one HTML Purifier in your system * @param $prototype Optional prototype HTMLPurifier instance to @@ -223,12 +223,12 @@ class HTMLPurifier } return self::$instance; } - + /** * @note Backwards compatibility, see instance() */ public static function getInstance($prototype = null) { return HTMLPurifier::instance($prototype); } - + } diff --git a/library/HTMLPurifier.safe-includes.php b/library/HTMLPurifier.safe-includes.php index 05cc0a3c..7d393036 100644 --- a/library/HTMLPurifier.safe-includes.php +++ b/library/HTMLPurifier.safe-includes.php @@ -6,7 +6,7 @@ * the core files required by HTML Purifier. This is a convenience stub that * includes all files using dirname(__FILE__) and require_once. PLEASE DO NOT * EDIT THIS FILE, changes will be overwritten the next time the script is run. - * + * * Changes to include_path are not necessary. */ @@ -49,6 +49,8 @@ require_once $__dir . '/HTMLPurifier/LanguageFactory.php'; require_once $__dir . '/HTMLPurifier/Length.php'; require_once $__dir . '/HTMLPurifier/Lexer.php'; require_once $__dir . '/HTMLPurifier/PercentEncoder.php'; +require_once $__dir . '/HTMLPurifier/PropertyList.php'; +require_once $__dir . '/HTMLPurifier/PropertyListIterator.php'; require_once $__dir . '/HTMLPurifier/Strategy.php'; require_once $__dir . '/HTMLPurifier/StringHash.php'; require_once $__dir . '/HTMLPurifier/StringHashParser.php'; diff --git a/library/HTMLPurifier/AttrCollections.php b/library/HTMLPurifier/AttrCollections.php index 33f42984..cb65aa8b 100644 --- a/library/HTMLPurifier/AttrCollections.php +++ b/library/HTMLPurifier/AttrCollections.php @@ -6,12 +6,12 @@ class HTMLPurifier_AttrCollections { - + /** * Associative array of attribute collections, indexed by name */ public $info = array(); - + /** * Performs all expansions on internal data for use by other inclusions * It also collects all attribute collection extensions from @@ -45,7 +45,7 @@ class HTMLPurifier_AttrCollections $this->expandIdentifiers($this->info[$name], $attr_types); } } - + /** * Takes a reference to an attribute associative array and performs * all inclusions specified by the zero index. @@ -72,7 +72,7 @@ class HTMLPurifier_AttrCollections } unset($attr[0]); } - + /** * Expands all string identifiers in an attribute array by replacing * them with the appropriate values inside HTMLPurifier_AttrTypes @@ -80,17 +80,17 @@ class HTMLPurifier_AttrCollections * @param $attr_types HTMLPurifier_AttrTypes instance */ public function expandIdentifiers(&$attr, $attr_types) { - + // because foreach will process new elements we add, make sure we // skip duplicates $processed = array(); - + foreach ($attr as $def_i => $def) { // skip inclusions if ($def_i === 0) continue; - + if (isset($processed[$def_i])) continue; - + // determine whether or not attribute is required if ($required = (strpos($def_i, '*') !== false)) { // rename the definition @@ -98,21 +98,21 @@ class HTMLPurifier_AttrCollections $def_i = trim($def_i, '*'); $attr[$def_i] = $def; } - + $processed[$def_i] = true; - + // if we've already got a literal object, move on if (is_object($def)) { // preserve previous required $attr[$def_i]->required = ($required || $attr[$def_i]->required); continue; } - + if ($def === false) { unset($attr[$def_i]); continue; } - + if ($t = $attr_types->get($def)) { $attr[$def_i] = $t; $attr[$def_i]->required = $required; @@ -120,8 +120,8 @@ class HTMLPurifier_AttrCollections unset($attr[$def_i]); } } - + } - + } diff --git a/library/HTMLPurifier/AttrDef.php b/library/HTMLPurifier/AttrDef.php index eefe1c5d..e2815063 100644 --- a/library/HTMLPurifier/AttrDef.php +++ b/library/HTMLPurifier/AttrDef.php @@ -2,53 +2,53 @@ /** * Base class for all validating attribute definitions. - * + * * This family of classes forms the core for not only HTML attribute validation, * but also any sort of string that needs to be validated or cleaned (which - * means CSS properties and composite definitions are defined here too). + * means CSS properties and composite definitions are defined here too). * Besides defining (through code) what precisely makes the string valid, * subclasses are also responsible for cleaning the code if possible. */ abstract class HTMLPurifier_AttrDef { - + /** * Tells us whether or not an HTML attribute is minimized. Has no * meaning in other contexts. */ public $minimized = false; - + /** * Tells us whether or not an HTML attribute is required. Has no * meaning in other contexts */ public $required = false; - + /** * Validates and cleans passed string according to a definition. - * + * * @param $string String to be validated and cleaned. * @param $config Mandatory HTMLPurifier_Config object. * @param $context Mandatory HTMLPurifier_AttrContext object. */ abstract public function validate($string, $config, $context); - + /** * Convenience method that parses a string as if it were CDATA. - * + * * This method process a string in the manner specified at * by removing * leading and trailing whitespace, ignoring line feeds, and replacing * carriage returns and tabs with spaces. While most useful for HTML * attributes specified as CDATA, it can also be applied to most CSS * values. - * + * * @note This method is not entirely standards compliant, as trim() removes * more types of whitespace than specified in the spec. In practice, * this is rarely a problem, as those extra characters usually have * already been removed by HTMLPurifier_Encoder. - * + * * @warning This processing is inconsistent with XML's whitespace handling * as specified by section 3.3.3 and referenced XHTML 1.0 section * 4.7. However, note that we are NOT necessarily @@ -60,7 +60,7 @@ abstract class HTMLPurifier_AttrDef $string = str_replace(array("\n", "\t", "\r"), ' ', $string); return $string; } - + /** * Factory method for creating this class from a string. * @param $string String construction info @@ -73,7 +73,7 @@ abstract class HTMLPurifier_AttrDef // to clone or instantiate new copies. (Instantiation is safer.) return $this; } - + /** * Removes spaces from rgb(0, 0, 0) so that shorthand CSS properties work * properly. THIS IS A HACK! @@ -81,6 +81,6 @@ abstract class HTMLPurifier_AttrDef protected function mungeRgb($string) { return preg_replace('/rgb\((\d+)\s*,\s*(\d+)\s*,\s*(\d+)\)/', 'rgb(\1,\2,\3)', $string); } - + } diff --git a/library/HTMLPurifier/AttrDef/CSS.php b/library/HTMLPurifier/AttrDef/CSS.php index 53afaf08..b6a4c3ab 100644 --- a/library/HTMLPurifier/AttrDef/CSS.php +++ b/library/HTMLPurifier/AttrDef/CSS.php @@ -13,28 +13,28 @@ */ class HTMLPurifier_AttrDef_CSS extends HTMLPurifier_AttrDef { - + public function validate($css, $config, $context) { - + $css = $this->parseCDATA($css); - + $definition = $config->getCSSDefinition(); - + // we're going to break the spec and explode by semicolons. // This is because semicolon rarely appears in escaped form // Doing this is generally flaky but fast // IT MIGHT APPEAR IN URIs, see HTMLPurifier_AttrDef_CSSURI // for details - + $declarations = explode(';', $css); $propvalues = array(); - + /** * Name of the current CSS property being validated. */ $property = false; $context->register('CurrentCSSProperty', $property); - + foreach ($declarations as $declaration) { if (!$declaration) continue; if (!strpos($declaration, ':')) continue; @@ -66,21 +66,21 @@ class HTMLPurifier_AttrDef_CSS extends HTMLPurifier_AttrDef if ($result === false) continue; $propvalues[$property] = $result; } - + $context->destroy('CurrentCSSProperty'); - + // procedure does not write the new CSS simultaneously, so it's // slightly inefficient, but it's the only way of getting rid of // duplicates. Perhaps config to optimize it, but not now. - + $new_declarations = ''; foreach ($propvalues as $prop => $value) { $new_declarations .= "$prop:$value;"; } - + return $new_declarations ? $new_declarations : false; - + } - + } diff --git a/library/HTMLPurifier/AttrDef/CSS/AlphaValue.php b/library/HTMLPurifier/AttrDef/CSS/AlphaValue.php index 701e7e44..9eb3eee8 100644 --- a/library/HTMLPurifier/AttrDef/CSS/AlphaValue.php +++ b/library/HTMLPurifier/AttrDef/CSS/AlphaValue.php @@ -2,11 +2,11 @@ class HTMLPurifier_AttrDef_CSS_AlphaValue extends HTMLPurifier_AttrDef_CSS_Number { - + public function __construct() { parent::__construct(false); // opacity is non-negative, but we will clamp it } - + public function validate($number, $config, $context) { $result = parent::validate($number, $config, $context); if ($result === false) return $result; @@ -15,5 +15,5 @@ class HTMLPurifier_AttrDef_CSS_AlphaValue extends HTMLPurifier_AttrDef_CSS_Numbe if ($float > 1.0) $result = '1'; return $result; } - + } diff --git a/library/HTMLPurifier/AttrDef/CSS/Background.php b/library/HTMLPurifier/AttrDef/CSS/Background.php index 76afa440..c698741e 100644 --- a/library/HTMLPurifier/AttrDef/CSS/Background.php +++ b/library/HTMLPurifier/AttrDef/CSS/Background.php @@ -6,13 +6,13 @@ */ class HTMLPurifier_AttrDef_CSS_Background extends HTMLPurifier_AttrDef { - + /** * Local copy of component validators. * @note See HTMLPurifier_AttrDef_Font::$info for a similar impl. */ protected $info; - + public function __construct($config) { $def = $config->getCSSDefinition(); $this->info['background-color'] = $def->info['background-color']; @@ -21,29 +21,29 @@ class HTMLPurifier_AttrDef_CSS_Background extends HTMLPurifier_AttrDef $this->info['background-attachment'] = $def->info['background-attachment']; $this->info['background-position'] = $def->info['background-position']; } - + public function validate($string, $config, $context) { - + // regular pre-processing $string = $this->parseCDATA($string); if ($string === '') return false; - + // munge rgb() decl if necessary $string = $this->mungeRgb($string); - + // assumes URI doesn't have spaces in it $bits = explode(' ', strtolower($string)); // bits to process - + $caught = array(); $caught['color'] = false; $caught['image'] = false; $caught['repeat'] = false; $caught['attachment'] = false; $caught['position'] = false; - + $i = 0; // number of catches $none = false; - + foreach ($bits as $bit) { if ($bit === '') continue; foreach ($caught as $key => $status) { @@ -64,23 +64,23 @@ class HTMLPurifier_AttrDef_CSS_Background extends HTMLPurifier_AttrDef break; } } - + if (!$i) return false; if ($caught['position'] !== false) { $caught['position'] = $this->info['background-position']-> validate($caught['position'], $config, $context); } - + $ret = array(); foreach ($caught as $value) { if ($value === false) continue; $ret[] = $value; } - + if (empty($ret)) return false; return implode(' ', $ret); - + } - + } diff --git a/library/HTMLPurifier/AttrDef/CSS/BackgroundPosition.php b/library/HTMLPurifier/AttrDef/CSS/BackgroundPosition.php index 7e424e12..1dddfcd1 100644 --- a/library/HTMLPurifier/AttrDef/CSS/BackgroundPosition.php +++ b/library/HTMLPurifier/AttrDef/CSS/BackgroundPosition.php @@ -7,7 +7,7 @@ [ | | left | center | right ] - [ + [ | | top | center | bottom ]? ] | @@ -28,10 +28,10 @@ /* QuirksMode says: keyword + length/percentage must be ordered correctly, as per W3C - + Internet Explorer and Opera, however, support arbitrary ordering. We should fix it up. - + Minor issue though, not strictly necessary. */ @@ -43,27 +43,27 @@ */ class HTMLPurifier_AttrDef_CSS_BackgroundPosition extends HTMLPurifier_AttrDef { - + protected $length; protected $percentage; - + public function __construct() { $this->length = new HTMLPurifier_AttrDef_CSS_Length(); $this->percentage = new HTMLPurifier_AttrDef_CSS_Percentage(); } - + public function validate($string, $config, $context) { $string = $this->parseCDATA($string); $bits = explode(' ', $string); - + $keywords = array(); $keywords['h'] = false; // left, right $keywords['v'] = false; // top, bottom $keywords['c'] = false; // center $measures = array(); - + $i = 0; - + $lookup = array( 'top' => 'v', 'bottom' => 'v', @@ -71,10 +71,10 @@ class HTMLPurifier_AttrDef_CSS_BackgroundPosition extends HTMLPurifier_AttrDef 'right' => 'h', 'center' => 'c' ); - + foreach ($bits as $bit) { if ($bit === '') continue; - + // test for keyword $lbit = ctype_lower($bit) ? $bit : strtolower($bit); if (isset($lookup[$lbit])) { @@ -82,28 +82,28 @@ class HTMLPurifier_AttrDef_CSS_BackgroundPosition extends HTMLPurifier_AttrDef $keywords[$status] = $lbit; $i++; } - + // test for length $r = $this->length->validate($bit, $config, $context); if ($r !== false) { $measures[] = $r; $i++; } - + // test for percentage $r = $this->percentage->validate($bit, $config, $context); if ($r !== false) { $measures[] = $r; $i++; } - + } - + if (!$i) return false; // no valid values were caught - - + + $ret = array(); - + // first keyword if ($keywords['h']) $ret[] = $keywords['h']; elseif (count($measures)) $ret[] = array_shift($measures); @@ -111,15 +111,15 @@ class HTMLPurifier_AttrDef_CSS_BackgroundPosition extends HTMLPurifier_AttrDef $ret[] = $keywords['c']; $keywords['c'] = false; // prevent re-use: center = center center } - + if ($keywords['v']) $ret[] = $keywords['v']; elseif (count($measures)) $ret[] = array_shift($measures); elseif ($keywords['c']) $ret[] = $keywords['c']; - + if (empty($ret)) return false; return implode(' ', $ret); - + } - + } diff --git a/library/HTMLPurifier/AttrDef/CSS/Border.php b/library/HTMLPurifier/AttrDef/CSS/Border.php index ec0249ef..b3afdb72 100644 --- a/library/HTMLPurifier/AttrDef/CSS/Border.php +++ b/library/HTMLPurifier/AttrDef/CSS/Border.php @@ -5,19 +5,19 @@ */ class HTMLPurifier_AttrDef_CSS_Border extends HTMLPurifier_AttrDef { - + /** * Local copy of properties this property is shorthand for. */ protected $info = array(); - + public function __construct($config) { $def = $config->getCSSDefinition(); $this->info['border-width'] = $def->info['border-width']; $this->info['border-style'] = $def->info['border-style']; $this->info['border-top-color'] = $def->info['border-top-color']; } - + public function validate($string, $config, $context) { $string = $this->parseCDATA($string); $string = $this->mungeRgb($string); @@ -37,6 +37,6 @@ class HTMLPurifier_AttrDef_CSS_Border extends HTMLPurifier_AttrDef } return rtrim($ret); } - + } diff --git a/library/HTMLPurifier/AttrDef/CSS/Color.php b/library/HTMLPurifier/AttrDef/CSS/Color.php index e47eac69..efaafb35 100644 --- a/library/HTMLPurifier/AttrDef/CSS/Color.php +++ b/library/HTMLPurifier/AttrDef/CSS/Color.php @@ -5,18 +5,18 @@ */ class HTMLPurifier_AttrDef_CSS_Color extends HTMLPurifier_AttrDef { - + public function validate($color, $config, $context) { - + static $colors = null; if ($colors === null) $colors = $config->get('Core', 'ColorKeywords'); - + $color = trim($color); if ($color === '') return false; - + $lower = strtolower($color); if (isset($colors[$lower])) return $colors[$lower]; - + if (strpos($color, 'rgb(') !== false) { // rgb literal handling $length = strlen($color); @@ -68,10 +68,10 @@ class HTMLPurifier_AttrDef_CSS_Color extends HTMLPurifier_AttrDef if ($length !== 3 && $length !== 6) return false; if (!ctype_xdigit($hex)) return false; } - + return $color; - + } - + } diff --git a/library/HTMLPurifier/AttrDef/CSS/Composite.php b/library/HTMLPurifier/AttrDef/CSS/Composite.php index c9650699..66d670a0 100644 --- a/library/HTMLPurifier/AttrDef/CSS/Composite.php +++ b/library/HTMLPurifier/AttrDef/CSS/Composite.php @@ -2,7 +2,7 @@ /** * Allows multiple validators to attempt to validate attribute. - * + * * Composite is just what it sounds like: a composite of many validators. * This means that multiple HTMLPurifier_AttrDef objects will have a whack * at the string. If one of them passes, that's what is returned. This is @@ -11,20 +11,20 @@ */ class HTMLPurifier_AttrDef_CSS_Composite extends HTMLPurifier_AttrDef { - + /** * List of HTMLPurifier_AttrDef objects that may process strings * @todo Make protected */ public $defs; - + /** * @param $defs List of HTMLPurifier_AttrDef objects */ public function __construct($defs) { $this->defs = $defs; } - + public function validate($string, $config, $context) { foreach ($this->defs as $i => $def) { $result = $this->defs[$i]->validate($string, $config, $context); @@ -32,6 +32,6 @@ class HTMLPurifier_AttrDef_CSS_Composite extends HTMLPurifier_AttrDef } return false; } - + } diff --git a/library/HTMLPurifier/AttrDef/CSS/DenyElementDecorator.php b/library/HTMLPurifier/AttrDef/CSS/DenyElementDecorator.php index 756dec3c..bbf3f952 100644 --- a/library/HTMLPurifier/AttrDef/CSS/DenyElementDecorator.php +++ b/library/HTMLPurifier/AttrDef/CSS/DenyElementDecorator.php @@ -6,7 +6,7 @@ class HTMLPurifier_AttrDef_CSS_DenyElementDecorator extends HTMLPurifier_AttrDef { protected $def, $element; - + /** * @param $def Definition to wrap * @param $element Element to deny diff --git a/library/HTMLPurifier/AttrDef/CSS/Filter.php b/library/HTMLPurifier/AttrDef/CSS/Filter.php index 3fe5e589..1bc6ceb5 100644 --- a/library/HTMLPurifier/AttrDef/CSS/Filter.php +++ b/library/HTMLPurifier/AttrDef/CSS/Filter.php @@ -7,13 +7,13 @@ */ class HTMLPurifier_AttrDef_CSS_Filter extends HTMLPurifier_AttrDef { - + protected $intValidator; - + public function __construct() { $this->intValidator = new HTMLPurifier_AttrDef_Integer(); } - + public function validate($value, $config, $context) { $value = $this->parseCDATA($value); if ($value === 'none') return $value; @@ -48,5 +48,5 @@ class HTMLPurifier_AttrDef_CSS_Filter extends HTMLPurifier_AttrDef $ret_function = "$function($ret_parameters)"; return $ret_function; } - + } diff --git a/library/HTMLPurifier/AttrDef/CSS/Font.php b/library/HTMLPurifier/AttrDef/CSS/Font.php index a4a74b43..9a621ad4 100644 --- a/library/HTMLPurifier/AttrDef/CSS/Font.php +++ b/library/HTMLPurifier/AttrDef/CSS/Font.php @@ -5,17 +5,17 @@ */ class HTMLPurifier_AttrDef_CSS_Font extends HTMLPurifier_AttrDef { - + /** * Local copy of component validators. - * + * * @note If we moved specific CSS property definitions to their own * classes instead of having them be assembled at run time by * CSSDefinition, this wouldn't be necessary. We'd instantiate * our own copies. */ protected $info = array(); - + public function __construct($config) { $def = $config->getCSSDefinition(); $this->info['font-style'] = $def->info['font-style']; @@ -25,9 +25,9 @@ class HTMLPurifier_AttrDef_CSS_Font extends HTMLPurifier_AttrDef $this->info['line-height'] = $def->info['line-height']; $this->info['font-family'] = $def->info['font-family']; } - + public function validate($string, $config, $context) { - + static $system_fonts = array( 'caption' => true, 'icon' => true, @@ -36,27 +36,27 @@ class HTMLPurifier_AttrDef_CSS_Font extends HTMLPurifier_AttrDef 'small-caption' => true, 'status-bar' => true ); - + // regular pre-processing $string = $this->parseCDATA($string); if ($string === '') return false; - + // check if it's one of the keywords $lowercase_string = strtolower($string); if (isset($system_fonts[$lowercase_string])) { return $lowercase_string; } - + $bits = explode(' ', $string); // bits to process $stage = 0; // this indicates what we're looking for $caught = array(); // which stage 0 properties have we caught? $stage_1 = array('font-style', 'font-variant', 'font-weight'); $final = ''; // output - + for ($i = 0, $size = count($bits); $i < $size; $i++) { if ($bits[$i] === '') continue; switch ($stage) { - + // attempting to catch font-style, font-variant or font-weight case 0: foreach ($stage_1 as $validator_name) { @@ -72,7 +72,7 @@ class HTMLPurifier_AttrDef_CSS_Font extends HTMLPurifier_AttrDef // all three caught, continue on if (count($caught) >= 3) $stage = 1; if ($r !== false) break; - + // attempting to catch font-size and perhaps line-height case 1: $found_slash = false; @@ -126,7 +126,7 @@ class HTMLPurifier_AttrDef_CSS_Font extends HTMLPurifier_AttrDef break; } return false; - + // attempting to catch font-family case 2: $font_family = @@ -143,6 +143,6 @@ class HTMLPurifier_AttrDef_CSS_Font extends HTMLPurifier_AttrDef } return false; } - + } diff --git a/library/HTMLPurifier/AttrDef/CSS/FontFamily.php b/library/HTMLPurifier/AttrDef/CSS/FontFamily.php index d7f04a8b..494cff73 100644 --- a/library/HTMLPurifier/AttrDef/CSS/FontFamily.php +++ b/library/HTMLPurifier/AttrDef/CSS/FontFamily.php @@ -6,7 +6,7 @@ */ class HTMLPurifier_AttrDef_CSS_FontFamily extends HTMLPurifier_AttrDef { - + public function validate($string, $config, $context) { static $generic_names = array( 'serif' => true, @@ -15,7 +15,7 @@ class HTMLPurifier_AttrDef_CSS_FontFamily extends HTMLPurifier_AttrDef 'fantasy' => true, 'cursive' => true ); - + // assume that no font names contain commas in them $fonts = explode(',', $string); $final = ''; @@ -34,7 +34,7 @@ class HTMLPurifier_AttrDef_CSS_FontFamily extends HTMLPurifier_AttrDef $quote = $font[0]; if ($font[$length - 1] !== $quote) continue; $font = substr($font, 1, $length - 2); - + $new_font = ''; for ($i = 0, $c = strlen($font); $i < $c; $i++) { if ($font[$i] === '\\') { @@ -62,19 +62,19 @@ class HTMLPurifier_AttrDef_CSS_FontFamily extends HTMLPurifier_AttrDef } $new_font .= $font[$i]; } - + $font = $new_font; } // $font is a pure representation of the font name - + if (ctype_alnum($font) && $font !== '') { // very simple font, allow it in unharmed $final .= $font . ', '; continue; } - + // complicated font, requires quoting - + // armor single quotes and new lines $font = str_replace("\\", "\\\\", $font); $font = str_replace("'", "\\'", $font); @@ -84,6 +84,6 @@ class HTMLPurifier_AttrDef_CSS_FontFamily extends HTMLPurifier_AttrDef if ($final === '') return false; return $final; } - + } diff --git a/library/HTMLPurifier/AttrDef/CSS/ImportantDecorator.php b/library/HTMLPurifier/AttrDef/CSS/ImportantDecorator.php index 97b414c7..84dc795e 100644 --- a/library/HTMLPurifier/AttrDef/CSS/ImportantDecorator.php +++ b/library/HTMLPurifier/AttrDef/CSS/ImportantDecorator.php @@ -6,7 +6,7 @@ class HTMLPurifier_AttrDef_CSS_ImportantDecorator extends HTMLPurifier_AttrDef { protected $def, $allow; - + /** * @param $def Definition to wrap * @param $allow Whether or not to allow !important diff --git a/library/HTMLPurifier/AttrDef/CSS/Length.php b/library/HTMLPurifier/AttrDef/CSS/Length.php index 2b8db17c..5a13a81b 100644 --- a/library/HTMLPurifier/AttrDef/CSS/Length.php +++ b/library/HTMLPurifier/AttrDef/CSS/Length.php @@ -5,9 +5,9 @@ */ class HTMLPurifier_AttrDef_CSS_Length extends HTMLPurifier_AttrDef { - + protected $min, $max; - + /** * @param HTMLPurifier_Length $max Minimum length, or null for no bound. String is also acceptable. * @param HTMLPurifier_Length $max Maximum length, or null for no bound. String is also acceptable. @@ -16,18 +16,18 @@ class HTMLPurifier_AttrDef_CSS_Length extends HTMLPurifier_AttrDef $this->min = $min !== null ? HTMLPurifier_Length::make($min) : null; $this->max = $max !== null ? HTMLPurifier_Length::make($max) : null; } - + public function validate($string, $config, $context) { $string = $this->parseCDATA($string); - + // Optimizations if ($string === '') return false; if ($string === '0') return '0'; if (strlen($string) === 1) return false; - + $length = HTMLPurifier_Length::make($string); if (!$length->isValid()) return false; - + if ($this->min) { $c = $length->compareTo($this->min); if ($c === false) return false; @@ -38,9 +38,9 @@ class HTMLPurifier_AttrDef_CSS_Length extends HTMLPurifier_AttrDef if ($c === false) return false; if ($c > 0) return false; } - + return $length->toString(); } - + } diff --git a/library/HTMLPurifier/AttrDef/CSS/ListStyle.php b/library/HTMLPurifier/AttrDef/CSS/ListStyle.php index 836cb465..8614e6c9 100644 --- a/library/HTMLPurifier/AttrDef/CSS/ListStyle.php +++ b/library/HTMLPurifier/AttrDef/CSS/ListStyle.php @@ -6,37 +6,37 @@ */ class HTMLPurifier_AttrDef_CSS_ListStyle extends HTMLPurifier_AttrDef { - + /** * Local copy of component validators. * @note See HTMLPurifier_AttrDef_CSS_Font::$info for a similar impl. */ protected $info; - + public function __construct($config) { $def = $config->getCSSDefinition(); $this->info['list-style-type'] = $def->info['list-style-type']; $this->info['list-style-position'] = $def->info['list-style-position']; $this->info['list-style-image'] = $def->info['list-style-image']; } - + public function validate($string, $config, $context) { - + // regular pre-processing $string = $this->parseCDATA($string); if ($string === '') return false; - + // assumes URI doesn't have spaces in it $bits = explode(' ', strtolower($string)); // bits to process - + $caught = array(); $caught['type'] = false; $caught['position'] = false; $caught['image'] = false; - + $i = 0; // number of catches $none = false; - + foreach ($bits as $bit) { if ($i >= 3) return; // optimization bit if ($bit === '') continue; @@ -54,24 +54,24 @@ class HTMLPurifier_AttrDef_CSS_ListStyle extends HTMLPurifier_AttrDef break; } } - + if (!$i) return false; - + $ret = array(); - + // construct type if ($caught['type']) $ret[] = $caught['type']; - + // construct image if ($caught['image']) $ret[] = $caught['image']; - + // construct position if ($caught['position']) $ret[] = $caught['position']; - + if (empty($ret)) return false; return implode(' ', $ret); - + } - + } diff --git a/library/HTMLPurifier/AttrDef/CSS/Multiple.php b/library/HTMLPurifier/AttrDef/CSS/Multiple.php index 878940db..d72829a6 100644 --- a/library/HTMLPurifier/AttrDef/CSS/Multiple.php +++ b/library/HTMLPurifier/AttrDef/CSS/Multiple.php @@ -2,30 +2,30 @@ /** * Framework class for strings that involve multiple values. - * + * * Certain CSS properties such as border-width and margin allow multiple * lengths to be specified. This class can take a vanilla border-width * definition and multiply it, usually into a max of four. - * + * * @note Even though the CSS specification isn't clear about it, inherit * can only be used alone: it will never manifest as part of a multi * shorthand declaration. Thus, this class does not allow inherit. */ class HTMLPurifier_AttrDef_CSS_Multiple extends HTMLPurifier_AttrDef { - + /** * Instance of component definition to defer validation to. * @todo Make protected */ public $single; - + /** * Max number of values allowed. * @todo Make protected */ public $max; - + /** * @param $single HTMLPurifier_AttrDef to multiply * @param $max Max number of values allowed (usually four) @@ -34,7 +34,7 @@ class HTMLPurifier_AttrDef_CSS_Multiple extends HTMLPurifier_AttrDef $this->single = $single; $this->max = $max; } - + public function validate($string, $config, $context) { $string = $this->parseCDATA($string); if ($string === '') return false; @@ -52,6 +52,6 @@ class HTMLPurifier_AttrDef_CSS_Multiple extends HTMLPurifier_AttrDef if ($final === '') return false; return rtrim($final); } - + } diff --git a/library/HTMLPurifier/AttrDef/CSS/Number.php b/library/HTMLPurifier/AttrDef/CSS/Number.php index 15153e4b..a00aad12 100644 --- a/library/HTMLPurifier/AttrDef/CSS/Number.php +++ b/library/HTMLPurifier/AttrDef/CSS/Number.php @@ -5,30 +5,30 @@ */ class HTMLPurifier_AttrDef_CSS_Number extends HTMLPurifier_AttrDef { - + /** * Bool indicating whether or not only positive values allowed. */ protected $non_negative = false; - + /** * @param $non_negative Bool indicating whether negatives are forbidden */ public function __construct($non_negative = false) { $this->non_negative = $non_negative; } - + /** * @warning Some contexts do not pass $config, $context. These * variables should not be used without checking HTMLPurifier_Length */ public function validate($number, $config, $context) { - + $number = $this->parseCDATA($number); - + if ($number === '') return false; if ($number === '0') return '0'; - + $sign = ''; switch ($number[0]) { case '-': @@ -37,32 +37,32 @@ class HTMLPurifier_AttrDef_CSS_Number extends HTMLPurifier_AttrDef case '+': $number = substr($number, 1); } - + if (ctype_digit($number)) { $number = ltrim($number, '0'); return $number ? $sign . $number : '0'; } - + // Period is the only non-numeric character allowed if (strpos($number, '.') === false) return false; - + list($left, $right) = explode('.', $number, 2); - + if ($left === '' && $right === '') return false; if ($left !== '' && !ctype_digit($left)) return false; - + $left = ltrim($left, '0'); $right = rtrim($right, '0'); - + if ($right === '') { return $left ? $sign . $left : '0'; } elseif (!ctype_digit($right)) { return false; } - + return $sign . $left . '.' . $right; - + } - + } diff --git a/library/HTMLPurifier/AttrDef/CSS/Percentage.php b/library/HTMLPurifier/AttrDef/CSS/Percentage.php index 8b0fcd51..025bf0f8 100644 --- a/library/HTMLPurifier/AttrDef/CSS/Percentage.php +++ b/library/HTMLPurifier/AttrDef/CSS/Percentage.php @@ -5,35 +5,35 @@ */ class HTMLPurifier_AttrDef_CSS_Percentage extends HTMLPurifier_AttrDef { - + /** * Instance of HTMLPurifier_AttrDef_CSS_Number to defer number validation */ protected $number_def; - + /** * @param Bool indicating whether to forbid negative values */ public function __construct($non_negative = false) { $this->number_def = new HTMLPurifier_AttrDef_CSS_Number($non_negative); } - + public function validate($string, $config, $context) { - + $string = $this->parseCDATA($string); - + if ($string === '') return false; $length = strlen($string); if ($length === 1) return false; if ($string[$length - 1] !== '%') return false; - + $number = substr($string, 0, $length - 1); $number = $this->number_def->validate($number, $config, $context); - + if ($number === false) return false; return "$number%"; - + } - + } diff --git a/library/HTMLPurifier/AttrDef/CSS/TextDecoration.php b/library/HTMLPurifier/AttrDef/CSS/TextDecoration.php index af16d591..7cd31f5e 100644 --- a/library/HTMLPurifier/AttrDef/CSS/TextDecoration.php +++ b/library/HTMLPurifier/AttrDef/CSS/TextDecoration.php @@ -7,19 +7,19 @@ */ class HTMLPurifier_AttrDef_CSS_TextDecoration extends HTMLPurifier_AttrDef { - + public function validate($string, $config, $context) { - + static $allowed_values = array( 'line-through' => true, 'overline' => true, 'underline' => true, ); - + $string = strtolower($this->parseCDATA($string)); - + if ($string === 'none') return $string; - + $parts = explode(' ', $string); $final = ''; foreach ($parts as $part) { @@ -30,8 +30,8 @@ class HTMLPurifier_AttrDef_CSS_TextDecoration extends HTMLPurifier_AttrDef $final = rtrim($final); if ($final === '') return false; return $final; - + } - + } diff --git a/library/HTMLPurifier/AttrDef/CSS/URI.php b/library/HTMLPurifier/AttrDef/CSS/URI.php index c7dae503..edf5e6fb 100644 --- a/library/HTMLPurifier/AttrDef/CSS/URI.php +++ b/library/HTMLPurifier/AttrDef/CSS/URI.php @@ -11,45 +11,45 @@ */ class HTMLPurifier_AttrDef_CSS_URI extends HTMLPurifier_AttrDef_URI { - + public function __construct() { parent::__construct(true); // always embedded } - + public function validate($uri_string, $config, $context) { // parse the URI out of the string and then pass it onto // the parent object - + $uri_string = $this->parseCDATA($uri_string); if (strpos($uri_string, 'url(') !== 0) return false; $uri_string = substr($uri_string, 4); $new_length = strlen($uri_string) - 1; if ($uri_string[$new_length] != ')') return false; $uri = trim(substr($uri_string, 0, $new_length)); - + if (!empty($uri) && ($uri[0] == "'" || $uri[0] == '"')) { $quote = $uri[0]; $new_length = strlen($uri) - 1; if ($uri[$new_length] !== $quote) return false; $uri = substr($uri, 1, $new_length - 1); } - + $keys = array( '(', ')', ',', ' ', '"', "'"); $values = array('\\(', '\\)', '\\,', '\\ ', '\\"', "\\'"); $uri = str_replace($values, $keys, $uri); - + $result = parent::validate($uri, $config, $context); - + if ($result === false) return false; - + // escape necessary characters according to CSS spec // except for the comma, none of these should appear in the // URI at all $result = str_replace($keys, $values, $result); - + return "url($result)"; - + } - + } diff --git a/library/HTMLPurifier/AttrDef/Enum.php b/library/HTMLPurifier/AttrDef/Enum.php index 11d952e6..ae774541 100644 --- a/library/HTMLPurifier/AttrDef/Enum.php +++ b/library/HTMLPurifier/AttrDef/Enum.php @@ -9,19 +9,19 @@ */ class HTMLPurifier_AttrDef_Enum extends HTMLPurifier_AttrDef { - + /** * Lookup table of valid values. * @todo Make protected */ public $valid_values = array(); - + /** * Bool indicating whether or not enumeration is case sensitive. * @note In general this is always case insensitive. */ protected $case_sensitive = false; // values according to W3C spec - + /** * @param $valid_values List of valid values * @param $case_sensitive Bool indicating whether or not case sensitive @@ -32,7 +32,7 @@ class HTMLPurifier_AttrDef_Enum extends HTMLPurifier_AttrDef $this->valid_values = array_flip($valid_values); $this->case_sensitive = $case_sensitive; } - + public function validate($string, $config, $context) { $string = trim($string); if (!$this->case_sensitive) { @@ -40,10 +40,10 @@ class HTMLPurifier_AttrDef_Enum extends HTMLPurifier_AttrDef $string = ctype_lower($string) ? $string : strtolower($string); } $result = isset($this->valid_values[$string]); - + return $result ? $string : false; } - + /** * @param $string In form of comma-delimited list of case-insensitive * valid values. Example: "foo,bar,baz". Prepend "s:" to make @@ -59,6 +59,6 @@ class HTMLPurifier_AttrDef_Enum extends HTMLPurifier_AttrDef $values = explode(',', $string); return new HTMLPurifier_AttrDef_Enum($values, $sensitive); } - + } diff --git a/library/HTMLPurifier/AttrDef/HTML/Bool.php b/library/HTMLPurifier/AttrDef/HTML/Bool.php index c8870279..c54d21b8 100644 --- a/library/HTMLPurifier/AttrDef/HTML/Bool.php +++ b/library/HTMLPurifier/AttrDef/HTML/Bool.php @@ -5,23 +5,23 @@ */ class HTMLPurifier_AttrDef_HTML_Bool extends HTMLPurifier_AttrDef { - + protected $name; public $minimized = true; - + public function __construct($name = false) {$this->name = $name;} - + public function validate($string, $config, $context) { if (empty($string)) return false; return $this->name; } - + /** * @param $string Name of attribute */ public function make($string) { return new HTMLPurifier_AttrDef_HTML_Bool($string); } - + } diff --git a/library/HTMLPurifier/AttrDef/HTML/Color.php b/library/HTMLPurifier/AttrDef/HTML/Color.php index 3aa193e9..a5138fe8 100644 --- a/library/HTMLPurifier/AttrDef/HTML/Color.php +++ b/library/HTMLPurifier/AttrDef/HTML/Color.php @@ -5,27 +5,27 @@ */ class HTMLPurifier_AttrDef_HTML_Color extends HTMLPurifier_AttrDef { - + public function validate($string, $config, $context) { - + static $colors = null; if ($colors === null) $colors = $config->get('Core', 'ColorKeywords'); - + $string = trim($string); - + if (empty($string)) return false; if (isset($colors[$string])) return $colors[$string]; if ($string[0] === '#') $hex = substr($string, 1); else $hex = $string; - + $length = strlen($hex); if ($length !== 3 && $length !== 6) return false; if (!ctype_xdigit($hex)) return false; if ($length === 3) $hex = $hex[0].$hex[0].$hex[1].$hex[1].$hex[2].$hex[2]; - + return "#$hex"; - + } - + } diff --git a/library/HTMLPurifier/AttrDef/HTML/FrameTarget.php b/library/HTMLPurifier/AttrDef/HTML/FrameTarget.php index 0bc80432..ae64206a 100644 --- a/library/HTMLPurifier/AttrDef/HTML/FrameTarget.php +++ b/library/HTMLPurifier/AttrDef/HTML/FrameTarget.php @@ -5,16 +5,16 @@ */ class HTMLPurifier_AttrDef_HTML_FrameTarget extends HTMLPurifier_AttrDef_Enum { - + public $valid_values = false; // uninitialized value protected $case_sensitive = false; - + public function __construct() {} - + public function validate($string, $config, $context) { if ($this->valid_values === false) $this->valid_values = $config->get('Attr', 'AllowedFrameTargets'); return parent::validate($string, $config, $context); } - + } diff --git a/library/HTMLPurifier/AttrDef/HTML/ID.php b/library/HTMLPurifier/AttrDef/HTML/ID.php index 9c6aa37e..2a9dd118 100644 --- a/library/HTMLPurifier/AttrDef/HTML/ID.php +++ b/library/HTMLPurifier/AttrDef/HTML/ID.php @@ -11,18 +11,18 @@ class HTMLPurifier_AttrDef_HTML_ID extends HTMLPurifier_AttrDef { - + // ref functionality disabled, since we also have to verify // whether or not the ID it refers to exists - + public function validate($id, $config, $context) { - + if (!$config->get('Attr', 'EnableID')) return false; - + $id = trim($id); // trim it first - + if ($id === '') return false; - + $prefix = $config->get('Attr', 'IDPrefix'); if ($prefix !== '') { $prefix .= $config->get('Attr', 'IDPrefixLocal'); @@ -32,14 +32,14 @@ class HTMLPurifier_AttrDef_HTML_ID extends HTMLPurifier_AttrDef trigger_error('%Attr.IDPrefixLocal cannot be used unless '. '%Attr.IDPrefix is set', E_USER_WARNING); } - + //if (!$this->ref) { $id_accumulator =& $context->get('IDAccumulator'); if (isset($id_accumulator->ids[$id])) return false; //} - + // we purposely avoid using regex, hopefully this is faster - + if (ctype_alpha($id)) { $result = true; } else { @@ -50,20 +50,20 @@ class HTMLPurifier_AttrDef_HTML_ID extends HTMLPurifier_AttrDef ); $result = ($trim === ''); } - + $regexp = $config->get('Attr', 'IDBlacklistRegexp'); if ($regexp && preg_match($regexp, $id)) { return false; } - + if (/*!$this->ref && */$result) $id_accumulator->add($id); - + // if no change was made to the ID, return the result // else, return the new id if stripping whitespace made it // valid, or return false. return $result ? $id : false; - + } - + } diff --git a/library/HTMLPurifier/AttrDef/HTML/Length.php b/library/HTMLPurifier/AttrDef/HTML/Length.php index 3f995047..27fb4e79 100644 --- a/library/HTMLPurifier/AttrDef/HTML/Length.php +++ b/library/HTMLPurifier/AttrDef/HTML/Length.php @@ -2,39 +2,39 @@ /** * Validates the HTML type length (not to be confused with CSS's length). - * + * * This accepts integer pixels or percentages as lengths for certain * HTML attributes. */ class HTMLPurifier_AttrDef_HTML_Length extends HTMLPurifier_AttrDef_HTML_Pixels { - + public function validate($string, $config, $context) { - + $string = trim($string); if ($string === '') return false; - + $parent_result = parent::validate($string, $config, $context); if ($parent_result !== false) return $parent_result; - + $length = strlen($string); $last_char = $string[$length - 1]; - + if ($last_char !== '%') return false; - + $points = substr($string, 0, $length - 1); - + if (!is_numeric($points)) return false; - + $points = (int) $points; - + if ($points < 0) return '0%'; if ($points > 100) return '100%'; - + return ((string) $points) . '%'; - + } - + } diff --git a/library/HTMLPurifier/AttrDef/HTML/LinkTypes.php b/library/HTMLPurifier/AttrDef/HTML/LinkTypes.php index dca75df3..968bf83e 100644 --- a/library/HTMLPurifier/AttrDef/HTML/LinkTypes.php +++ b/library/HTMLPurifier/AttrDef/HTML/LinkTypes.php @@ -8,10 +8,10 @@ */ class HTMLPurifier_AttrDef_HTML_LinkTypes extends HTMLPurifier_AttrDef { - + /** Name config attribute to pull. */ protected $name; - + public function __construct($name) { $configLookup = array( 'rel' => 'AllowedRel', @@ -24,15 +24,15 @@ class HTMLPurifier_AttrDef_HTML_LinkTypes extends HTMLPurifier_AttrDef } $this->name = $configLookup[$name]; } - + public function validate($string, $config, $context) { - + $allowed = $config->get('Attr', $this->name); if (empty($allowed)) return false; - + $string = $this->parseCDATA($string); $parts = explode(' ', $string); - + // lookup to prevent duplicates $ret_lookup = array(); foreach ($parts as $part) { @@ -40,13 +40,13 @@ class HTMLPurifier_AttrDef_HTML_LinkTypes extends HTMLPurifier_AttrDef if (!isset($allowed[$part])) continue; $ret_lookup[$part] = true; } - + if (empty($ret_lookup)) return false; $string = implode(' ', array_keys($ret_lookup)); - + return $string; - + } - + } diff --git a/library/HTMLPurifier/AttrDef/HTML/MultiLength.php b/library/HTMLPurifier/AttrDef/HTML/MultiLength.php index b7b9e057..dbd818ce 100644 --- a/library/HTMLPurifier/AttrDef/HTML/MultiLength.php +++ b/library/HTMLPurifier/AttrDef/HTML/MultiLength.php @@ -2,39 +2,39 @@ /** * Validates a MultiLength as defined by the HTML spec. - * + * * A multilength is either a integer (pixel count), a percentage, or * a relative number. */ class HTMLPurifier_AttrDef_HTML_MultiLength extends HTMLPurifier_AttrDef_HTML_Length { - + public function validate($string, $config, $context) { - + $string = trim($string); if ($string === '') return false; - + $parent_result = parent::validate($string, $config, $context); if ($parent_result !== false) return $parent_result; - + $length = strlen($string); $last_char = $string[$length - 1]; - + if ($last_char !== '*') return false; - + $int = substr($string, 0, $length - 1); - + if ($int == '') return '*'; if (!is_numeric($int)) return false; - + $int = (int) $int; - + if ($int < 0) return false; if ($int == 0) return '0'; if ($int == 1) return '*'; return ((string) $int) . '*'; - + } - + } diff --git a/library/HTMLPurifier/AttrDef/HTML/Nmtokens.php b/library/HTMLPurifier/AttrDef/HTML/Nmtokens.php index 6ff057c2..53789d53 100644 --- a/library/HTMLPurifier/AttrDef/HTML/Nmtokens.php +++ b/library/HTMLPurifier/AttrDef/HTML/Nmtokens.php @@ -9,17 +9,17 @@ */ class HTMLPurifier_AttrDef_HTML_Nmtokens extends HTMLPurifier_AttrDef { - + public function validate($string, $config, $context) { - + $string = trim($string); - + // early abort: '' and '0' (strings that convert to false) are invalid if (!$string) return false; - + // OPTIMIZABLE! // do the preg_match, capture all subpatterns for reformulation - + // we don't support U+00A1 and up codepoints or // escaping because I don't know how to do that with regexps // and plus it would complicate optimization efforts (you never @@ -29,19 +29,19 @@ class HTMLPurifier_AttrDef_HTML_Nmtokens extends HTMLPurifier_AttrDef '((?:--|-?[A-Za-z_])[A-Za-z_\-0-9]*)'. '(?:(?=\s)|\z)/'; // look ahead for space or string end preg_match_all($pattern, $string, $matches); - + if (empty($matches[1])) return false; - + // reconstruct string $new_string = ''; foreach ($matches[1] as $token) { $new_string .= $token . ' '; } $new_string = rtrim($new_string); - + return $new_string; - + } - + } diff --git a/library/HTMLPurifier/AttrDef/HTML/Pixels.php b/library/HTMLPurifier/AttrDef/HTML/Pixels.php index 6b615fe9..2890ffb5 100644 --- a/library/HTMLPurifier/AttrDef/HTML/Pixels.php +++ b/library/HTMLPurifier/AttrDef/HTML/Pixels.php @@ -5,15 +5,15 @@ */ class HTMLPurifier_AttrDef_HTML_Pixels extends HTMLPurifier_AttrDef { - + protected $max; - + public function __construct($max = null) { $this->max = $max; } - + public function validate($string, $config, $context) { - + $string = trim($string); if ($string === '0') return $string; if ($string === '') return false; @@ -23,25 +23,25 @@ class HTMLPurifier_AttrDef_HTML_Pixels extends HTMLPurifier_AttrDef } if (!is_numeric($string)) return false; $int = (int) $string; - + if ($int < 0) return '0'; - + // upper-bound value, extremely high values can // crash operating systems, see // WARNING, above link WILL crash you if you're using Windows - + if ($this->max !== null && $int > $this->max) return (string) $this->max; - + return (string) $int; - + } - + public function make($string) { if ($string === '') $max = null; else $max = (int) $string; $class = get_class($this); return new $class($max); } - + } diff --git a/library/HTMLPurifier/AttrDef/Integer.php b/library/HTMLPurifier/AttrDef/Integer.php index 5f701f0d..3ccce1b5 100644 --- a/library/HTMLPurifier/AttrDef/Integer.php +++ b/library/HTMLPurifier/AttrDef/Integer.php @@ -9,22 +9,22 @@ */ class HTMLPurifier_AttrDef_Integer extends HTMLPurifier_AttrDef { - + /** * Bool indicating whether or not negative values are allowed */ protected $negative = true; - + /** * Bool indicating whether or not zero is allowed */ protected $zero = true; - + /** * Bool indicating whether or not positive values are allowed */ protected $positive = true; - + /** * @param $negative Bool indicating whether or not negative values are allowed * @param $zero Bool indicating whether or not zero is allowed @@ -37,15 +37,15 @@ class HTMLPurifier_AttrDef_Integer extends HTMLPurifier_AttrDef $this->zero = $zero; $this->positive = $positive; } - + public function validate($integer, $config, $context) { - + $integer = $this->parseCDATA($integer); if ($integer === '') return false; - + // we could possibly simply typecast it to integer, but there are // certain fringe cases that must not return an integer. - + // clip leading sign if ( $this->negative && $integer[0] === '-' ) { $digits = substr($integer, 1); @@ -55,18 +55,18 @@ class HTMLPurifier_AttrDef_Integer extends HTMLPurifier_AttrDef } else { $digits = $integer; } - + // test if it's numeric if (!ctype_digit($digits)) return false; - + // perform scope tests if (!$this->zero && $integer == 0) return false; if (!$this->positive && $integer > 0) return false; if (!$this->negative && $integer < 0) return false; - + return $integer; - + } - + } diff --git a/library/HTMLPurifier/AttrDef/Lang.php b/library/HTMLPurifier/AttrDef/Lang.php index 5593331a..73cab4ff 100644 --- a/library/HTMLPurifier/AttrDef/Lang.php +++ b/library/HTMLPurifier/AttrDef/Lang.php @@ -6,17 +6,17 @@ */ class HTMLPurifier_AttrDef_Lang extends HTMLPurifier_AttrDef { - + public function validate($string, $config, $context) { - + $string = trim($string); if (!$string) return false; - + $subtags = explode('-', $string); $num_subtags = count($subtags); - + if ($num_subtags == 0) return false; // sanity check - + // process primary subtag : $subtags[0] $length = strlen($subtags[0]); switch ($length) { @@ -38,20 +38,20 @@ class HTMLPurifier_AttrDef_Lang extends HTMLPurifier_AttrDef default: return false; } - + $new_string = $subtags[0]; if ($num_subtags == 1) return $new_string; - + // process second subtag : $subtags[1] $length = strlen($subtags[1]); if ($length == 0 || ($length == 1 && $subtags[1] != 'x') || $length > 8 || !ctype_alnum($subtags[1])) { return $new_string; } if (!ctype_lower($subtags[1])) $subtags[1] = strtolower($subtags[1]); - + $new_string .= '-' . $subtags[1]; if ($num_subtags == 2) return $new_string; - + // process all other subtags, index 2 and up for ($i = 2; $i < $num_subtags; $i++) { $length = strlen($subtags[$i]); @@ -63,10 +63,10 @@ class HTMLPurifier_AttrDef_Lang extends HTMLPurifier_AttrDef } $new_string .= '-' . $subtags[$i]; } - + return $new_string; - + } - + } diff --git a/library/HTMLPurifier/AttrDef/Switch.php b/library/HTMLPurifier/AttrDef/Switch.php index 31398e25..99f5f172 100644 --- a/library/HTMLPurifier/AttrDef/Switch.php +++ b/library/HTMLPurifier/AttrDef/Switch.php @@ -5,10 +5,10 @@ */ class HTMLPurifier_AttrDef_Switch { - + protected $tag; protected $withTag, $withoutTag; - + /** * @param string $tag Tag name to switch upon * @param HTMLPurifier_AttrDef $with_tag Call if token matches tag @@ -19,7 +19,7 @@ class HTMLPurifier_AttrDef_Switch $this->withTag = $with_tag; $this->withoutTag = $without_tag; } - + public function validate($string, $config, $context) { $token = $context->get('CurrentToken', true); if (!$token || $token->name !== $this->tag) { @@ -28,5 +28,5 @@ class HTMLPurifier_AttrDef_Switch return $this->withTag->validate($string, $config, $context); } } - + } diff --git a/library/HTMLPurifier/AttrDef/Text.php b/library/HTMLPurifier/AttrDef/Text.php index e88a8456..a3c31016 100644 --- a/library/HTMLPurifier/AttrDef/Text.php +++ b/library/HTMLPurifier/AttrDef/Text.php @@ -5,10 +5,10 @@ */ class HTMLPurifier_AttrDef_Text extends HTMLPurifier_AttrDef { - + public function validate($string, $config, $context) { return $this->parseCDATA($string); } - + } diff --git a/library/HTMLPurifier/AttrDef/URI.php b/library/HTMLPurifier/AttrDef/URI.php index b814e9ee..63758cf2 100644 --- a/library/HTMLPurifier/AttrDef/URI.php +++ b/library/HTMLPurifier/AttrDef/URI.php @@ -6,10 +6,10 @@ */ class HTMLPurifier_AttrDef_URI extends HTMLPurifier_AttrDef { - + protected $parser; protected $embedsResource; - + /** * @param $embeds_resource_resource Does the URI here result in an extra HTTP request? */ @@ -17,61 +17,61 @@ class HTMLPurifier_AttrDef_URI extends HTMLPurifier_AttrDef $this->parser = new HTMLPurifier_URIParser(); $this->embedsResource = (bool) $embeds_resource; } - + public function make($string) { $embeds = (bool) $string; return new HTMLPurifier_AttrDef_URI($embeds); } - + public function validate($uri, $config, $context) { - + if ($config->get('URI', 'Disable')) return false; - + $uri = $this->parseCDATA($uri); - + // parse the URI $uri = $this->parser->parse($uri); if ($uri === false) return false; - + // add embedded flag to context for validators - $context->register('EmbeddedURI', $this->embedsResource); - + $context->register('EmbeddedURI', $this->embedsResource); + $ok = false; do { - + // generic validation $result = $uri->validate($config, $context); if (!$result) break; - + // chained filtering $uri_def = $config->getDefinition('URI'); $result = $uri_def->filter($uri, $config, $context); if (!$result) break; - - // scheme-specific validation + + // scheme-specific validation $scheme_obj = $uri->getSchemeObj($config, $context); if (!$scheme_obj) break; if ($this->embedsResource && !$scheme_obj->browsable) break; $result = $scheme_obj->validate($uri, $config, $context); if (!$result) break; - + // Post chained filtering $result = $uri_def->postFilter($uri, $config, $context); if (!$result) break; - + // survived gauntlet $ok = true; - + } while (false); - + $context->destroy('EmbeddedURI'); if (!$ok) return false; - + // back to string return $uri->toString(); - + } - + } diff --git a/library/HTMLPurifier/AttrDef/URI/Email.php b/library/HTMLPurifier/AttrDef/URI/Email.php index 98d984c3..9c57ad7c 100644 --- a/library/HTMLPurifier/AttrDef/URI/Email.php +++ b/library/HTMLPurifier/AttrDef/URI/Email.php @@ -2,14 +2,14 @@ abstract class HTMLPurifier_AttrDef_URI_Email extends HTMLPurifier_AttrDef { - + /** * Unpacks a mailbox into its display-name and address */ function unpack($string) { // needs to be implemented } - + } // sub-implementations diff --git a/library/HTMLPurifier/AttrDef/URI/Email/SimpleCheck.php b/library/HTMLPurifier/AttrDef/URI/Email/SimpleCheck.php index 98551c46..33e3b98d 100644 --- a/library/HTMLPurifier/AttrDef/URI/Email/SimpleCheck.php +++ b/library/HTMLPurifier/AttrDef/URI/Email/SimpleCheck.php @@ -1,12 +1,12 @@ " // that needs more percent encoding to be done @@ -15,6 +15,6 @@ class HTMLPurifier_AttrDef_URI_Email_SimpleCheck extends HTMLPurifier_AttrDef_UR $result = preg_match('/^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i', $string); return $result ? $string : false; } - + } diff --git a/library/HTMLPurifier/AttrDef/URI/Host.php b/library/HTMLPurifier/AttrDef/URI/Host.php index 8d1a7b2c..a754c704 100644 --- a/library/HTMLPurifier/AttrDef/URI/Host.php +++ b/library/HTMLPurifier/AttrDef/URI/Host.php @@ -5,22 +5,22 @@ */ class HTMLPurifier_AttrDef_URI_Host extends HTMLPurifier_AttrDef { - + /** * Instance of HTMLPurifier_AttrDef_URI_IPv4 sub-validator */ protected $ipv4; - + /** * Instance of HTMLPurifier_AttrDef_URI_IPv6 sub-validator */ protected $ipv6; - + public function __construct() { $this->ipv4 = new HTMLPurifier_AttrDef_URI_IPv4(); $this->ipv6 = new HTMLPurifier_AttrDef_URI_IPv6(); } - + public function validate($string, $config, $context) { $length = strlen($string); if ($string === '') return ''; @@ -31,17 +31,17 @@ class HTMLPurifier_AttrDef_URI_Host extends HTMLPurifier_AttrDef if ($valid === false) return false; return '['. $valid . ']'; } - + // need to do checks on unusual encodings too $ipv4 = $this->ipv4->validate($string, $config, $context); if ($ipv4 !== false) return $ipv4; - + // A regular domain name. - + // This breaks I18N domain names, but we don't have proper IRI support, - // so force users to insert Punycode. If there's complaining we'll + // so force users to insert Punycode. If there's complaining we'll // try to fix things into an international friendly form. - + // The productions describing this are: $a = '[a-z]'; // alpha $an = '[a-z0-9]'; // alphanum @@ -53,9 +53,9 @@ class HTMLPurifier_AttrDef_URI_Host extends HTMLPurifier_AttrDef // hostname = *( domainlabel "." ) toplabel [ "." ] $match = preg_match("/^($domainlabel\.)*$toplabel\.?$/i", $string); if (!$match) return false; - + return $string; } - + } diff --git a/library/HTMLPurifier/AttrDef/URI/IPv4.php b/library/HTMLPurifier/AttrDef/URI/IPv4.php index 107e0605..b3037174 100644 --- a/library/HTMLPurifier/AttrDef/URI/IPv4.php +++ b/library/HTMLPurifier/AttrDef/URI/IPv4.php @@ -6,25 +6,25 @@ */ class HTMLPurifier_AttrDef_URI_IPv4 extends HTMLPurifier_AttrDef { - + /** * IPv4 regex, protected so that IPv6 can reuse it */ protected $ip4; - + public function validate($aIP, $config, $context) { - + if (!$this->ip4) $this->_loadRegex(); - + if (preg_match('#^' . $this->ip4 . '$#s', $aIP)) { return $aIP; } - + return false; - + } - + /** * Lazy load function to prevent regex from being stuffed in * cache. @@ -33,6 +33,6 @@ class HTMLPurifier_AttrDef_URI_IPv4 extends HTMLPurifier_AttrDef $oct = '(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])'; // 0-255 $this->ip4 = "(?:{$oct}\\.{$oct}\\.{$oct}\\.{$oct})"; } - + } diff --git a/library/HTMLPurifier/AttrDef/URI/IPv6.php b/library/HTMLPurifier/AttrDef/URI/IPv6.php index 28fb8f5b..cf6068d8 100644 --- a/library/HTMLPurifier/AttrDef/URI/IPv6.php +++ b/library/HTMLPurifier/AttrDef/URI/IPv6.php @@ -8,17 +8,17 @@ */ class HTMLPurifier_AttrDef_URI_IPv6 extends HTMLPurifier_AttrDef_URI_IPv4 { - + public function validate($aIP, $config, $context) { - + if (!$this->ip4) $this->_loadRegex(); - + $original = $aIP; - + $hex = '[0-9a-fA-F]'; $blk = '(?:' . $hex . '{1,4})'; $pre = '(?:/(?:12[0-8]|1[0-1][0-9]|[1-9][0-9]|[0-9]))'; // /0 - /128 - + // prefix check if (strpos($aIP, '/') !== false) { @@ -32,8 +32,8 @@ class HTMLPurifier_AttrDef_URI_IPv6 extends HTMLPurifier_AttrDef_URI_IPv4 return false; } } - - // IPv4-compatiblity check + + // IPv4-compatiblity check if (preg_match('#(?<=:'.')' . $this->ip4 . '$#s', $aIP, $find)) { $aIP = substr($aIP, 0, 0-strlen($find[0])); @@ -42,7 +42,7 @@ class HTMLPurifier_AttrDef_URI_IPv6 extends HTMLPurifier_AttrDef_URI_IPv4 $aIP .= $ip[0] . $ip[1] . ':' . $ip[2] . $ip[3]; unset($find, $ip); } - + // compression check $aIP = explode('::', $aIP); $c = count($aIP); @@ -55,12 +55,12 @@ class HTMLPurifier_AttrDef_URI_IPv6 extends HTMLPurifier_AttrDef_URI_IPv4 list($first, $second) = $aIP; $first = explode(':', $first); $second = explode(':', $second); - + if (count($first) + count($second) > 8) { return false; } - + while(count($first) < 8) { array_push($first, '0'); @@ -75,12 +75,12 @@ class HTMLPurifier_AttrDef_URI_IPv6 extends HTMLPurifier_AttrDef_URI_IPv4 $aIP = explode(':', $aIP[0]); } $c = count($aIP); - + if ($c != 8) { return false; } - + // All the pieces should be 16-bit hex strings. Are they? foreach ($aIP as $piece) { @@ -89,10 +89,10 @@ class HTMLPurifier_AttrDef_URI_IPv6 extends HTMLPurifier_AttrDef_URI_IPv4 return false; } } - + return $original; - + } - + } diff --git a/library/HTMLPurifier/AttrTransform.php b/library/HTMLPurifier/AttrTransform.php index a295c985..41594dce 100644 --- a/library/HTMLPurifier/AttrTransform.php +++ b/library/HTMLPurifier/AttrTransform.php @@ -2,13 +2,13 @@ /** * Processes an entire attribute array for corrections needing multiple values. - * + * * Occasionally, a certain attribute will need to be removed and popped onto * another value. Instead of creating a complex return syntax for * HTMLPurifier_AttrDef, we just pass the whole attribute array to a * specialized object and have that do the special work. That is the * family of HTMLPurifier_AttrTransform. - * + * * An attribute transformation can be assigned to run before or after * HTMLPurifier_AttrDef validation. See HTMLPurifier_HTMLDefinition for * more details. @@ -16,10 +16,10 @@ abstract class HTMLPurifier_AttrTransform { - + /** * Abstract: makes changes to the attributes dependent on multiple values. - * + * * @param $attr Assoc array of attributes, usually from * HTMLPurifier_Token_Tag::$attr * @param $config Mandatory HTMLPurifier_Config object. @@ -27,7 +27,7 @@ abstract class HTMLPurifier_AttrTransform * @returns Processed attribute array. */ abstract public function transform($attr, $config, $context); - + /** * Prepends CSS properties to the style attribute, creating the * attribute if it doesn't exist. @@ -38,7 +38,7 @@ abstract class HTMLPurifier_AttrTransform $attr['style'] = isset($attr['style']) ? $attr['style'] : ''; $attr['style'] = $css . $attr['style']; } - + /** * Retrieves and removes an attribute * @param $attr Attribute array to process (passed by reference) @@ -50,6 +50,6 @@ abstract class HTMLPurifier_AttrTransform unset($attr[$key]); return $value; } - + } diff --git a/library/HTMLPurifier/AttrTransform/Background.php b/library/HTMLPurifier/AttrTransform/Background.php index f7f0feda..6dc301f9 100644 --- a/library/HTMLPurifier/AttrTransform/Background.php +++ b/library/HTMLPurifier/AttrTransform/Background.php @@ -6,17 +6,17 @@ class HTMLPurifier_AttrTransform_Background extends HTMLPurifier_AttrTransform { public function transform($attr, $config, $context) { - + if (!isset($attr['background'])) return $attr; - + $background = $this->confiscateAttr($attr, 'background'); // some validation should happen here - + $this->prependCSS($attr, "background-image:url($background);"); - + return $attr; - + } - + } diff --git a/library/HTMLPurifier/AttrTransform/BdoDir.php b/library/HTMLPurifier/AttrTransform/BdoDir.php index bf108bbb..289daaaf 100644 --- a/library/HTMLPurifier/AttrTransform/BdoDir.php +++ b/library/HTMLPurifier/AttrTransform/BdoDir.php @@ -7,12 +7,12 @@ */ class HTMLPurifier_AttrTransform_BdoDir extends HTMLPurifier_AttrTransform { - + public function transform($attr, $config, $context) { if (isset($attr['dir'])) return $attr; $attr['dir'] = $config->get('Attr', 'DefaultTextDir'); return $attr; } - + } diff --git a/library/HTMLPurifier/AttrTransform/BgColor.php b/library/HTMLPurifier/AttrTransform/BgColor.php index 5bc21367..e3d8d1df 100644 --- a/library/HTMLPurifier/AttrTransform/BgColor.php +++ b/library/HTMLPurifier/AttrTransform/BgColor.php @@ -6,17 +6,17 @@ class HTMLPurifier_AttrTransform_BgColor extends HTMLPurifier_AttrTransform { public function transform($attr, $config, $context) { - + if (!isset($attr['bgcolor'])) return $attr; - + $bgcolor = $this->confiscateAttr($attr, 'bgcolor'); // some validation should happen here - + $this->prependCSS($attr, "background-color:$bgcolor;"); - + return $attr; - + } - + } diff --git a/library/HTMLPurifier/AttrTransform/BoolToCSS.php b/library/HTMLPurifier/AttrTransform/BoolToCSS.php index ec523a11..a5efa5b4 100644 --- a/library/HTMLPurifier/AttrTransform/BoolToCSS.php +++ b/library/HTMLPurifier/AttrTransform/BoolToCSS.php @@ -4,17 +4,17 @@ * Pre-transform that changes converts a boolean attribute to fixed CSS */ class HTMLPurifier_AttrTransform_BoolToCSS extends HTMLPurifier_AttrTransform { - + /** * Name of boolean attribute that is trigger */ protected $attr; - + /** * CSS declarations to add to style, needs trailing semicolon */ protected $css; - + /** * @param $attr string attribute name to convert from * @param $css string CSS declarations to add to style (needs semicolon) @@ -23,13 +23,13 @@ class HTMLPurifier_AttrTransform_BoolToCSS extends HTMLPurifier_AttrTransform { $this->attr = $attr; $this->css = $css; } - + public function transform($attr, $config, $context) { if (!isset($attr[$this->attr])) return $attr; unset($attr[$this->attr]); $this->prependCSS($attr, $this->css); return $attr; } - + } diff --git a/library/HTMLPurifier/AttrTransform/Border.php b/library/HTMLPurifier/AttrTransform/Border.php index b72c019e..a651c4d2 100644 --- a/library/HTMLPurifier/AttrTransform/Border.php +++ b/library/HTMLPurifier/AttrTransform/Border.php @@ -12,6 +12,6 @@ class HTMLPurifier_AttrTransform_Border extends HTMLPurifier_AttrTransform { $this->prependCSS($attr, "border:{$border_width}px solid;"); return $attr; } - + } diff --git a/library/HTMLPurifier/AttrTransform/EnumToCSS.php b/library/HTMLPurifier/AttrTransform/EnumToCSS.php index 5d36b6de..0b38a8c6 100644 --- a/library/HTMLPurifier/AttrTransform/EnumToCSS.php +++ b/library/HTMLPurifier/AttrTransform/EnumToCSS.php @@ -5,24 +5,24 @@ * values (enumerated) to CSS. */ class HTMLPurifier_AttrTransform_EnumToCSS extends HTMLPurifier_AttrTransform { - + /** * Name of attribute to transform from */ protected $attr; - + /** * Lookup array of attribute values to CSS */ protected $enumToCSS = array(); - + /** * Case sensitivity of the matching * @warning Currently can only be guaranteed to work with ASCII * values. */ protected $caseSensitive = false; - + /** * @param $attr String attribute name to transform from * @param $enumToCSS Lookup array of attribute values to CSS @@ -33,25 +33,25 @@ class HTMLPurifier_AttrTransform_EnumToCSS extends HTMLPurifier_AttrTransform { $this->enumToCSS = $enum_to_css; $this->caseSensitive = (bool) $case_sensitive; } - + public function transform($attr, $config, $context) { - + if (!isset($attr[$this->attr])) return $attr; - + $value = trim($attr[$this->attr]); unset($attr[$this->attr]); - + if (!$this->caseSensitive) $value = strtolower($value); - + if (!isset($this->enumToCSS[$value])) { return $attr; } - + $this->prependCSS($attr, $this->enumToCSS[$value]); - + return $attr; - + } - + } diff --git a/library/HTMLPurifier/AttrTransform/ImgRequired.php b/library/HTMLPurifier/AttrTransform/ImgRequired.php index e938f525..ef89ca97 100644 --- a/library/HTMLPurifier/AttrTransform/ImgRequired.php +++ b/library/HTMLPurifier/AttrTransform/ImgRequired.php @@ -10,16 +10,16 @@ */ class HTMLPurifier_AttrTransform_ImgRequired extends HTMLPurifier_AttrTransform { - + public function transform($attr, $config, $context) { - + $src = true; if (!isset($attr['src'])) { if ($config->get('Core', 'RemoveInvalidImg')) return $attr; $attr['src'] = $config->get('Attr', 'DefaultInvalidImage'); $src = false; } - + if (!isset($attr['alt'])) { if ($src) { $alt = $config->get('Attr', 'DefaultImageAlt'); @@ -32,10 +32,10 @@ class HTMLPurifier_AttrTransform_ImgRequired extends HTMLPurifier_AttrTransform $attr['alt'] = $config->get('Attr', 'DefaultInvalidImageAlt'); } } - + return $attr; - + } - + } diff --git a/library/HTMLPurifier/AttrTransform/ImgSpace.php b/library/HTMLPurifier/AttrTransform/ImgSpace.php index 02aaef59..b22a2687 100644 --- a/library/HTMLPurifier/AttrTransform/ImgSpace.php +++ b/library/HTMLPurifier/AttrTransform/ImgSpace.php @@ -4,40 +4,40 @@ * Pre-transform that changes deprecated hspace and vspace attributes to CSS */ class HTMLPurifier_AttrTransform_ImgSpace extends HTMLPurifier_AttrTransform { - + protected $attr; protected $css = array( 'hspace' => array('left', 'right'), 'vspace' => array('top', 'bottom') ); - + public function __construct($attr) { $this->attr = $attr; if (!isset($this->css[$attr])) { trigger_error(htmlspecialchars($attr) . ' is not valid space attribute'); } } - + public function transform($attr, $config, $context) { - + if (!isset($attr[$this->attr])) return $attr; - + $width = $this->confiscateAttr($attr, $this->attr); // some validation could happen here - + if (!isset($this->css[$this->attr])) return $attr; - + $style = ''; foreach ($this->css[$this->attr] as $suffix) { $property = "margin-$suffix"; $style .= "$property:{$width}px;"; } - + $this->prependCSS($attr, $style); - + return $attr; - + } - + } diff --git a/library/HTMLPurifier/AttrTransform/Input.php b/library/HTMLPurifier/AttrTransform/Input.php index f082c4de..c71171a0 100644 --- a/library/HTMLPurifier/AttrTransform/Input.php +++ b/library/HTMLPurifier/AttrTransform/Input.php @@ -5,13 +5,13 @@ * input elements. This is meant to be a post-transform. */ class HTMLPurifier_AttrTransform_Input extends HTMLPurifier_AttrTransform { - + protected $pixels; - + public function __construct() { $this->pixels = new HTMLPurifier_AttrDef_HTML_Pixels(); } - + public function transform($attr, $config, $context) { if (!isset($attr['type'])) $t = 'text'; else $t = strtolower($attr['type']); @@ -34,6 +34,6 @@ class HTMLPurifier_AttrTransform_Input extends HTMLPurifier_AttrTransform { } return $attr; } - + } diff --git a/library/HTMLPurifier/AttrTransform/Lang.php b/library/HTMLPurifier/AttrTransform/Lang.php index 960f489e..5acc2414 100644 --- a/library/HTMLPurifier/AttrTransform/Lang.php +++ b/library/HTMLPurifier/AttrTransform/Lang.php @@ -7,21 +7,21 @@ */ class HTMLPurifier_AttrTransform_Lang extends HTMLPurifier_AttrTransform { - + public function transform($attr, $config, $context) { - + $lang = isset($attr['lang']) ? $attr['lang'] : false; $xml_lang = isset($attr['xml:lang']) ? $attr['xml:lang'] : false; - + if ($lang !== false && $xml_lang === false) { $attr['xml:lang'] = $lang; } elseif ($xml_lang !== false) { $attr['lang'] = $xml_lang; } - + return $attr; - + } - + } diff --git a/library/HTMLPurifier/AttrTransform/Length.php b/library/HTMLPurifier/AttrTransform/Length.php index 81732802..bb5d914e 100644 --- a/library/HTMLPurifier/AttrTransform/Length.php +++ b/library/HTMLPurifier/AttrTransform/Length.php @@ -5,15 +5,15 @@ */ class HTMLPurifier_AttrTransform_Length extends HTMLPurifier_AttrTransform { - + protected $name; protected $cssName; - + public function __construct($name, $css_name = null) { $this->name = $name; $this->cssName = $css_name ? $css_name : $name; } - + public function transform($attr, $config, $context) { if (!isset($attr[$this->name])) return $attr; $length = $this->confiscateAttr($attr, $this->name); @@ -21,6 +21,6 @@ class HTMLPurifier_AttrTransform_Length extends HTMLPurifier_AttrTransform $this->prependCSS($attr, $this->cssName . ":$length;"); return $attr; } - + } diff --git a/library/HTMLPurifier/AttrTransform/Name.php b/library/HTMLPurifier/AttrTransform/Name.php index 8de8c6ba..aa9f96b8 100644 --- a/library/HTMLPurifier/AttrTransform/Name.php +++ b/library/HTMLPurifier/AttrTransform/Name.php @@ -5,7 +5,7 @@ */ class HTMLPurifier_AttrTransform_Name extends HTMLPurifier_AttrTransform { - + public function transform($attr, $config, $context) { if (!isset($attr['name'])) return $attr; $id = $this->confiscateAttr($attr, 'name'); @@ -13,6 +13,6 @@ class HTMLPurifier_AttrTransform_Name extends HTMLPurifier_AttrTransform $attr['id'] = $id; return $attr; } - + } diff --git a/library/HTMLPurifier/AttrTransform/SafeEmbed.php b/library/HTMLPurifier/AttrTransform/SafeEmbed.php index d3c1883b..f2e433df 100644 --- a/library/HTMLPurifier/AttrTransform/SafeEmbed.php +++ b/library/HTMLPurifier/AttrTransform/SafeEmbed.php @@ -1,6 +1,6 @@ uri = new HTMLPurifier_AttrDef_URI(true); // embedded } - + public function transform($attr, $config, $context) { // If we add support for other objects, we'll need to alter the // transforms. diff --git a/library/HTMLPurifier/AttrTransform/Textarea.php b/library/HTMLPurifier/AttrTransform/Textarea.php index c7cc9888..624d2ee8 100644 --- a/library/HTMLPurifier/AttrTransform/Textarea.php +++ b/library/HTMLPurifier/AttrTransform/Textarea.php @@ -5,12 +5,12 @@ */ class HTMLPurifier_AttrTransform_Textarea extends HTMLPurifier_AttrTransform { - + public function transform($attr, $config, $context) { // Calculated from Firefox if (!isset($attr['cols'])) $attr['cols'] = '22'; if (!isset($attr['rows'])) $attr['rows'] = '3'; return $attr; } - + } \ No newline at end of file diff --git a/library/HTMLPurifier/AttrTypes.php b/library/HTMLPurifier/AttrTypes.php index c3116a16..74bf062d 100644 --- a/library/HTMLPurifier/AttrTypes.php +++ b/library/HTMLPurifier/AttrTypes.php @@ -9,7 +9,7 @@ class HTMLPurifier_AttrTypes * Lookup array of attribute string identifiers to concrete implementations */ protected $info = array(); - + /** * Constructs the info array, supplying default implementations for attribute * types. @@ -18,7 +18,7 @@ class HTMLPurifier_AttrTypes // pseudo-types, must be instantiated via shorthand $this->info['Enum'] = new HTMLPurifier_AttrDef_Enum(); $this->info['Bool'] = new HTMLPurifier_AttrDef_HTML_Bool(); - + $this->info['CDATA'] = new HTMLPurifier_AttrDef_Text(); $this->info['ID'] = new HTMLPurifier_AttrDef_HTML_ID(); $this->info['Length'] = new HTMLPurifier_AttrDef_HTML_Length(); @@ -29,38 +29,38 @@ class HTMLPurifier_AttrTypes $this->info['URI'] = new HTMLPurifier_AttrDef_URI(); $this->info['LanguageCode'] = new HTMLPurifier_AttrDef_Lang(); $this->info['Color'] = new HTMLPurifier_AttrDef_HTML_Color(); - + // unimplemented aliases $this->info['ContentType'] = new HTMLPurifier_AttrDef_Text(); $this->info['ContentTypes'] = new HTMLPurifier_AttrDef_Text(); $this->info['Charsets'] = new HTMLPurifier_AttrDef_Text(); $this->info['Character'] = new HTMLPurifier_AttrDef_Text(); - + // number is really a positive integer (one or more digits) // FIXME: ^^ not always, see start and value of list items $this->info['Number'] = new HTMLPurifier_AttrDef_Integer(false, false, true); } - + /** * Retrieves a type * @param $type String type name * @return Object AttrDef for type */ public function get($type) { - + // determine if there is any extra info tacked on if (strpos($type, '#') !== false) list($type, $string) = explode('#', $type, 2); else $string = ''; - + if (!isset($this->info[$type])) { trigger_error('Cannot retrieve undefined attribute type ' . $type, E_USER_ERROR); return; } - + return $this->info[$type]->make($string); - + } - + /** * Sets a new implementation for a type * @param $type String type name diff --git a/library/HTMLPurifier/AttrValidator.php b/library/HTMLPurifier/AttrValidator.php index fb913fc0..df21c3ac 100644 --- a/library/HTMLPurifier/AttrValidator.php +++ b/library/HTMLPurifier/AttrValidator.php @@ -7,7 +7,7 @@ */ class HTMLPurifier_AttrValidator { - + /** * Validates the attributes of a token, returning a modified token * that has valid tokens @@ -19,33 +19,33 @@ class HTMLPurifier_AttrValidator * @param $context Instance of HTMLPurifier_Context */ public function validateToken(&$token, &$config, $context) { - + $definition = $config->getHTMLDefinition(); $e =& $context->get('ErrorCollector', true); - + // initialize IDAccumulator if necessary $ok =& $context->get('IDAccumulator', true); if (!$ok) { $id_accumulator = HTMLPurifier_IDAccumulator::build($config, $context); $context->register('IDAccumulator', $id_accumulator); } - + // initialize CurrentToken if necessary $current_token =& $context->get('CurrentToken', true); if (!$current_token) $context->register('CurrentToken', $token); - + if ( !$token instanceof HTMLPurifier_Token_Start && !$token instanceof HTMLPurifier_Token_Empty ) return $token; - + // create alias to global definition array, see also $defs // DEFINITION CALL $d_defs = $definition->info_global_attr; - + // don't update token until the very end, to ensure an atomic update $attr = $token->attr; - + // do global transformations (pre) // nothing currently utilizes this foreach ($definition->info_attr_transform_pre as $transform) { @@ -54,7 +54,7 @@ class HTMLPurifier_AttrValidator if ($attr != $o) $e->send(E_NOTICE, 'AttrValidator: Attributes transformed', $o, $attr); } } - + // do local transformations only applicable to this element (pre) // ex.

          to

          foreach ($definition->info[$token->name]->attr_transform_pre as $transform) { @@ -63,19 +63,19 @@ class HTMLPurifier_AttrValidator if ($attr != $o) $e->send(E_NOTICE, 'AttrValidator: Attributes transformed', $o, $attr); } } - + // create alias to this element's attribute definition array, see // also $d_defs (global attribute definition array) // DEFINITION CALL $defs = $definition->info[$token->name]->attr; - + $attr_key = false; $context->register('CurrentAttr', $attr_key); - + // iterate through all the attribute keypairs // Watch out for name collisions: $key has previously been used foreach ($attr as $attr_key => $value) { - + // call the definition if ( isset($defs[$attr_key]) ) { // there is a local definition defined @@ -102,37 +102,37 @@ class HTMLPurifier_AttrValidator // system never heard of the attribute? DELETE! $result = false; } - + // put the results into effect if ($result === false || $result === null) { // this is a generic error message that should replaced // with more specific ones when possible if ($e) $e->send(E_ERROR, 'AttrValidator: Attribute removed'); - + // remove the attribute unset($attr[$attr_key]); } elseif (is_string($result)) { // generally, if a substitution is happening, there // was some sort of implicit correction going on. We'll // delegate it to the attribute classes to say exactly what. - + // simple substitution $attr[$attr_key] = $result; } else { // nothing happens } - + // we'd also want slightly more complicated substitution // involving an array as the return value, // although we're not sure how colliding attributes would // resolve (certain ones would be completely overriden, // others would prepend themselves). } - + $context->destroy('CurrentAttr'); - + // post transforms - + // global (error reporting untested) foreach ($definition->info_attr_transform_post as $transform) { $attr = $transform->transform($o = $attr, $config, $context); @@ -140,7 +140,7 @@ class HTMLPurifier_AttrValidator if ($attr != $o) $e->send(E_NOTICE, 'AttrValidator: Attributes transformed', $o, $attr); } } - + // local (error reporting untested) foreach ($definition->info[$token->name]->attr_transform_post as $transform) { $attr = $transform->transform($o = $attr, $config, $context); @@ -148,14 +148,14 @@ class HTMLPurifier_AttrValidator if ($attr != $o) $e->send(E_NOTICE, 'AttrValidator: Attributes transformed', $o, $attr); } } - + $token->attr = $attr; - + // destroy CurrentToken if we made it ourselves if (!$current_token) $context->destroy('CurrentToken'); - + } - - + + } diff --git a/library/HTMLPurifier/Bootstrap.php b/library/HTMLPurifier/Bootstrap.php index 09dcb501..eb266231 100644 --- a/library/HTMLPurifier/Bootstrap.php +++ b/library/HTMLPurifier/Bootstrap.php @@ -29,7 +29,7 @@ if (!defined('PHP_EOL')) { */ class HTMLPurifier_Bootstrap { - + /** * Autoload function for HTML Purifier * @param $class Class to load @@ -40,7 +40,7 @@ class HTMLPurifier_Bootstrap require HTMLPURIFIER_PREFIX . '/' . $file; return true; } - + /** * Returns the path for a specific class. */ @@ -56,7 +56,7 @@ class HTMLPurifier_Bootstrap if (!file_exists(HTMLPURIFIER_PREFIX . '/' . $file)) return false; return $file; } - + /** * "Pre-registers" our autoloader on the SPL stack. */ @@ -92,5 +92,5 @@ class HTMLPurifier_Bootstrap foreach ($funcs as $func) spl_autoload_register($func); } } - + } diff --git a/library/HTMLPurifier/CSSDefinition.php b/library/HTMLPurifier/CSSDefinition.php index 604c4554..2433cab5 100644 --- a/library/HTMLPurifier/CSSDefinition.php +++ b/library/HTMLPurifier/CSSDefinition.php @@ -6,32 +6,32 @@ */ class HTMLPurifier_CSSDefinition extends HTMLPurifier_Definition { - + public $type = 'CSS'; - + /** * Assoc array of attribute name to definition object. */ public $info = array(); - + /** * Constructs the info array. The meat of this class. */ protected function doSetup($config) { - + $this->info['text-align'] = new HTMLPurifier_AttrDef_Enum( array('left', 'right', 'center', 'justify'), false); - + $border_style = - $this->info['border-bottom-style'] = - $this->info['border-right-style'] = - $this->info['border-left-style'] = + $this->info['border-bottom-style'] = + $this->info['border-right-style'] = + $this->info['border-left-style'] = $this->info['border-top-style'] = new HTMLPurifier_AttrDef_Enum( array('none', 'hidden', 'dotted', 'dashed', 'solid', 'double', 'groove', 'ridge', 'inset', 'outset'), false); - + $this->info['border-style'] = new HTMLPurifier_AttrDef_CSS_Multiple($border_style); - + $this->info['clear'] = new HTMLPurifier_AttrDef_Enum( array('none', 'left', 'right', 'both'), false); $this->info['float'] = new HTMLPurifier_AttrDef_Enum( @@ -40,27 +40,27 @@ class HTMLPurifier_CSSDefinition extends HTMLPurifier_Definition array('normal', 'italic', 'oblique'), false); $this->info['font-variant'] = new HTMLPurifier_AttrDef_Enum( array('normal', 'small-caps'), false); - + $uri_or_none = new HTMLPurifier_AttrDef_CSS_Composite( array( new HTMLPurifier_AttrDef_Enum(array('none')), new HTMLPurifier_AttrDef_CSS_URI() ) ); - + $this->info['list-style-position'] = new HTMLPurifier_AttrDef_Enum( array('inside', 'outside'), false); $this->info['list-style-type'] = new HTMLPurifier_AttrDef_Enum( array('disc', 'circle', 'square', 'decimal', 'lower-roman', 'upper-roman', 'lower-alpha', 'upper-alpha', 'none'), false); $this->info['list-style-image'] = $uri_or_none; - + $this->info['list-style'] = new HTMLPurifier_AttrDef_CSS_ListStyle($config); - + $this->info['text-transform'] = new HTMLPurifier_AttrDef_Enum( array('capitalize', 'uppercase', 'lowercase', 'none'), false); $this->info['color'] = new HTMLPurifier_AttrDef_CSS_Color(); - + $this->info['background-image'] = $uri_or_none; $this->info['background-repeat'] = new HTMLPurifier_AttrDef_Enum( array('repeat', 'repeat-x', 'repeat-y', 'no-repeat') @@ -69,42 +69,42 @@ class HTMLPurifier_CSSDefinition extends HTMLPurifier_Definition array('scroll', 'fixed') ); $this->info['background-position'] = new HTMLPurifier_AttrDef_CSS_BackgroundPosition(); - - $border_color = - $this->info['border-top-color'] = - $this->info['border-bottom-color'] = - $this->info['border-left-color'] = - $this->info['border-right-color'] = + + $border_color = + $this->info['border-top-color'] = + $this->info['border-bottom-color'] = + $this->info['border-left-color'] = + $this->info['border-right-color'] = $this->info['background-color'] = new HTMLPurifier_AttrDef_CSS_Composite(array( new HTMLPurifier_AttrDef_Enum(array('transparent')), new HTMLPurifier_AttrDef_CSS_Color() )); - + $this->info['background'] = new HTMLPurifier_AttrDef_CSS_Background($config); - + $this->info['border-color'] = new HTMLPurifier_AttrDef_CSS_Multiple($border_color); - - $border_width = - $this->info['border-top-width'] = - $this->info['border-bottom-width'] = - $this->info['border-left-width'] = + + $border_width = + $this->info['border-top-width'] = + $this->info['border-bottom-width'] = + $this->info['border-left-width'] = $this->info['border-right-width'] = new HTMLPurifier_AttrDef_CSS_Composite(array( new HTMLPurifier_AttrDef_Enum(array('thin', 'medium', 'thick')), new HTMLPurifier_AttrDef_CSS_Length('0') //disallow negative )); - + $this->info['border-width'] = new HTMLPurifier_AttrDef_CSS_Multiple($border_width); - + $this->info['letter-spacing'] = new HTMLPurifier_AttrDef_CSS_Composite(array( new HTMLPurifier_AttrDef_Enum(array('normal')), new HTMLPurifier_AttrDef_CSS_Length() )); - + $this->info['word-spacing'] = new HTMLPurifier_AttrDef_CSS_Composite(array( new HTMLPurifier_AttrDef_Enum(array('normal')), new HTMLPurifier_AttrDef_CSS_Length() )); - + $this->info['font-size'] = new HTMLPurifier_AttrDef_CSS_Composite(array( new HTMLPurifier_AttrDef_Enum(array('xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large', @@ -112,54 +112,54 @@ class HTMLPurifier_CSSDefinition extends HTMLPurifier_Definition new HTMLPurifier_AttrDef_CSS_Percentage(), new HTMLPurifier_AttrDef_CSS_Length() )); - + $this->info['line-height'] = new HTMLPurifier_AttrDef_CSS_Composite(array( new HTMLPurifier_AttrDef_Enum(array('normal')), new HTMLPurifier_AttrDef_CSS_Number(true), // no negatives new HTMLPurifier_AttrDef_CSS_Length('0'), new HTMLPurifier_AttrDef_CSS_Percentage(true) )); - + $margin = - $this->info['margin-top'] = - $this->info['margin-bottom'] = - $this->info['margin-left'] = + $this->info['margin-top'] = + $this->info['margin-bottom'] = + $this->info['margin-left'] = $this->info['margin-right'] = new HTMLPurifier_AttrDef_CSS_Composite(array( new HTMLPurifier_AttrDef_CSS_Length(), new HTMLPurifier_AttrDef_CSS_Percentage(), new HTMLPurifier_AttrDef_Enum(array('auto')) )); - + $this->info['margin'] = new HTMLPurifier_AttrDef_CSS_Multiple($margin); - + // non-negative $padding = - $this->info['padding-top'] = - $this->info['padding-bottom'] = - $this->info['padding-left'] = + $this->info['padding-top'] = + $this->info['padding-bottom'] = + $this->info['padding-left'] = $this->info['padding-right'] = new HTMLPurifier_AttrDef_CSS_Composite(array( new HTMLPurifier_AttrDef_CSS_Length('0'), new HTMLPurifier_AttrDef_CSS_Percentage(true) )); - + $this->info['padding'] = new HTMLPurifier_AttrDef_CSS_Multiple($padding); - + $this->info['text-indent'] = new HTMLPurifier_AttrDef_CSS_Composite(array( new HTMLPurifier_AttrDef_CSS_Length(), new HTMLPurifier_AttrDef_CSS_Percentage() )); - + $trusted_wh = new HTMLPurifier_AttrDef_CSS_Composite(array( new HTMLPurifier_AttrDef_CSS_Length('0'), new HTMLPurifier_AttrDef_CSS_Percentage(true), new HTMLPurifier_AttrDef_Enum(array('auto')) )); $max = $config->get('CSS', 'MaxImgLength'); - + $this->info['width'] = $this->info['height'] = $max === null ? - $trusted_wh : + $trusted_wh : new HTMLPurifier_AttrDef_Switch('img', // For img tags: new HTMLPurifier_AttrDef_CSS_Composite(array( @@ -169,65 +169,65 @@ class HTMLPurifier_CSSDefinition extends HTMLPurifier_Definition // For everyone else: $trusted_wh ); - + $this->info['text-decoration'] = new HTMLPurifier_AttrDef_CSS_TextDecoration(); - + $this->info['font-family'] = new HTMLPurifier_AttrDef_CSS_FontFamily(); - + // this could use specialized code $this->info['font-weight'] = new HTMLPurifier_AttrDef_Enum( array('normal', 'bold', 'bolder', 'lighter', '100', '200', '300', '400', '500', '600', '700', '800', '900'), false); - + // MUST be called after other font properties, as it references // a CSSDefinition object $this->info['font'] = new HTMLPurifier_AttrDef_CSS_Font($config); - + // same here $this->info['border'] = - $this->info['border-bottom'] = - $this->info['border-top'] = - $this->info['border-left'] = + $this->info['border-bottom'] = + $this->info['border-top'] = + $this->info['border-left'] = $this->info['border-right'] = new HTMLPurifier_AttrDef_CSS_Border($config); - + $this->info['border-collapse'] = new HTMLPurifier_AttrDef_Enum(array( 'collapse', 'separate')); - + $this->info['caption-side'] = new HTMLPurifier_AttrDef_Enum(array( 'top', 'bottom')); - + $this->info['table-layout'] = new HTMLPurifier_AttrDef_Enum(array( 'auto', 'fixed')); - + $this->info['vertical-align'] = new HTMLPurifier_AttrDef_CSS_Composite(array( new HTMLPurifier_AttrDef_Enum(array('baseline', 'sub', 'super', 'top', 'text-top', 'middle', 'bottom', 'text-bottom')), new HTMLPurifier_AttrDef_CSS_Length(), new HTMLPurifier_AttrDef_CSS_Percentage() )); - + $this->info['border-spacing'] = new HTMLPurifier_AttrDef_CSS_Multiple(new HTMLPurifier_AttrDef_CSS_Length(), 2); - + // partial support $this->info['white-space'] = new HTMLPurifier_AttrDef_Enum(array('nowrap')); - + if ($config->get('CSS', 'Proprietary')) { $this->doSetupProprietary($config); } - + if ($config->get('CSS', 'AllowTricky')) { $this->doSetupTricky($config); } - + $allow_important = $config->get('CSS', 'AllowImportant'); // wrap all attr-defs with decorator that handles !important foreach ($this->info as $k => $v) { $this->info[$k] = new HTMLPurifier_AttrDef_CSS_ImportantDecorator($v, $allow_important); } - + $this->setupConfigStuff($config); } - + protected function doSetupProprietary($config) { // Internet Explorer only scrollbar colors $this->info['scrollbar-arrow-color'] = new HTMLPurifier_AttrDef_CSS_Color(); @@ -236,17 +236,17 @@ class HTMLPurifier_CSSDefinition extends HTMLPurifier_Definition $this->info['scrollbar-face-color'] = new HTMLPurifier_AttrDef_CSS_Color(); $this->info['scrollbar-highlight-color'] = new HTMLPurifier_AttrDef_CSS_Color(); $this->info['scrollbar-shadow-color'] = new HTMLPurifier_AttrDef_CSS_Color(); - + // technically not proprietary, but CSS3, and no one supports it $this->info['opacity'] = new HTMLPurifier_AttrDef_CSS_AlphaValue(); $this->info['-moz-opacity'] = new HTMLPurifier_AttrDef_CSS_AlphaValue(); $this->info['-khtml-opacity'] = new HTMLPurifier_AttrDef_CSS_AlphaValue(); - + // only opacity, for now $this->info['filter'] = new HTMLPurifier_AttrDef_CSS_Filter(); - + } - + protected function doSetupTricky($config) { $this->info['display'] = new HTMLPurifier_AttrDef_Enum(array( 'inline', 'block', 'list-item', 'run-in', 'compact', @@ -259,8 +259,8 @@ class HTMLPurifier_CSSDefinition extends HTMLPurifier_Definition )); $this->info['overflow'] = new HTMLPurifier_AttrDef_Enum(array('visible', 'hidden', 'auto', 'scroll')); } - - + + /** * Performs extra config-based processing. Based off of * HTMLPurifier_HTMLDefinition. @@ -268,7 +268,7 @@ class HTMLPurifier_CSSDefinition extends HTMLPurifier_Definition * composition, not inheritance). */ protected function setupConfigStuff($config) { - + // setup allowed elements $support = "(for information on implementing this, see the ". "support forums) "; @@ -285,7 +285,7 @@ class HTMLPurifier_CSSDefinition extends HTMLPurifier_Definition trigger_error("Style attribute '$name' is not supported $support", E_USER_WARNING); } } - + } } diff --git a/library/HTMLPurifier/ChildDef.php b/library/HTMLPurifier/ChildDef.php index 38f3692f..3f5e6652 100644 --- a/library/HTMLPurifier/ChildDef.php +++ b/library/HTMLPurifier/ChildDef.php @@ -10,20 +10,20 @@ abstract class HTMLPurifier_ChildDef * Used occasionally in terms of context. */ public $type; - + /** * Bool that indicates whether or not an empty array of children is okay - * + * * This is necessary for redundant checking when changes affecting * a child node may cause a parent node to now be disallowed. */ public $allow_empty; - + /** * Lookup array of all elements that this definition could possibly allow */ public $elements = array(); - + /** * Get lookup of tag names that should not close this element automatically. * All other elements will do so. @@ -31,10 +31,10 @@ abstract class HTMLPurifier_ChildDef public function getNonAutoCloseElements($config) { return $this->elements; } - + /** * Validates nodes according to definition and returns modification. - * + * * @param $tokens_of_children Array of HTMLPurifier_Token * @param $config HTMLPurifier_Config object * @param $context HTMLPurifier_Context object diff --git a/library/HTMLPurifier/ChildDef/Chameleon.php b/library/HTMLPurifier/ChildDef/Chameleon.php index d918080a..042c9bb7 100644 --- a/library/HTMLPurifier/ChildDef/Chameleon.php +++ b/library/HTMLPurifier/ChildDef/Chameleon.php @@ -2,7 +2,7 @@ /** * Definition that uses different definitions depending on context. - * + * * The del and ins tags are notable because they allow different types of * elements depending on whether or not they're in a block or inline context. * Chameleon allows this behavior to happen by using two different @@ -11,19 +11,19 @@ */ class HTMLPurifier_ChildDef_Chameleon extends HTMLPurifier_ChildDef { - + /** * Instance of the definition object to use when inline. Usually stricter. */ public $inline; - + /** * Instance of the definition object to use when block. */ public $block; - + public $type = 'chameleon'; - + /** * @param $inline List of elements to allow when inline. * @param $block List of elements to allow when block. @@ -33,7 +33,7 @@ class HTMLPurifier_ChildDef_Chameleon extends HTMLPurifier_ChildDef $this->block = new HTMLPurifier_ChildDef_Optional($block); $this->elements = $this->block->elements; } - + public function validateChildren($tokens_of_children, $config, $context) { if ($context->get('IsInline') === false) { return $this->block->validateChildren( diff --git a/library/HTMLPurifier/ChildDef/Custom.php b/library/HTMLPurifier/ChildDef/Custom.php index f79bfcae..444b207c 100644 --- a/library/HTMLPurifier/ChildDef/Custom.php +++ b/library/HTMLPurifier/ChildDef/Custom.php @@ -2,7 +2,7 @@ /** * Custom validation class, accepts DTD child definitions - * + * * @warning Currently this class is an all or nothing proposition, that is, * it will only give a bool return value. */ @@ -36,25 +36,25 @@ class HTMLPurifier_ChildDef_Custom extends HTMLPurifier_ChildDef } $el = '[#a-zA-Z0-9_.-]+'; $reg = $raw; - + // COMPLICATED! AND MIGHT BE BUGGY! I HAVE NO CLUE WHAT I'M // DOING! Seriously: if there's problems, please report them. - + // collect all elements into the $elements array preg_match_all("/$el/", $reg, $matches); foreach ($matches[0] as $match) { $this->elements[$match] = true; } - + // setup all elements as parentheticals with leading commas $reg = preg_replace("/$el/", '(,\\0)', $reg); - + // remove commas when they were not solicited $reg = preg_replace("/([^,(|]\(+),/", '\\1', $reg); - + // remove all non-paranthetical commas: they are handled by first regex $reg = preg_replace("/,\(/", '(', $reg); - + $this->_pcre_regex = $reg; } public function validateChildren($tokens_of_children, $config, $context) { @@ -62,15 +62,15 @@ class HTMLPurifier_ChildDef_Custom extends HTMLPurifier_ChildDef $nesting = 0; // depth into the nest foreach ($tokens_of_children as $token) { if (!empty($token->is_whitespace)) continue; - + $is_child = ($nesting == 0); // direct - + if ($token instanceof HTMLPurifier_Token_Start) { $nesting++; } elseif ($token instanceof HTMLPurifier_Token_End) { $nesting--; } - + if ($is_child) { $list_of_children .= $token->name . ','; } @@ -82,7 +82,7 @@ class HTMLPurifier_ChildDef_Custom extends HTMLPurifier_ChildDef '/^,?'.$this->_pcre_regex.'$/', $list_of_children ); - + return (bool) $okay; } } diff --git a/library/HTMLPurifier/ChildDef/Required.php b/library/HTMLPurifier/ChildDef/Required.php index 9e0afe33..0af6d159 100644 --- a/library/HTMLPurifier/ChildDef/Required.php +++ b/library/HTMLPurifier/ChildDef/Required.php @@ -40,45 +40,45 @@ class HTMLPurifier_ChildDef_Required extends HTMLPurifier_ChildDef // if there are no tokens, delete parent node if (empty($tokens_of_children)) return false; - + // the new set of children $result = array(); - + // current depth into the nest $nesting = 0; - + // whether or not we're deleting a node $is_deleting = false; - + // whether or not parsed character data is allowed // this controls whether or not we silently drop a tag // or generate escaped HTML from it $pcdata_allowed = isset($this->elements['#PCDATA']); - + // a little sanity check to make sure it's not ALL whitespace $all_whitespace = true; - + // some configuration $escape_invalid_children = $config->get('Core', 'EscapeInvalidChildren'); - + // generator $gen = new HTMLPurifier_Generator($config, $context); - + foreach ($tokens_of_children as $token) { if (!empty($token->is_whitespace)) { $result[] = $token; continue; } $all_whitespace = false; // phew, we're not talking about whitespace - + $is_child = ($nesting == 0); - + if ($token instanceof HTMLPurifier_Token_Start) { $nesting++; } elseif ($token instanceof HTMLPurifier_Token_End) { $nesting--; } - + if ($is_child) { $is_deleting = false; if (!isset($this->elements[$token->name])) { diff --git a/library/HTMLPurifier/ChildDef/StrictBlockquote.php b/library/HTMLPurifier/ChildDef/StrictBlockquote.php index ec0890d9..ba2b0d02 100644 --- a/library/HTMLPurifier/ChildDef/StrictBlockquote.php +++ b/library/HTMLPurifier/ChildDef/StrictBlockquote.php @@ -10,7 +10,7 @@ class HTMLPurifier_ChildDef_StrictBlockquote extends HTMLPurifier_ChildDef_Requi public $allow_empty = true; public $type = 'strictblockquote'; protected $init = false; - + /** * @note We don't want MakeWellFormed to auto-close inline elements since * they might be allowed. @@ -19,26 +19,26 @@ class HTMLPurifier_ChildDef_StrictBlockquote extends HTMLPurifier_ChildDef_Requi $this->init($config); return $this->fake_elements; } - + public function validateChildren($tokens_of_children, $config, $context) { - + $this->init($config); - + // trick the parent class into thinking it allows more $this->elements = $this->fake_elements; $result = parent::validateChildren($tokens_of_children, $config, $context); $this->elements = $this->real_elements; - + if ($result === false) return array(); if ($result === true) $result = $tokens_of_children; - + $def = $config->getHTMLDefinition(); $block_wrap_start = new HTMLPurifier_Token_Start($def->info_block_wrapper); $block_wrap_end = new HTMLPurifier_Token_End( $def->info_block_wrapper); $is_inline = false; $depth = 0; $ret = array(); - + // assuming that there are no comment tokens foreach ($result as $i => $token) { $token = $result[$i]; @@ -72,7 +72,7 @@ class HTMLPurifier_ChildDef_StrictBlockquote extends HTMLPurifier_ChildDef_Requi if ($is_inline) $ret[] = $block_wrap_end; return $ret; } - + private function init($config) { if (!$this->init) { $def = $config->getHTMLDefinition(); diff --git a/library/HTMLPurifier/ChildDef/Table.php b/library/HTMLPurifier/ChildDef/Table.php index d9d45bad..ced19477 100644 --- a/library/HTMLPurifier/ChildDef/Table.php +++ b/library/HTMLPurifier/ChildDef/Table.php @@ -12,31 +12,31 @@ class HTMLPurifier_ChildDef_Table extends HTMLPurifier_ChildDef public function __construct() {} public function validateChildren($tokens_of_children, $config, $context) { if (empty($tokens_of_children)) return false; - + // this ensures that the loop gets run one last time before closing // up. It's a little bit of a hack, but it works! Just make sure you // get rid of the token later. $tokens_of_children[] = false; - + // only one of these elements is allowed in a table $caption = false; $thead = false; $tfoot = false; - + // as many of these as you want $cols = array(); $content = array(); - + $nesting = 0; // current depth so we can determine nodes $is_collecting = false; // are we globbing together tokens to package // into one of the collectors? $collection = array(); // collected nodes $tag_index = 0; // the first node might be whitespace, // so this tells us where the start tag is - + foreach ($tokens_of_children as $token) { $is_child = ($nesting == 0); - + if ($token === false) { // terminating sequence started } elseif ($token instanceof HTMLPurifier_Token_Start) { @@ -44,7 +44,7 @@ class HTMLPurifier_ChildDef_Table extends HTMLPurifier_ChildDef } elseif ($token instanceof HTMLPurifier_Token_End) { $nesting--; } - + // handle node collection if ($is_collecting) { if ($is_child) { @@ -85,10 +85,10 @@ class HTMLPurifier_ChildDef_Table extends HTMLPurifier_ChildDef $collection[] = $token; } } - + // terminate if ($token === false) break; - + if ($is_child) { // determine what we're dealing with if ($token->name == 'col') { @@ -118,9 +118,9 @@ class HTMLPurifier_ChildDef_Table extends HTMLPurifier_ChildDef } } } - + if (empty($content)) return false; - + $ret = array(); if ($caption !== false) $ret = array_merge($ret, $caption); if ($cols !== false) foreach ($cols as $token_array) $ret = array_merge($ret, $token_array); @@ -131,11 +131,11 @@ class HTMLPurifier_ChildDef_Table extends HTMLPurifier_ChildDef // grab the trailing space $ret = array_merge($ret, $collection); } - + array_pop($tokens_of_children); // remove phantom token - + return ($ret === $tokens_of_children) ? true : $ret; - + } } diff --git a/library/HTMLPurifier/Config.php b/library/HTMLPurifier/Config.php index aca84982..d2b0d2cd 100644 --- a/library/HTMLPurifier/Config.php +++ b/library/HTMLPurifier/Config.php @@ -5,69 +5,69 @@ * * @warning This class is strongly defined: that means that the class * will fail if an undefined directive is retrieved or set. - * + * * @note Many classes that could (although many times don't) use the * configuration object make it a mandatory parameter. This is * because a configuration object should always be forwarded, * otherwise, you run the risk of missing a parameter and then * being stumped when a configuration directive doesn't work. - * + * * @todo Reconsider some of the public member variables */ class HTMLPurifier_Config { - + /** * HTML Purifier's version */ public $version = '3.2.0'; - + /** - * Bool indicator whether or not to automatically finalize + * Bool indicator whether or not to automatically finalize * the object if a read operation is done */ public $autoFinalize = true; - + // protected member variables - + /** * Namespace indexed array of serials for specific namespaces (see * getSerial() for more info). */ protected $serials = array(); - + /** * Serial for entire configuration object */ protected $serial; - + /** * Two-level associative array of configuration directives */ protected $conf; - + /** * Parser for variables */ protected $parser; - + /** * Reference HTMLPurifier_ConfigSchema for value checking * @note This is public for introspective purposes. Please don't * abuse! */ public $def; - + /** * Indexed array of definitions */ protected $definitions; - + /** * Bool indicator whether or not config is finalized */ protected $finalized = false; - + /** * @param $definition HTMLPurifier_ConfigSchema that defines what directives * are allowed. @@ -77,7 +77,7 @@ class HTMLPurifier_Config $this->def = $definition; // keep a copy around for checking $this->parser = new HTMLPurifier_VarParser_Flexible(); } - + /** * Convenience constructor that creates a config object based on a mixed var * @param mixed $config Variable that defines the state of the config @@ -101,7 +101,7 @@ class HTMLPurifier_Config elseif (is_array($config)) $ret->loadArray($config); return $ret; } - + /** * Convenience constructor that creates a default configuration object. * @return Default HTMLPurifier_Config object. @@ -111,7 +111,7 @@ class HTMLPurifier_Config $config = new HTMLPurifier_Config($definition); return $config; } - + /** * Retreives a value from the configuration. * @param $namespace String namespace @@ -133,7 +133,7 @@ class HTMLPurifier_Config } return $this->conf[$namespace][$key]; } - + /** * Retreives an array of directives to values from a given namespace * @param $namespace String namespace @@ -147,7 +147,7 @@ class HTMLPurifier_Config } return $this->conf[$namespace]; } - + /** * Returns a md5 signature of a segment of the configuration object * that uniquely identifies that particular configuration @@ -163,7 +163,7 @@ class HTMLPurifier_Config } return $this->serials[$namespace]; } - + /** * Returns a md5 signature for the entire configuration object * that uniquely identifies that particular configuration @@ -174,7 +174,7 @@ class HTMLPurifier_Config } return $this->serial; } - + /** * Retrieves all directives, organized by namespace */ @@ -182,7 +182,7 @@ class HTMLPurifier_Config if (!$this->finalized && $this->autoFinalize) $this->finalize(); return $this->conf; } - + /** * Sets a value to configuration. * @param $namespace String namespace @@ -197,7 +197,7 @@ class HTMLPurifier_Config return; } $def = $this->def->info[$namespace][$key]; - + if (isset($def->isAlias)) { if ($from_alias) { trigger_error('Double-aliases not allowed, please fix '. @@ -210,7 +210,7 @@ class HTMLPurifier_Config trigger_error("$namespace.$key is an alias, preferred directive name is $new_ns.$new_dir", E_USER_NOTICE); return; } - + // Raw type might be negative when using the fully optimized form // of stdclass, which indicates allow_null == true $rtype = is_int($def) ? $def : $def->type; @@ -221,7 +221,7 @@ class HTMLPurifier_Config $type = $rtype; $allow_null = isset($def->allow_null); } - + try { $value = $this->parser->parse($value, $type, $allow_null); } catch (HTMLPurifier_VarParserException $e) { @@ -241,17 +241,17 @@ class HTMLPurifier_Config } } $this->conf[$namespace][$key] = $value; - + // reset definitions if the directives they depend on changed - // this is a very costly process, so it's discouraged + // this is a very costly process, so it's discouraged // with finalization if ($namespace == 'HTML' || $namespace == 'CSS') { $this->definitions[$namespace] = null; } - + $this->serials[$namespace] = false; } - + /** * Convenience function for error reporting */ @@ -260,7 +260,7 @@ class HTMLPurifier_Config foreach ($lookup as $name => $b) $list[] = $name; return implode(', ', $list); } - + /** * Retrieves object reference to the HTML definition. * @param $raw Return a copy that has not been setup yet. Must be @@ -269,7 +269,7 @@ class HTMLPurifier_Config public function getHTMLDefinition($raw = false) { return $this->getDefinition('HTML', $raw); } - + /** * Retrieves object reference to the CSS definition * @param $raw Return a copy that has not been setup yet. Must be @@ -278,7 +278,7 @@ class HTMLPurifier_Config public function getCSSDefinition($raw = false) { return $this->getDefinition('CSS', $raw); } - + /** * Retrieves a definition * @param $type Type of definition: HTML, CSS, etc @@ -334,7 +334,7 @@ class HTMLPurifier_Config $cache->set($this->definitions[$type], $this); return $this->definitions[$type]; } - + /** * Loads configuration values from an array with the following structure: * Namespace.Directive => Value @@ -357,7 +357,7 @@ class HTMLPurifier_Config } } } - + /** * Returns a list of array(namespace, directive) for all directives * that are allowed in a web-form context as per an allowed @@ -401,13 +401,13 @@ class HTMLPurifier_Config } return $ret; } - + /** * Loads configuration values from $_GET/$_POST that were posted * via ConfigForm * @param $array $_GET or $_POST array to import * @param $index Index/name that the config variables are in - * @param $allowed List of allowed namespaces/directives + * @param $allowed List of allowed namespaces/directives * @param $mq_fix Boolean whether or not to enable magic quotes fix * @param $schema Instance of HTMLPurifier_ConfigSchema to use, if not global copy */ @@ -416,7 +416,7 @@ class HTMLPurifier_Config $config = HTMLPurifier_Config::create($ret, $schema); return $config; } - + /** * Merges in configuration values from $_GET/$_POST to object. NOT STATIC. * @note Same parameters as loadArrayFromForm @@ -425,7 +425,7 @@ class HTMLPurifier_Config $ret = HTMLPurifier_Config::prepareArrayFromForm($array, $index, $allowed, $mq_fix, $this->def); $this->loadArray($ret); } - + /** * Prepares an array from a form into something usable for the more * strict parts of HTMLPurifier_Config @@ -433,7 +433,7 @@ class HTMLPurifier_Config public static function prepareArrayFromForm($array, $index = false, $allowed = true, $mq_fix = true, $schema = null) { if ($index !== false) $array = (isset($array[$index]) && is_array($array[$index])) ? $array[$index] : array(); $mq = $mq_fix && function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc(); - + $allowed = HTMLPurifier_Config::getAllowedDirectivesForForm($allowed, $schema); $ret = array(); foreach ($allowed as $key) { @@ -449,7 +449,7 @@ class HTMLPurifier_Config } return $ret; } - + /** * Loads configuration values from an ini file * @param $filename Name of ini file @@ -459,7 +459,7 @@ class HTMLPurifier_Config $array = parse_ini_file($filename, true); $this->loadArray($array); } - + /** * Checks whether or not the configuration object is finalized. * @param $error String error message, or false for no error @@ -470,7 +470,7 @@ class HTMLPurifier_Config } return $this->finalized; } - + /** * Finalizes configuration only if auto finalize is on and not * already finalized @@ -478,14 +478,14 @@ class HTMLPurifier_Config public function autoFinalize() { if (!$this->finalized && $this->autoFinalize) $this->finalize(); } - + /** * Finalizes a configuration object, prohibiting further change */ public function finalize() { $this->finalized = true; } - + } diff --git a/library/HTMLPurifier/ConfigSchema.php b/library/HTMLPurifier/ConfigSchema.php index b324181c..5ce63f43 100644 --- a/library/HTMLPurifier/ConfigSchema.php +++ b/library/HTMLPurifier/ConfigSchema.php @@ -4,24 +4,24 @@ * Configuration definition, defines directives and their defaults. */ class HTMLPurifier_ConfigSchema { - + /** * Defaults of the directives and namespaces. * @note This shares the exact same structure as HTMLPurifier_Config::$conf */ public $defaults = array(); - + /** * Definition of the directives. The structure of this is: - * + * * array( * 'Namespace' => array( * 'Directive' => new stdclass(), * ) * ) - * + * * The stdclass may have the following properties: - * + * * - If isAlias isn't set: * - type: Integer type of directive, see HTMLPurifier_VarParser for definitions * - allow_null: If set, this directive allows null values @@ -30,30 +30,30 @@ class HTMLPurifier_ConfigSchema { * - If isAlias is set: * - namespace: Namespace this directive aliases to * - name: Directive name this directive aliases to - * + * * In certain degenerate cases, stdclass will actually be an integer. In * that case, the value is equivalent to an stdclass with the type * property set to the integer. If the integer is negative, type is * equal to the absolute value of integer, and allow_null is true. - * + * * This class is friendly with HTMLPurifier_Config. If you need introspection * about the schema, you're better of using the ConfigSchema_Interchange, * which uses more memory but has much richer information. */ public $info = array(); - + /** * Application-wide singleton */ static protected $singleton; - + /** * Unserializes the default ConfigSchema. */ public static function makeFromSerial() { return unserialize(file_get_contents(HTMLPURIFIER_PREFIX . '/HTMLPurifier/ConfigSchema/schema.ser')); } - + /** * Retrieves an instance of the application-wide configuration definition. */ @@ -65,7 +65,7 @@ class HTMLPurifier_ConfigSchema { } return HTMLPurifier_ConfigSchema::$singleton; } - + /** * Defines a directive for configuration * @warning Will fail of directive's namespace is defined. @@ -85,7 +85,7 @@ class HTMLPurifier_ConfigSchema { $this->info[$namespace][$name] = $obj; $this->defaults[$namespace][$name] = $default; } - + /** * Defines a namespace for directives to be put into. * @warning This is slightly different from the corresponding static @@ -96,10 +96,10 @@ class HTMLPurifier_ConfigSchema { $this->info[$namespace] = array(); $this->defaults[$namespace] = array(); } - + /** * Defines a directive value alias. - * + * * Directive value aliases are convenient for developers because it lets * them set a directive to several values and get the same result. * @param $namespace Directive's namespace @@ -114,7 +114,7 @@ class HTMLPurifier_ConfigSchema { $this->info[$namespace][$name]->aliases[$alias] = $real; } } - + /** * Defines a set of allowed values for a directive. * @warning This is slightly different from the corresponding static @@ -126,7 +126,7 @@ class HTMLPurifier_ConfigSchema { public function addAllowedValues($namespace, $name, $allowed) { $this->info[$namespace][$name]->allowed = $allowed; } - + /** * Defines a directive alias for backwards compatibility * @param $namespace @@ -141,7 +141,7 @@ class HTMLPurifier_ConfigSchema { $obj->isAlias = true; $this->info[$namespace][$name] = $obj; } - + /** * Replaces any stdclass that only has the type property with type integer. */ @@ -156,9 +156,9 @@ class HTMLPurifier_ConfigSchema { } } } - + // DEPRECATED METHODS - + /** @see HTMLPurifier_ConfigSchema->set() */ public static function define($namespace, $name, $default, $type, $description) { HTMLPurifier_ConfigSchema::deprecated(__METHOD__); @@ -169,21 +169,21 @@ class HTMLPurifier_ConfigSchema { $def = HTMLPurifier_ConfigSchema::instance(); $def->add($namespace, $name, $default, $type, $allow_null); } - + /** @see HTMLPurifier_ConfigSchema->addNamespace() */ public static function defineNamespace($namespace, $description) { HTMLPurifier_ConfigSchema::deprecated(__METHOD__); $def = HTMLPurifier_ConfigSchema::instance(); $def->addNamespace($namespace); } - + /** @see HTMLPurifier_ConfigSchema->addValueAliases() */ public static function defineValueAliases($namespace, $name, $aliases) { HTMLPurifier_ConfigSchema::deprecated(__METHOD__); $def = HTMLPurifier_ConfigSchema::instance(); $def->addValueAliases($namespace, $name, $aliases); } - + /** @see HTMLPurifier_ConfigSchema->addAllowedValues() */ public static function defineAllowedValues($namespace, $name, $allowed_values) { HTMLPurifier_ConfigSchema::deprecated(__METHOD__); @@ -194,28 +194,28 @@ class HTMLPurifier_ConfigSchema { $def = HTMLPurifier_ConfigSchema::instance(); $def->addAllowedValues($namespace, $name, $allowed); } - + /** @see HTMLPurifier_ConfigSchema->addAlias() */ public static function defineAlias($namespace, $name, $new_namespace, $new_name) { HTMLPurifier_ConfigSchema::deprecated(__METHOD__); $def = HTMLPurifier_ConfigSchema::instance(); $def->addAlias($namespace, $name, $new_namespace, $new_name); } - + /** @deprecated, use HTMLPurifier_VarParser->parse() */ public function validate($a, $b, $c = false) { trigger_error("HTMLPurifier_ConfigSchema->validate deprecated, use HTMLPurifier_VarParser->parse instead", E_USER_NOTICE); $parser = new HTMLPurifier_VarParser(); return $parser->parse($a, $b, $c); } - + /** * Throws an E_USER_NOTICE stating that a method is deprecated. */ private static function deprecated($method) { trigger_error("Static HTMLPurifier_ConfigSchema::$method deprecated, use add*() method instead", E_USER_NOTICE); } - + } diff --git a/library/HTMLPurifier/ConfigSchema/Builder/ConfigSchema.php b/library/HTMLPurifier/ConfigSchema/Builder/ConfigSchema.php index 727f58ee..164eb358 100644 --- a/library/HTMLPurifier/ConfigSchema/Builder/ConfigSchema.php +++ b/library/HTMLPurifier/ConfigSchema/Builder/ConfigSchema.php @@ -6,7 +6,7 @@ */ class HTMLPurifier_ConfigSchema_Builder_ConfigSchema { - + public function build($interchange) { $schema = new HTMLPurifier_ConfigSchema(); foreach ($interchange->namespaces as $n) { @@ -46,5 +46,5 @@ class HTMLPurifier_ConfigSchema_Builder_ConfigSchema $schema->postProcess(); return $schema; } - + } diff --git a/library/HTMLPurifier/ConfigSchema/Builder/Xml.php b/library/HTMLPurifier/ConfigSchema/Builder/Xml.php index 3c398d66..1e0ed2bb 100644 --- a/library/HTMLPurifier/ConfigSchema/Builder/Xml.php +++ b/library/HTMLPurifier/ConfigSchema/Builder/Xml.php @@ -6,69 +6,69 @@ */ class HTMLPurifier_ConfigSchema_Builder_Xml extends XMLWriter { - + protected $interchange; - + protected function writeHTMLDiv($html) { $this->startElement('div'); - + $purifier = HTMLPurifier::getInstance(); $html = $purifier->purify($html); $this->writeAttribute('xmlns', 'http://www.w3.org/1999/xhtml'); $this->writeRaw($html); - + $this->endElement(); // div } - + protected function export($var) { if ($var === array()) return 'array()'; return var_export($var, true); } - + public function build($interchange) { // global access, only use as last resort $this->interchange = $interchange; - + $this->setIndent(true); $this->startDocument('1.0', 'UTF-8'); $this->startElement('configdoc'); $this->writeElement('title', $interchange->name); - + foreach ($interchange->namespaces as $namespace) { $this->buildNamespace($namespace); } - + $this->endElement(); // configdoc $this->flush(); } - + public function buildNamespace($namespace) { $this->startElement('namespace'); $this->writeAttribute('id', $namespace->namespace); - + $this->writeElement('name', $namespace->namespace); $this->startElement('description'); $this->writeHTMLDiv($namespace->description); $this->endElement(); // description - + foreach ($this->interchange->directives as $directive) { if ($directive->id->namespace !== $namespace->namespace) continue; $this->buildDirective($directive); } - + $this->endElement(); // namespace } - + public function buildDirective($directive) { $this->startElement('directive'); $this->writeAttribute('id', $directive->id->toString()); - + $this->writeElement('name', $directive->id->directive); - + $this->startElement('aliases'); foreach ($directive->aliases as $alias) $this->writeElement('alias', $alias->toString()); $this->endElement(); // aliases - + $this->startElement('constraints'); if ($directive->version) $this->writeElement('version', $directive->version); $this->startElement('type'); @@ -88,19 +88,19 @@ class HTMLPurifier_ConfigSchema_Builder_Xml extends XMLWriter $this->endElement(); } $this->endElement(); // constraints - + if ($directive->deprecatedVersion) { $this->startElement('deprecated'); $this->writeElement('version', $directive->deprecatedVersion); $this->writeElement('use', $directive->deprecatedUse->toString()); $this->endElement(); // deprecated } - + $this->startElement('description'); $this->writeHTMLDiv($directive->description); $this->endElement(); // description - + $this->endElement(); // directive } - + } diff --git a/library/HTMLPurifier/ConfigSchema/Exception.php b/library/HTMLPurifier/ConfigSchema/Exception.php index 4c51d670..a6ec24ae 100644 --- a/library/HTMLPurifier/ConfigSchema/Exception.php +++ b/library/HTMLPurifier/ConfigSchema/Exception.php @@ -5,5 +5,5 @@ */ class HTMLPurifier_ConfigSchema_Exception extends HTMLPurifier_Exception { - + } diff --git a/library/HTMLPurifier/ConfigSchema/Interchange.php b/library/HTMLPurifier/ConfigSchema/Interchange.php index 37a374f0..aa7cc9f0 100644 --- a/library/HTMLPurifier/ConfigSchema/Interchange.php +++ b/library/HTMLPurifier/ConfigSchema/Interchange.php @@ -7,22 +7,22 @@ */ class HTMLPurifier_ConfigSchema_Interchange { - + /** * Name of the application this schema is describing. */ public $name; - + /** * Array of Namespace ID => array(namespace info) */ public $namespaces = array(); - + /** * Array of Directive ID => array(directive info) */ public $directives = array(); - + /** * Adds a namespace array to $namespaces */ @@ -32,7 +32,7 @@ class HTMLPurifier_ConfigSchema_Interchange } $this->namespaces[$i] = $namespace; } - + /** * Adds a directive array to $directives */ @@ -42,7 +42,7 @@ class HTMLPurifier_ConfigSchema_Interchange } $this->directives[$i] = $directive; } - + /** * Convenience function to perform standard validation. Throws exception * on failed validation. @@ -51,5 +51,5 @@ class HTMLPurifier_ConfigSchema_Interchange $validator = new HTMLPurifier_ConfigSchema_Validator(); return $validator->validate($this); } - + } diff --git a/library/HTMLPurifier/ConfigSchema/Interchange/Directive.php b/library/HTMLPurifier/ConfigSchema/Interchange/Directive.php index 5c8c4797..24daed67 100644 --- a/library/HTMLPurifier/ConfigSchema/Interchange/Directive.php +++ b/library/HTMLPurifier/ConfigSchema/Interchange/Directive.php @@ -5,71 +5,71 @@ */ class HTMLPurifier_ConfigSchema_Interchange_Directive { - + /** * ID of directive, instance of HTMLPurifier_ConfigSchema_Interchange_Id. */ public $id; - + /** * String type, e.g. 'integer' or 'istring'. */ public $type; - + /** * Default value, e.g. 3 or 'DefaultVal'. */ public $default; - + /** * HTML description. */ public $description; - + /** * Boolean whether or not null is allowed as a value. */ public $typeAllowsNull = false; - + /** * Lookup table of allowed scalar values, e.g. array('allowed' => true). * Null if all values are allowed. */ public $allowed; - + /** * List of aliases for the directive, * e.g. array(new HTMLPurifier_ConfigSchema_Interchange_Id('Ns', 'Dir'))). */ public $aliases = array(); - + /** * Hash of value aliases, e.g. array('alt' => 'real'). Null if value * aliasing is disabled (necessary for non-scalar types). */ public $valueAliases; - + /** * Version of HTML Purifier the directive was introduced, e.g. '1.3.1'. * Null if the directive has always existed. */ public $version; - + /** * ID of directive that supercedes this old directive, is an instance * of HTMLPurifier_ConfigSchema_Interchange_Id. Null if not deprecated. */ public $deprecatedUse; - + /** * Version of HTML Purifier this directive was deprecated. Null if not * deprecated. */ public $deprecatedVersion; - + /** * List of external projects this directive depends on, e.g. array('CSSTidy'). */ public $external = array(); - + } diff --git a/library/HTMLPurifier/ConfigSchema/Interchange/Id.php b/library/HTMLPurifier/ConfigSchema/Interchange/Id.php index 40a5fe3c..4d5b4cb3 100644 --- a/library/HTMLPurifier/ConfigSchema/Interchange/Id.php +++ b/library/HTMLPurifier/ConfigSchema/Interchange/Id.php @@ -5,14 +5,14 @@ */ class HTMLPurifier_ConfigSchema_Interchange_Id { - + public $namespace, $directive; - + public function __construct($namespace, $directive) { $this->namespace = $namespace; $this->directive = $directive; } - + /** * @warning This is NOT magic, to ensure that people don't abuse SPL and * cause problems for PHP 5.0 support. @@ -20,10 +20,10 @@ class HTMLPurifier_ConfigSchema_Interchange_Id public function toString() { return $this->namespace . '.' . $this->directive; } - + public static function make($id) { list($namespace, $directive) = explode('.', $id); return new HTMLPurifier_ConfigSchema_Interchange_Id($namespace, $directive); } - + } diff --git a/library/HTMLPurifier/ConfigSchema/Interchange/Namespace.php b/library/HTMLPurifier/ConfigSchema/Interchange/Namespace.php index 8fe81581..3eed008e 100644 --- a/library/HTMLPurifier/ConfigSchema/Interchange/Namespace.php +++ b/library/HTMLPurifier/ConfigSchema/Interchange/Namespace.php @@ -5,15 +5,15 @@ */ class HTMLPurifier_ConfigSchema_Interchange_Namespace { - + /** * Name of namespace defined. */ public $namespace; - + /** * HTML description. */ public $description; - + } diff --git a/library/HTMLPurifier/ConfigSchema/InterchangeBuilder.php b/library/HTMLPurifier/ConfigSchema/InterchangeBuilder.php index 98a0c9d3..5f781fbc 100644 --- a/library/HTMLPurifier/ConfigSchema/InterchangeBuilder.php +++ b/library/HTMLPurifier/ConfigSchema/InterchangeBuilder.php @@ -2,25 +2,25 @@ class HTMLPurifier_ConfigSchema_InterchangeBuilder { - + /** * Used for processing DEFAULT, nothing else. */ protected $varParser; - + public function __construct($varParser = null) { $this->varParser = $varParser ? $varParser : new HTMLPurifier_VarParser_Native(); } - + public static function buildFromDirectory($dir = null) { $parser = new HTMLPurifier_StringHashParser(); $builder = new HTMLPurifier_ConfigSchema_InterchangeBuilder(); $interchange = new HTMLPurifier_ConfigSchema_Interchange(); - + if (!$dir) $dir = HTMLPURIFIER_PREFIX . '/HTMLPurifier/ConfigSchema/schema/'; $info = parse_ini_file($dir . 'info.ini'); $interchange->name = $info['name']; - + $files = array(); $dh = opendir($dir); while (false !== ($file = readdir($dh))) { @@ -30,7 +30,7 @@ class HTMLPurifier_ConfigSchema_InterchangeBuilder $files[] = $file; } closedir($dh); - + sort($files); foreach ($files as $file) { $builder->build( @@ -38,10 +38,10 @@ class HTMLPurifier_ConfigSchema_InterchangeBuilder new HTMLPurifier_StringHash( $parser->parseFile($dir . $file) ) ); } - + return $interchange; } - + /** * Builds an interchange object based on a hash. * @param $interchange HTMLPurifier_ConfigSchema_Interchange object to build @@ -61,7 +61,7 @@ class HTMLPurifier_ConfigSchema_InterchangeBuilder } $this->_findUnused($hash); } - + public function buildNamespace($interchange, $hash) { $namespace = new HTMLPurifier_ConfigSchema_Interchange_Namespace(); $namespace->namespace = $hash->offsetGet('ID'); @@ -70,14 +70,14 @@ class HTMLPurifier_ConfigSchema_InterchangeBuilder } $interchange->addNamespace($namespace); } - + public function buildDirective($interchange, $hash) { $directive = new HTMLPurifier_ConfigSchema_Interchange_Directive(); - + // These are required elements: $directive->id = $this->id($hash->offsetGet('ID')); $id = $directive->id->toString(); // convenience - + if (isset($hash['TYPE'])) { $type = explode('/', $hash->offsetGet('TYPE')); if (isset($type[1])) $directive->typeAllowsNull = true; @@ -85,7 +85,7 @@ class HTMLPurifier_ConfigSchema_InterchangeBuilder } else { throw new HTMLPurifier_ConfigSchema_Exception("TYPE in directive hash '$id' not defined"); } - + if (isset($hash['DEFAULT'])) { try { $directive->default = $this->varParser->parse($hash->offsetGet('DEFAULT'), $directive->type, $directive->typeAllowsNull); @@ -93,19 +93,19 @@ class HTMLPurifier_ConfigSchema_InterchangeBuilder throw new HTMLPurifier_ConfigSchema_Exception($e->getMessage() . " in DEFAULT in directive hash '$id'"); } } - + if (isset($hash['DESCRIPTION'])) { $directive->description = $hash->offsetGet('DESCRIPTION'); } - + if (isset($hash['ALLOWED'])) { $directive->allowed = $this->lookup($this->evalArray($hash->offsetGet('ALLOWED'))); } - + if (isset($hash['VALUE-ALIASES'])) { $directive->valueAliases = $this->evalArray($hash->offsetGet('VALUE-ALIASES')); } - + if (isset($hash['ALIASES'])) { $raw_aliases = trim($hash->offsetGet('ALIASES')); $aliases = preg_split('/\s*,\s*/', $raw_aliases); @@ -113,33 +113,33 @@ class HTMLPurifier_ConfigSchema_InterchangeBuilder $directive->aliases[] = $this->id($alias); } } - + if (isset($hash['VERSION'])) { $directive->version = $hash->offsetGet('VERSION'); } - + if (isset($hash['DEPRECATED-USE'])) { $directive->deprecatedUse = $this->id($hash->offsetGet('DEPRECATED-USE')); } - + if (isset($hash['DEPRECATED-VERSION'])) { $directive->deprecatedVersion = $hash->offsetGet('DEPRECATED-VERSION'); } - + if (isset($hash['EXTERNAL'])) { $directive->external = preg_split('/\s*,\s*/', trim($hash->offsetGet('EXTERNAL'))); } - + $interchange->addDirective($directive); } - + /** * Evaluates an array PHP code string without array() wrapper */ protected function evalArray($contents) { return eval('return array('. $contents .');'); } - + /** * Converts an array list into a lookup array. */ @@ -148,7 +148,7 @@ class HTMLPurifier_ConfigSchema_InterchangeBuilder foreach ($array as $val) $ret[$val] = true; return $ret; } - + /** * Convenience function that creates an HTMLPurifier_ConfigSchema_Interchange_Id * object based on a string Id. @@ -156,7 +156,7 @@ class HTMLPurifier_ConfigSchema_InterchangeBuilder protected function id($id) { return HTMLPurifier_ConfigSchema_Interchange_Id::make($id); } - + /** * Triggers errors for any unused keys passed in the hash; such keys * may indicate typos, missing values, etc. @@ -170,6 +170,6 @@ class HTMLPurifier_ConfigSchema_InterchangeBuilder } } } - + } diff --git a/library/HTMLPurifier/ConfigSchema/Validator.php b/library/HTMLPurifier/ConfigSchema/Validator.php index 64a35430..1bd959e8 100644 --- a/library/HTMLPurifier/ConfigSchema/Validator.php +++ b/library/HTMLPurifier/ConfigSchema/Validator.php @@ -10,26 +10,26 @@ */ class HTMLPurifier_ConfigSchema_Validator { - + /** * Easy to access global objects. */ protected $interchange, $aliases; - + /** * Context-stack to provide easy to read error messages. */ protected $context = array(); - + /** * HTMLPurifier_VarParser to test default's type. */ protected $parser; - + public function __construct() { $this->parser = new HTMLPurifier_VarParser(); } - + /** * Validates a fully-formed interchange object. Throws an * HTMLPurifier_ConfigSchema_Exception if there's a problem. @@ -50,7 +50,7 @@ class HTMLPurifier_ConfigSchema_Validator } return true; } - + /** * Validates a HTMLPurifier_ConfigSchema_Interchange_Namespace object. */ @@ -64,7 +64,7 @@ class HTMLPurifier_ConfigSchema_Validator ->assertIsString(); // handled by InterchangeBuilder array_pop($this->context); } - + /** * Validates a HTMLPurifier_ConfigSchema_Interchange_Id object. */ @@ -83,7 +83,7 @@ class HTMLPurifier_ConfigSchema_Validator ->assertAlnum(); // implicit assertIsString handled by InterchangeBuilder array_pop($this->context); } - + /** * Validates a HTMLPurifier_ConfigSchema_Interchange_Directive object. */ @@ -91,10 +91,10 @@ class HTMLPurifier_ConfigSchema_Validator $id = $d->id->toString(); $this->context[] = "directive '$id'"; $this->validateId($d->id); - + $this->with($d, 'description') ->assertNotEmpty(); - + // BEGIN - handled by InterchangeBuilder $this->with($d, 'type') ->assertNotEmpty(); @@ -107,7 +107,7 @@ class HTMLPurifier_ConfigSchema_Validator $this->error('default', 'had error: ' . $e->getMessage()); } // END - handled by InterchangeBuilder - + if (!is_null($d->allowed) || !empty($d->valueAliases)) { // allowed and valueAliases require that we be dealing with // strings, so check for that early. @@ -116,14 +116,14 @@ class HTMLPurifier_ConfigSchema_Validator $this->error('type', 'must be a string type when used with allowed or value aliases'); } } - + $this->validateDirectiveAllowed($d); $this->validateDirectiveValueAliases($d); $this->validateDirectiveAliases($d); - + array_pop($this->context); } - + /** * Extra validation if $allowed member variable of * HTMLPurifier_ConfigSchema_Interchange_Directive is defined. @@ -142,7 +142,7 @@ class HTMLPurifier_ConfigSchema_Validator } array_pop($this->context); } - + /** * Extra validation if $valueAliases member variable of * HTMLPurifier_ConfigSchema_Interchange_Directive is defined. @@ -170,7 +170,7 @@ class HTMLPurifier_ConfigSchema_Validator } array_pop($this->context); } - + /** * Extra validation if $aliases member variable of * HTMLPurifier_ConfigSchema_Interchange_Directive is defined. @@ -193,9 +193,9 @@ class HTMLPurifier_ConfigSchema_Validator } array_pop($this->context); } - + // protected helper functions - + /** * Convenience function for generating HTMLPurifier_ConfigSchema_ValidatorAtom * for validating simple member variables of objects. @@ -203,7 +203,7 @@ class HTMLPurifier_ConfigSchema_Validator protected function with($obj, $member) { return new HTMLPurifier_ConfigSchema_ValidatorAtom($this->getFormattedContext(), $obj, $member); } - + /** * Emits an error, providing helpful context. */ @@ -212,12 +212,12 @@ class HTMLPurifier_ConfigSchema_Validator else $prefix = ucfirst($this->getFormattedContext()); throw new HTMLPurifier_ConfigSchema_Exception(trim($prefix . ' ' . $msg)); } - + /** * Returns a formatted context string. */ protected function getFormattedContext() { return implode(' in ', array_reverse($this->context)); } - + } diff --git a/library/HTMLPurifier/ConfigSchema/ValidatorAtom.php b/library/HTMLPurifier/ConfigSchema/ValidatorAtom.php index 2bb99676..80cd1147 100644 --- a/library/HTMLPurifier/ConfigSchema/ValidatorAtom.php +++ b/library/HTMLPurifier/ConfigSchema/ValidatorAtom.php @@ -8,47 +8,47 @@ */ class HTMLPurifier_ConfigSchema_ValidatorAtom { - + protected $context, $obj, $member, $contents; - + public function __construct($context, $obj, $member) { $this->context = $context; $this->obj = $obj; $this->member = $member; $this->contents =& $obj->$member; } - + public function assertIsString() { if (!is_string($this->contents)) $this->error('must be a string'); return $this; } - + public function assertIsBool() { if (!is_bool($this->contents)) $this->error('must be a boolean'); return $this; } - + public function assertIsArray() { if (!is_array($this->contents)) $this->error('must be an array'); return $this; } - + public function assertNotNull() { if ($this->contents === null) $this->error('must not be null'); return $this; } - + public function assertAlnum() { $this->assertIsString(); if (!ctype_alnum($this->contents)) $this->error('must be alphanumeric'); return $this; } - + public function assertNotEmpty() { if (empty($this->contents)) $this->error('must not be empty'); return $this; } - + public function assertIsLookup() { $this->assertIsArray(); foreach ($this->contents as $v) { @@ -56,11 +56,11 @@ class HTMLPurifier_ConfigSchema_ValidatorAtom } return $this; } - + protected function error($msg) { throw new HTMLPurifier_ConfigSchema_Exception(ucfirst($this->member) . ' in ' . $this->context . ' ' . $msg); } - + } diff --git a/library/HTMLPurifier/ConfigSchema/schema/Attr.AllowedRel.txt b/library/HTMLPurifier/ConfigSchema/schema/Attr.AllowedRel.txt index e9f3febe..c5cda0f2 100644 --- a/library/HTMLPurifier/ConfigSchema/schema/Attr.AllowedRel.txt +++ b/library/HTMLPurifier/ConfigSchema/schema/Attr.AllowedRel.txt @@ -5,4 +5,4 @@ DEFAULT: array() --DESCRIPTION-- List of allowed forward document relationships in the rel attribute. Common values may be nofollow or print. By default, this is empty, meaning that no -document relationships are allowed. +document relationships are allowed. diff --git a/library/HTMLPurifier/ConfigSchema/schema/Attr.AllowedRev.txt b/library/HTMLPurifier/ConfigSchema/schema/Attr.AllowedRev.txt index 95cc372e..89212c85 100644 --- a/library/HTMLPurifier/ConfigSchema/schema/Attr.AllowedRev.txt +++ b/library/HTMLPurifier/ConfigSchema/schema/Attr.AllowedRev.txt @@ -5,4 +5,4 @@ DEFAULT: array() --DESCRIPTION-- List of allowed reverse document relationships in the rev attribute. This attribute is a bit of an edge-case; if you don't know what it is for, stay -away. +away. diff --git a/library/HTMLPurifier/ConfigSchema/schema/Attr.IDBlacklistRegexp.txt b/library/HTMLPurifier/ConfigSchema/schema/Attr.IDBlacklistRegexp.txt index 08a74a0a..2da2e7ab 100644 --- a/library/HTMLPurifier/ConfigSchema/schema/Attr.IDBlacklistRegexp.txt +++ b/library/HTMLPurifier/ConfigSchema/schema/Attr.IDBlacklistRegexp.txt @@ -5,4 +5,4 @@ DEFAULT: NULL --DESCRIPTION-- PCRE regular expression to be matched against all IDs. If the expression is matches, the ID is rejected. Use this with care: may cause significant -degradation. ID matching is done after all other validation. +degradation. ID matching is done after all other validation. diff --git a/library/HTMLPurifier/ConfigSchema/schema/Attr.IDPrefix.txt b/library/HTMLPurifier/ConfigSchema/schema/Attr.IDPrefix.txt index 362aa242..e5736f68 100644 --- a/library/HTMLPurifier/ConfigSchema/schema/Attr.IDPrefix.txt +++ b/library/HTMLPurifier/ConfigSchema/schema/Attr.IDPrefix.txt @@ -8,4 +8,4 @@ you may opt to simply add a prefix to all user-submitted ID attributes so that they are still usable, but will not conflict with core page IDs. Example: setting the directive to 'user_' will result in a user submitted 'foo' to become 'user_foo' Be sure to set %HTML.EnableAttrID to true -before using this. +before using this. diff --git a/library/HTMLPurifier/ConfigSchema/schema/Attr.IDPrefixLocal.txt b/library/HTMLPurifier/ConfigSchema/schema/Attr.IDPrefixLocal.txt index b4f6b315..4a8b6872 100644 --- a/library/HTMLPurifier/ConfigSchema/schema/Attr.IDPrefixLocal.txt +++ b/library/HTMLPurifier/ConfigSchema/schema/Attr.IDPrefixLocal.txt @@ -10,4 +10,4 @@ seperately submitted user content displayed on the same page doesn't clobber each other. Ideal values are unique identifiers for the content it represents (i.e. the id of the row in the database). Be sure to add a seperator (like an underscore) at the end. Warning: this directive will -not work unless %Attr.IDPrefix is set to a non-empty value! +not work unless %Attr.IDPrefix is set to a non-empty value! diff --git a/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.Custom.txt b/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.Custom.txt index a8bd4eb1..90fc5ad7 100644 --- a/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.Custom.txt +++ b/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.Custom.txt @@ -7,6 +7,6 @@ DEFAULT: array()

          This directive can be used to add custom auto-format injectors. Specify an array of injector names (class name minus the prefix) - or concrete implementations. Injector class must exist. + or concrete implementations. Injector class must exist.

          diff --git a/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.Linkify.txt b/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.Linkify.txt index 6c1cd7b6..c377e917 100644 --- a/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.Linkify.txt +++ b/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.Linkify.txt @@ -7,6 +7,6 @@ DEFAULT: false

          This directive turns on linkification, auto-linking http, ftp and https URLs. a tags with the href attribute - must be allowed. + must be allowed.

          diff --git a/library/HTMLPurifier/ConfigSchema/schema/AutoFormatParam.PurifierLinkifyDocURL.txt b/library/HTMLPurifier/ConfigSchema/schema/AutoFormatParam.PurifierLinkifyDocURL.txt index 11d3b4e1..b7ff83f8 100644 --- a/library/HTMLPurifier/ConfigSchema/schema/AutoFormatParam.PurifierLinkifyDocURL.txt +++ b/library/HTMLPurifier/ConfigSchema/schema/AutoFormatParam.PurifierLinkifyDocURL.txt @@ -7,6 +7,6 @@ DEFAULT: '#%s'

          Location of configuration documentation to link to, let %s substitute into the configuration's namespace and directive names sans the percent - sign. + sign.

          diff --git a/library/HTMLPurifier/ConfigSchema/schema/CSS.AllowedProperties.txt b/library/HTMLPurifier/ConfigSchema/schema/CSS.AllowedProperties.txt index b0668974..6960d562 100644 --- a/library/HTMLPurifier/ConfigSchema/schema/CSS.AllowedProperties.txt +++ b/library/HTMLPurifier/ConfigSchema/schema/CSS.AllowedProperties.txt @@ -5,13 +5,13 @@ DEFAULT: NULL --DESCRIPTION--

          - If HTML Purifier's style attributes set is unsatisfactory for your needs, - you can overload it with your own list of tags to allow. Note that this - method is subtractive: it does its job by taking away from HTML Purifier - usual feature set, so you cannot add an attribute that HTML Purifier never + If HTML Purifier's style attributes set is unsatisfactory for your needs, + you can overload it with your own list of tags to allow. Note that this + method is subtractive: it does its job by taking away from HTML Purifier + usual feature set, so you cannot add an attribute that HTML Purifier never supported in the first place.

          - Warning: If another directive conflicts with the - elements here, that directive will win and override. + Warning: If another directive conflicts with the + elements here, that directive will win and override.

          diff --git a/library/HTMLPurifier/ConfigSchema/schema/CSS.DefinitionRev.txt b/library/HTMLPurifier/ConfigSchema/schema/CSS.DefinitionRev.txt index 5b40de2a..477791a1 100644 --- a/library/HTMLPurifier/ConfigSchema/schema/CSS.DefinitionRev.txt +++ b/library/HTMLPurifier/ConfigSchema/schema/CSS.DefinitionRev.txt @@ -6,6 +6,6 @@ DEFAULT: 1

          Revision identifier for your custom definition. See - %HTML.DefinitionRev for details. + %HTML.DefinitionRev for details.

          diff --git a/library/HTMLPurifier/ConfigSchema/schema/CSS.Proprietary.txt b/library/HTMLPurifier/ConfigSchema/schema/CSS.Proprietary.txt index cc883dc5..71b9ea47 100644 --- a/library/HTMLPurifier/ConfigSchema/schema/CSS.Proprietary.txt +++ b/library/HTMLPurifier/ConfigSchema/schema/CSS.Proprietary.txt @@ -5,6 +5,6 @@ DEFAULT: false --DESCRIPTION--

          - Whether or not to allow safe, proprietary CSS values. + Whether or not to allow safe, proprietary CSS values.

          diff --git a/library/HTMLPurifier/ConfigSchema/schema/Cache.DefinitionImpl.txt b/library/HTMLPurifier/ConfigSchema/schema/Cache.DefinitionImpl.txt index 192db1f9..92b3bee6 100644 --- a/library/HTMLPurifier/ConfigSchema/schema/Cache.DefinitionImpl.txt +++ b/library/HTMLPurifier/ConfigSchema/schema/Cache.DefinitionImpl.txt @@ -7,7 +7,7 @@ DEFAULT: 'Serializer' This directive defines which method to use when caching definitions, the complex data-type that makes HTML Purifier tick. Set to null to disable caching (not recommended, as you will see a definite -performance degradation). +performance degradation). --ALIASES-- Core.DefinitionCache diff --git a/library/HTMLPurifier/ConfigSchema/schema/Cache.SerializerPath.txt b/library/HTMLPurifier/ConfigSchema/schema/Cache.SerializerPath.txt index 600c567e..981882eb 100644 --- a/library/HTMLPurifier/ConfigSchema/schema/Cache.SerializerPath.txt +++ b/library/HTMLPurifier/ConfigSchema/schema/Cache.SerializerPath.txt @@ -8,6 +8,6 @@ DEFAULT: NULL Absolute path with no trailing slash to store serialized definitions in. Default is within the HTML Purifier library inside DefinitionCache/Serializer. This - path must be writable by the webserver. + path must be writable by the webserver.

          diff --git a/library/HTMLPurifier/ConfigSchema/schema/Core.CollectErrors.txt b/library/HTMLPurifier/ConfigSchema/schema/Core.CollectErrors.txt index ccaf2ae3..5ab4168a 100644 --- a/library/HTMLPurifier/ConfigSchema/schema/Core.CollectErrors.txt +++ b/library/HTMLPurifier/ConfigSchema/schema/Core.CollectErrors.txt @@ -8,4 +8,4 @@ Whether or not to collect errors found while filtering the document. This is a useful way to give feedback to your users. Warning: Currently this feature is very patchy and experimental, with lots of possible error messages not yet implemented. It will not cause any -problems, but it may not help your users either. +problems, but it may not help your users either. diff --git a/library/HTMLPurifier/ConfigSchema/schema/Core.DirectLexLineNumberSyncInterval.txt b/library/HTMLPurifier/ConfigSchema/schema/Core.DirectLexLineNumberSyncInterval.txt index 1ecc6637..56c213ab 100644 --- a/library/HTMLPurifier/ConfigSchema/schema/Core.DirectLexLineNumberSyncInterval.txt +++ b/library/HTMLPurifier/ConfigSchema/schema/Core.DirectLexLineNumberSyncInterval.txt @@ -12,6 +12,6 @@ DEFAULT: 0 performance, and this is only strictly necessary if the counting algorithm is buggy (in which case you should report it as a bug). This has no effect when %Core.MaintainLineNumbers is disabled or DirectLex is - not being used. + not being used.

          diff --git a/library/HTMLPurifier/ConfigSchema/schema/Core.EscapeNonASCIICharacters.txt b/library/HTMLPurifier/ConfigSchema/schema/Core.EscapeNonASCIICharacters.txt index 93b8a4b2..8540c202 100644 --- a/library/HTMLPurifier/ConfigSchema/schema/Core.EscapeNonASCIICharacters.txt +++ b/library/HTMLPurifier/ConfigSchema/schema/Core.EscapeNonASCIICharacters.txt @@ -9,4 +9,4 @@ converting it to its native encoding. This means that even characters that can be expressed in the non-UTF-8 encoding will be entity-ized, which can be a real downer for encodings like Big5. It also assumes that the ASCII repetoire is available, although this is the case for almost all encodings. -Anyway, use UTF-8! +Anyway, use UTF-8! diff --git a/library/HTMLPurifier/ConfigSchema/schema/Core.HiddenElements.txt b/library/HTMLPurifier/ConfigSchema/schema/Core.HiddenElements.txt index f317221c..51ad8afc 100644 --- a/library/HTMLPurifier/ConfigSchema/schema/Core.HiddenElements.txt +++ b/library/HTMLPurifier/ConfigSchema/schema/Core.HiddenElements.txt @@ -10,7 +10,7 @@ array (

          This directive is a lookup array of elements which should have their contents removed when they are not allowed by the HTML definition. - For example, the contents of a script tag are not + For example, the contents of a script tag are not normally shown in a document, so if script tags are to be removed, their contents should be removed to. This is opposed to a b tag, which defines some presentational changes but does not hide its diff --git a/library/HTMLPurifier/ConfigSchema/schema/Core.MaintainLineNumbers.txt b/library/HTMLPurifier/ConfigSchema/schema/Core.MaintainLineNumbers.txt index 00fa7550..85307d35 100644 --- a/library/HTMLPurifier/ConfigSchema/schema/Core.MaintainLineNumbers.txt +++ b/library/HTMLPurifier/ConfigSchema/schema/Core.MaintainLineNumbers.txt @@ -9,8 +9,8 @@ DEFAULT: NULL This is useful when error reporting is turned on, but can result in significant performance degradation and should not be used when unnecessary. This directive must be used with the DirectLex lexer, - as the DOMLex lexer does not (yet) support this functionality. + as the DOMLex lexer does not (yet) support this functionality. If the value is null, an appropriate value will be selected based - on other configuration. + on other configuration.

          diff --git a/library/HTMLPurifier/ConfigSchema/schema/Core.RemoveInvalidImg.txt b/library/HTMLPurifier/ConfigSchema/schema/Core.RemoveInvalidImg.txt index 3b5c8fd0..c049d4df 100644 --- a/library/HTMLPurifier/ConfigSchema/schema/Core.RemoveInvalidImg.txt +++ b/library/HTMLPurifier/ConfigSchema/schema/Core.RemoveInvalidImg.txt @@ -5,8 +5,8 @@ VERSION: 1.3.0 --DESCRIPTION--

          - This directive enables pre-emptive URI checking in img - tags, as the attribute validation strategy is not authorized to + This directive enables pre-emptive URI checking in img + tags, as the attribute validation strategy is not authorized to remove elements from the document. Revert to pre-1.3.0 behavior by setting to false.

          diff --git a/library/HTMLPurifier/ConfigSchema/schema/Filter.ExtractStyleBlocks.txt b/library/HTMLPurifier/ConfigSchema/schema/Filter.ExtractStyleBlocks.txt index aaa74163..49413220 100644 --- a/library/HTMLPurifier/ConfigSchema/schema/Filter.ExtractStyleBlocks.txt +++ b/library/HTMLPurifier/ConfigSchema/schema/Filter.ExtractStyleBlocks.txt @@ -27,15 +27,15 @@ EXTERNAL: CSSTidy body {color:#F00;} Some text'; $config = HTMLPurifier_Config::createDefault(); $config->set('Filter', 'ExtractStyleBlocks', true); $purifier = new HTMLPurifier($config); - + $html = $purifier->purify($dirty); - + // This implementation writes the stylesheets to the styles/ directory. // You can also echo the styles inside the document, but it's a bit // more difficult to make sure they get interpreted properly by diff --git a/library/HTMLPurifier/ConfigSchema/schema/FilterParam.ExtractStyleBlocksEscaping.txt b/library/HTMLPurifier/ConfigSchema/schema/FilterParam.ExtractStyleBlocksEscaping.txt index 96ac5e5d..45610102 100644 --- a/library/HTMLPurifier/ConfigSchema/schema/FilterParam.ExtractStyleBlocksEscaping.txt +++ b/library/HTMLPurifier/ConfigSchema/schema/FilterParam.ExtractStyleBlocksEscaping.txt @@ -9,6 +9,6 @@ ALIASES: Filter.ExtractStyleBlocksEscaping Whether or not to escape the dangerous characters <, > and & as \3C, \3E and \26, respectively. This is can be safely set to false if the contents of StyleBlocks will be placed in an external stylesheet, - where there is no risk of it being interpreted as HTML. + where there is no risk of it being interpreted as HTML.

          diff --git a/library/HTMLPurifier/ConfigSchema/schema/HTML.AllowedAttributes.txt b/library/HTMLPurifier/ConfigSchema/schema/HTML.AllowedAttributes.txt index 88e696e8..04d71ae8 100644 --- a/library/HTMLPurifier/ConfigSchema/schema/HTML.AllowedAttributes.txt +++ b/library/HTMLPurifier/ConfigSchema/schema/HTML.AllowedAttributes.txt @@ -5,15 +5,15 @@ DEFAULT: NULL --DESCRIPTION--

          - If HTML Purifier's attribute set is unsatisfactory, overload it! - The syntax is "tag.attr" or "*.attr" for the global attributes + If HTML Purifier's attribute set is unsatisfactory, overload it! + The syntax is "tag.attr" or "*.attr" for the global attributes (style, id, class, dir, lang, xml:lang).

          - Warning: If another directive conflicts with the - elements here, that directive will win and override. For - example, %HTML.EnableAttrID will take precedence over *.id in this - directive. You must set that directive to true before you can use - IDs at all. + Warning: If another directive conflicts with the + elements here, that directive will win and override. For + example, %HTML.EnableAttrID will take precedence over *.id in this + directive. You must set that directive to true before you can use + IDs at all.

          diff --git a/library/HTMLPurifier/ConfigSchema/schema/HTML.AllowedElements.txt b/library/HTMLPurifier/ConfigSchema/schema/HTML.AllowedElements.txt index b667b3da..336d5e41 100644 --- a/library/HTMLPurifier/ConfigSchema/schema/HTML.AllowedElements.txt +++ b/library/HTMLPurifier/ConfigSchema/schema/HTML.AllowedElements.txt @@ -4,15 +4,15 @@ VERSION: 1.3.0 DEFAULT: NULL --DESCRIPTION--

          - If HTML Purifier's tag set is unsatisfactory for your needs, you - can overload it with your own list of tags to allow. Note that this - method is subtractive: it does its job by taking away from HTML Purifier - usual feature set, so you cannot add a tag that HTML Purifier never - supported in the first place (like embed, form or head). If you + If HTML Purifier's tag set is unsatisfactory for your needs, you + can overload it with your own list of tags to allow. Note that this + method is subtractive: it does its job by taking away from HTML Purifier + usual feature set, so you cannot add a tag that HTML Purifier never + supported in the first place (like embed, form or head). If you change this, you probably also want to change %HTML.AllowedAttributes.

          - Warning: If another directive conflicts with the - elements here, that directive will win and override. + Warning: If another directive conflicts with the + elements here, that directive will win and override.

          diff --git a/library/HTMLPurifier/ConfigSchema/schema/HTML.AllowedModules.txt b/library/HTMLPurifier/ConfigSchema/schema/HTML.AllowedModules.txt index 85e39f76..cdd78270 100644 --- a/library/HTMLPurifier/ConfigSchema/schema/HTML.AllowedModules.txt +++ b/library/HTMLPurifier/ConfigSchema/schema/HTML.AllowedModules.txt @@ -15,6 +15,6 @@ DEFAULT: NULL If you specify a module that does not exist, the manager will silently fail to use it, so be careful! User-defined modules are not affected by this directive. Modules defined in %HTML.CoreModules are not - affected by this directive. + affected by this directive.

          diff --git a/library/HTMLPurifier/ConfigSchema/schema/HTML.BlockWrapper.txt b/library/HTMLPurifier/ConfigSchema/schema/HTML.BlockWrapper.txt index e12edb64..d4cfe854 100644 --- a/library/HTMLPurifier/ConfigSchema/schema/HTML.BlockWrapper.txt +++ b/library/HTMLPurifier/ConfigSchema/schema/HTML.BlockWrapper.txt @@ -13,6 +13,6 @@ DEFAULT: 'p' <blockquote>Foo</blockquote> would become <blockquote><p>Foo</p></blockquote>. The <p> tags can be replaced with whatever you desire, - as long as it is a block level element. + as long as it is a block level element.

          diff --git a/library/HTMLPurifier/ConfigSchema/schema/HTML.CoreModules.txt b/library/HTMLPurifier/ConfigSchema/schema/HTML.CoreModules.txt index c629f66b..43458628 100644 --- a/library/HTMLPurifier/ConfigSchema/schema/HTML.CoreModules.txt +++ b/library/HTMLPurifier/ConfigSchema/schema/HTML.CoreModules.txt @@ -18,6 +18,6 @@ array ( that must be included for the doctype to be an conforming document type: put those modules here. By default, XHTML's core modules are used. You can set this to a blank array to disable core module - protection, but this is not recommended. + protection, but this is not recommended.

          diff --git a/library/HTMLPurifier/ConfigSchema/schema/HTML.DefinitionRev.txt b/library/HTMLPurifier/ConfigSchema/schema/HTML.DefinitionRev.txt index bc084fa3..e241537a 100644 --- a/library/HTMLPurifier/ConfigSchema/schema/HTML.DefinitionRev.txt +++ b/library/HTMLPurifier/ConfigSchema/schema/HTML.DefinitionRev.txt @@ -11,6 +11,6 @@ DEFAULT: 1 context: revision 3 is more up-to-date then revision 2. Thus, when this gets incremented, the cache handling is smart enough to clean up any older revisions of your definition as well as flush the - cache. + cache.

          diff --git a/library/HTMLPurifier/ConfigSchema/schema/HTML.Parent.txt b/library/HTMLPurifier/ConfigSchema/schema/HTML.Parent.txt index ecc2f77b..28105d9c 100644 --- a/library/HTMLPurifier/ConfigSchema/schema/HTML.Parent.txt +++ b/library/HTMLPurifier/ConfigSchema/schema/HTML.Parent.txt @@ -5,8 +5,8 @@ DEFAULT: 'div' --DESCRIPTION--

          - String name of element that HTML fragment passed to library will be - inserted in. An interesting variation would be using span as the - parent element, meaning that only inline tags would be allowed. + String name of element that HTML fragment passed to library will be + inserted in. An interesting variation would be using span as the + parent element, meaning that only inline tags would be allowed.

          diff --git a/library/HTMLPurifier/ConfigSchema/schema/HTML.SafeObject.txt b/library/HTMLPurifier/ConfigSchema/schema/HTML.SafeObject.txt index 6270abea..4e9d9d23 100644 --- a/library/HTMLPurifier/ConfigSchema/schema/HTML.SafeObject.txt +++ b/library/HTMLPurifier/ConfigSchema/schema/HTML.SafeObject.txt @@ -6,7 +6,7 @@ DEFAULT: false

          Whether or not to permit object tags in documents, with a number of extra security features added to prevent script execution. This is similar to - what websites like MySpace do to object tags. You may also want to + what websites like MySpace do to object tags. You may also want to enable %HTML.SafeEmbed for maximum interoperability with Internet Explorer, although embed tags will cause your website to stop validating. Highly experimental. diff --git a/library/HTMLPurifier/ConfigSchema/schema/HTML.TidyAdd.txt b/library/HTMLPurifier/ConfigSchema/schema/HTML.TidyAdd.txt index 7fadf06c..fca9c804 100644 --- a/library/HTMLPurifier/ConfigSchema/schema/HTML.TidyAdd.txt +++ b/library/HTMLPurifier/ConfigSchema/schema/HTML.TidyAdd.txt @@ -4,5 +4,5 @@ VERSION: 2.0.0 DEFAULT: array() --DESCRIPTION-- -Fixes to add to the default set of Tidy fixes as per your level. +Fixes to add to the default set of Tidy fixes as per your level. diff --git a/library/HTMLPurifier/ConfigSchema/schema/HTML.TidyRemove.txt b/library/HTMLPurifier/ConfigSchema/schema/HTML.TidyRemove.txt index 4717f39f..22704c33 100644 --- a/library/HTMLPurifier/ConfigSchema/schema/HTML.TidyRemove.txt +++ b/library/HTMLPurifier/ConfigSchema/schema/HTML.TidyRemove.txt @@ -4,5 +4,5 @@ VERSION: 2.0.0 DEFAULT: array() --DESCRIPTION-- -Fixes to remove from the default set of Tidy fixes as per your level. +Fixes to remove from the default set of Tidy fixes as per your level. diff --git a/library/HTMLPurifier/ConfigSchema/schema/HTML.Trusted.txt b/library/HTMLPurifier/ConfigSchema/schema/HTML.Trusted.txt index 6a4015e7..0bd414aa 100644 --- a/library/HTMLPurifier/ConfigSchema/schema/HTML.Trusted.txt +++ b/library/HTMLPurifier/ConfigSchema/schema/HTML.Trusted.txt @@ -4,4 +4,4 @@ VERSION: 2.0.0 DEFAULT: false --DESCRIPTION-- Indicates whether or not the user input is trusted or not. If the input is -trusted, a more expansive set of allowed tags and attributes will be used. +trusted, a more expansive set of allowed tags and attributes will be used. diff --git a/library/HTMLPurifier/ConfigSchema/schema/Output.CommentScriptContents.txt b/library/HTMLPurifier/ConfigSchema/schema/Output.CommentScriptContents.txt index 5a77edb4..90a3e874 100644 --- a/library/HTMLPurifier/ConfigSchema/schema/Output.CommentScriptContents.txt +++ b/library/HTMLPurifier/ConfigSchema/schema/Output.CommentScriptContents.txt @@ -4,6 +4,6 @@ VERSION: 2.0.0 DEFAULT: true --DESCRIPTION-- Determines whether or not HTML Purifier should attempt to fix up the -contents of script tags for legacy browsers with comments. +contents of script tags for legacy browsers with comments. --ALIASES-- Core.CommentScriptContents diff --git a/library/HTMLPurifier/ConfigSchema/schema/Output.Newline.txt b/library/HTMLPurifier/ConfigSchema/schema/Output.Newline.txt index 2dd17999..6d4ca3e6 100644 --- a/library/HTMLPurifier/ConfigSchema/schema/Output.Newline.txt +++ b/library/HTMLPurifier/ConfigSchema/schema/Output.Newline.txt @@ -8,6 +8,6 @@ DEFAULT: NULL Newline string to format final output with. If left null, HTML Purifier will auto-detect the default newline type of the system and use that; you can manually override it here. Remember, \r\n is Windows, \r - is Mac, and \n is Unix. + is Mac, and \n is Unix.

          diff --git a/library/HTMLPurifier/ConfigSchema/schema/Output.TidyFormat.txt b/library/HTMLPurifier/ConfigSchema/schema/Output.TidyFormat.txt index 6d26c4de..8c005ca9 100644 --- a/library/HTMLPurifier/ConfigSchema/schema/Output.TidyFormat.txt +++ b/library/HTMLPurifier/ConfigSchema/schema/Output.TidyFormat.txt @@ -4,7 +4,7 @@ VERSION: 1.1.1 DEFAULT: false --DESCRIPTION--

          - Determines whether or not to run Tidy on the final output for pretty + Determines whether or not to run Tidy on the final output for pretty formatting reasons, such as indentation and wrap.

          diff --git a/library/HTMLPurifier/ConfigSchema/schema/URI.Base.txt b/library/HTMLPurifier/ConfigSchema/schema/URI.Base.txt index f68b8259..04187ef7 100644 --- a/library/HTMLPurifier/ConfigSchema/schema/URI.Base.txt +++ b/library/HTMLPurifier/ConfigSchema/schema/URI.Base.txt @@ -9,9 +9,9 @@ DEFAULT: NULL inserted into. This information is important if HTML Purifier needs to calculate absolute URIs from relative URIs, such as when %URI.MakeAbsolute is on. You may use a non-absolute URI for this value, but behavior - may vary (%URI.MakeAbsolute deals nicely with both absolute and + may vary (%URI.MakeAbsolute deals nicely with both absolute and relative paths, but forwards-compatibility is not guaranteed). Warning: If set, the scheme on this URI - overrides the one specified by %URI.DefaultScheme. + overrides the one specified by %URI.DefaultScheme.

          diff --git a/library/HTMLPurifier/ConfigSchema/schema/URI.DefaultScheme.txt b/library/HTMLPurifier/ConfigSchema/schema/URI.DefaultScheme.txt index ba472eda..6fb7602f 100644 --- a/library/HTMLPurifier/ConfigSchema/schema/URI.DefaultScheme.txt +++ b/library/HTMLPurifier/ConfigSchema/schema/URI.DefaultScheme.txt @@ -4,7 +4,7 @@ DEFAULT: 'http' --DESCRIPTION--

          - Defines through what scheme the output will be served, in order to + Defines through what scheme the output will be served, in order to select the proper object validator when no scheme information is present.

          diff --git a/library/HTMLPurifier/ConfigSchema/schema/URI.DefinitionRev.txt b/library/HTMLPurifier/ConfigSchema/schema/URI.DefinitionRev.txt index 9049897b..1a0bb8ba 100644 --- a/library/HTMLPurifier/ConfigSchema/schema/URI.DefinitionRev.txt +++ b/library/HTMLPurifier/ConfigSchema/schema/URI.DefinitionRev.txt @@ -6,6 +6,6 @@ DEFAULT: 1

          Revision identifier for your custom definition. See - %HTML.DefinitionRev for details. + %HTML.DefinitionRev for details.

          diff --git a/library/HTMLPurifier/ConfigSchema/schema/URI.Disable.txt b/library/HTMLPurifier/ConfigSchema/schema/URI.Disable.txt index 85fe3df1..a7977d3e 100644 --- a/library/HTMLPurifier/ConfigSchema/schema/URI.Disable.txt +++ b/library/HTMLPurifier/ConfigSchema/schema/URI.Disable.txt @@ -5,8 +5,8 @@ DEFAULT: false --DESCRIPTION--

          - Disables all URIs in all forms. Not sure why you'd want to do that - (after all, the Internet's founded on the notion of a hyperlink). + Disables all URIs in all forms. Not sure why you'd want to do that + (after all, the Internet's founded on the notion of a hyperlink).

          --ALIASES-- diff --git a/library/HTMLPurifier/ConfigSchema/schema/URI.DisableExternal.txt b/library/HTMLPurifier/ConfigSchema/schema/URI.DisableExternal.txt index 5f9dc31f..c6635809 100644 --- a/library/HTMLPurifier/ConfigSchema/schema/URI.DisableExternal.txt +++ b/library/HTMLPurifier/ConfigSchema/schema/URI.DisableExternal.txt @@ -7,4 +7,4 @@ Disables links to external websites. This is a highly effective anti-spam and anti-pagerank-leech measure, but comes at a hefty price: nolinks or images outside of your domain will be allowed. Non-linkified URIs will still be preserved. If you want to be able to link to subdomains or use -absolute URIs, specify %URI.Host for your website. +absolute URIs, specify %URI.Host for your website. diff --git a/library/HTMLPurifier/ConfigSchema/schema/URI.DisableExternalResources.txt b/library/HTMLPurifier/ConfigSchema/schema/URI.DisableExternalResources.txt index af43b614..27180a23 100644 --- a/library/HTMLPurifier/ConfigSchema/schema/URI.DisableExternalResources.txt +++ b/library/HTMLPurifier/ConfigSchema/schema/URI.DisableExternalResources.txt @@ -9,4 +9,4 @@ tracking (good for email viewers), bandwidth leeching, cross-site request forging, goatse.cx posting, and other nasties, but also results in a loss of end-user functionality (they can't directly post a pic they posted from Flickr anymore). Use it if you don't have a robust user-content moderation -team. +team. diff --git a/library/HTMLPurifier/ConfigSchema/schema/URI.DisableResources.txt b/library/HTMLPurifier/ConfigSchema/schema/URI.DisableResources.txt index 2f4e5741..8c41134a 100644 --- a/library/HTMLPurifier/ConfigSchema/schema/URI.DisableResources.txt +++ b/library/HTMLPurifier/ConfigSchema/schema/URI.DisableResources.txt @@ -6,7 +6,7 @@ DEFAULT: false

          Disables embedding resources, essentially meaning no pictures. You can - still link to them though. See %URI.DisableExternalResources for why - this might be a good idea. + still link to them though. See %URI.DisableExternalResources for why + this might be a good idea.

          diff --git a/library/HTMLPurifier/ConfigSchema/schema/URI.Host.txt b/library/HTMLPurifier/ConfigSchema/schema/URI.Host.txt index 48159407..408c03cf 100644 --- a/library/HTMLPurifier/ConfigSchema/schema/URI.Host.txt +++ b/library/HTMLPurifier/ConfigSchema/schema/URI.Host.txt @@ -5,13 +5,13 @@ DEFAULT: NULL --DESCRIPTION--

          - Defines the domain name of the server, so we can determine whether or - an absolute URI is from your website or not. Not strictly necessary, - as users should be using relative URIs to reference resources on your - website. It will, however, let you use absolute URIs to link to - subdomains of the domain you post here: i.e. example.com will allow - sub.example.com. However, higher up domains will still be excluded: - if you set %URI.Host to sub.example.com, example.com will be blocked. + Defines the domain name of the server, so we can determine whether or + an absolute URI is from your website or not. Not strictly necessary, + as users should be using relative URIs to reference resources on your + website. It will, however, let you use absolute URIs to link to + subdomains of the domain you post here: i.e. example.com will allow + sub.example.com. However, higher up domains will still be excluded: + if you set %URI.Host to sub.example.com, example.com will be blocked. Note: This directive overrides %URI.Base because a given page may be on a sub-domain, but you wish HTML Purifier to be more relaxed and allow some of the parent domains too. diff --git a/library/HTMLPurifier/ConfigSchema/schema/URI.HostBlacklist.txt b/library/HTMLPurifier/ConfigSchema/schema/URI.HostBlacklist.txt index a62a3543..dbd680f5 100644 --- a/library/HTMLPurifier/ConfigSchema/schema/URI.HostBlacklist.txt +++ b/library/HTMLPurifier/ConfigSchema/schema/URI.HostBlacklist.txt @@ -5,4 +5,4 @@ DEFAULT: array() --DESCRIPTION-- List of strings that are forbidden in the host of any URI. Use it to kill domain names of spam, etc. Note that it will catch anything in the domain, -so moo.com will catch moo.com.example.com. +so moo.com will catch moo.com.example.com. diff --git a/library/HTMLPurifier/ConfigSchema/schema/URI.Munge.txt b/library/HTMLPurifier/ConfigSchema/schema/URI.Munge.txt index ed9e142d..c68d689b 100644 --- a/library/HTMLPurifier/ConfigSchema/schema/URI.Munge.txt +++ b/library/HTMLPurifier/ConfigSchema/schema/URI.Munge.txt @@ -7,8 +7,8 @@ DEFAULT: NULL

          Munges all browsable (usually http, https and ftp) absolute URIs into another URI, usually a URI redirection service. - This directive accepts a URI, formatted with a %s where - the url-encoded original URI should be inserted (sample: + This directive accepts a URI, formatted with a %s where + the url-encoded original URI should be inserted (sample: http://www.google.com/url?q=%s).

          @@ -16,10 +16,10 @@ DEFAULT: NULL

          • - Prevent PageRank leaks, while being fairly transparent - to users (you may also want to add some client side JavaScript to + Prevent PageRank leaks, while being fairly transparent + to users (you may also want to add some client side JavaScript to override the text in the statusbar). Notice: - Many security experts believe that this form of protection does not deter spam-bots. + Many security experts believe that this form of protection does not deter spam-bots.
          • Redirect users to a splash page telling them they are leaving your diff --git a/library/HTMLPurifier/ContentSets.php b/library/HTMLPurifier/ContentSets.php index 15c8d97f..1f665905 100644 --- a/library/HTMLPurifier/ContentSets.php +++ b/library/HTMLPurifier/ContentSets.php @@ -5,18 +5,18 @@ */ class HTMLPurifier_ContentSets { - + /** * List of content set strings (pipe seperators) indexed by name. */ public $info = array(); - + /** * List of content set lookups (element => true) indexed by name. * @note This is in HTMLPurifier_HTMLDefinition->info_content_sets */ public $lookup = array(); - + /** * Synchronized list of defined content sets (keys of info) */ @@ -25,7 +25,7 @@ class HTMLPurifier_ContentSets * Synchronized list of defined content values (values of info) */ protected $values = array(); - + /** * Merges in module's content sets, expands identifiers in the content * sets and populates the keys, values and lookup member variables. @@ -60,14 +60,14 @@ class HTMLPurifier_ContentSets $this->lookup[$i] += $add; } } - + foreach ($this->lookup as $key => $lookup) { $this->info[$key] = implode(' | ', array_keys($lookup)); } $this->keys = array_keys($this->info); $this->values = array_values($this->info); } - + /** * Accepts a definition; generates and assigns a ChildDef for it * @param $def HTMLPurifier_ElementDef reference @@ -88,11 +88,11 @@ class HTMLPurifier_ContentSets } $def->child = $this->getChildDef($def, $module); } - + public function generateChildDefCallback($matches) { return $this->info[$matches[0]]; } - + /** * Instantiates a ChildDef based on content_model and content_model_type * member variables in HTMLPurifier_ElementDef @@ -134,7 +134,7 @@ class HTMLPurifier_ContentSets ); return false; } - + /** * Converts a string list of elements separated by pipes into * a lookup array. @@ -149,6 +149,6 @@ class HTMLPurifier_ContentSets } return $ret; } - + } diff --git a/library/HTMLPurifier/Context.php b/library/HTMLPurifier/Context.php index 151a68ed..2b9ec2b3 100644 --- a/library/HTMLPurifier/Context.php +++ b/library/HTMLPurifier/Context.php @@ -9,12 +9,12 @@ */ class HTMLPurifier_Context { - + /** * Private array that stores the references. */ private $_storage = array(); - + /** * Registers a variable into the context. * @param $name String name @@ -28,7 +28,7 @@ class HTMLPurifier_Context } $this->_storage[$name] =& $ref; } - + /** * Retrieves a variable reference from the context. * @param $name String name @@ -45,7 +45,7 @@ class HTMLPurifier_Context } return $this->_storage[$name]; } - + /** * Destorys a variable in the context. * @param $name String name @@ -58,7 +58,7 @@ class HTMLPurifier_Context } unset($this->_storage[$name]); } - + /** * Checks whether or not the variable exists. * @param $name String name @@ -66,7 +66,7 @@ class HTMLPurifier_Context public function exists($name) { return isset($this->_storage[$name]); } - + /** * Loads a series of variables from an associative array * @param $context_array Assoc array of variables to load @@ -76,6 +76,6 @@ class HTMLPurifier_Context $this->register($key, $context_array[$key]); } } - + } diff --git a/library/HTMLPurifier/Definition.php b/library/HTMLPurifier/Definition.php index 7de8b73d..71068efa 100644 --- a/library/HTMLPurifier/Definition.php +++ b/library/HTMLPurifier/Definition.php @@ -6,24 +6,24 @@ */ abstract class HTMLPurifier_Definition { - + /** * Has setup() been called yet? */ public $setup = false; - + /** * What type of definition is it? */ public $type; - + /** * Sets up the definition object into the final form, something * not done by the constructor * @param $config HTMLPurifier_Config instance */ abstract protected function doSetup($config); - + /** * Setup function that aborts if already setup * @param $config HTMLPurifier_Config instance @@ -33,6 +33,6 @@ abstract class HTMLPurifier_Definition $this->setup = true; $this->doSetup($config); } - + } diff --git a/library/HTMLPurifier/DefinitionCache.php b/library/HTMLPurifier/DefinitionCache.php index f81af0c5..f799a745 100644 --- a/library/HTMLPurifier/DefinitionCache.php +++ b/library/HTMLPurifier/DefinitionCache.php @@ -10,9 +10,9 @@ */ abstract class HTMLPurifier_DefinitionCache { - + public $type; - + /** * @param $name Type of definition objects this instance of the * cache will handle. @@ -20,7 +20,7 @@ abstract class HTMLPurifier_DefinitionCache public function __construct($type) { $this->type = $type; } - + /** * Generates a unique identifier for a particular configuration * @param Instance of HTMLPurifier_Config @@ -30,7 +30,7 @@ abstract class HTMLPurifier_DefinitionCache $config->getBatchSerial($this->type) . ',' . $config->get($this->type, 'DefinitionRev'); } - + /** * Tests whether or not a key is old with respect to the configuration's * version and revision number. @@ -50,7 +50,7 @@ abstract class HTMLPurifier_DefinitionCache ) return true; return false; } - + /** * Checks if a definition's type jives with the cache's type * @note Throws an error on failure @@ -64,37 +64,37 @@ abstract class HTMLPurifier_DefinitionCache } return true; } - + /** * Adds a definition object to the cache */ abstract public function add($def, $config); - + /** * Unconditionally saves a definition object to the cache */ abstract public function set($def, $config); - + /** * Replace an object in the cache */ abstract public function replace($def, $config); - + /** * Retrieves a definition object from the cache */ abstract public function get($config); - + /** * Removes a definition object to the cache */ abstract public function remove($config); - + /** * Clears all objects from cache */ abstract public function flush($config); - + /** * Clears all expired (older version or revision) objects from cache * @note Be carefuly implementing this method as flush. Flush must @@ -102,6 +102,6 @@ abstract class HTMLPurifier_DefinitionCache * should not be repeatedly called by userland code. */ abstract public function cleanup($config); - + } diff --git a/library/HTMLPurifier/DefinitionCache/Decorator.php b/library/HTMLPurifier/DefinitionCache/Decorator.php index 39eb474f..3fdac0a7 100644 --- a/library/HTMLPurifier/DefinitionCache/Decorator.php +++ b/library/HTMLPurifier/DefinitionCache/Decorator.php @@ -2,14 +2,14 @@ class HTMLPurifier_DefinitionCache_Decorator extends HTMLPurifier_DefinitionCache { - + /** * Cache object we are decorating */ public $cache; - + public function __construct() {} - + /** * Lazy decorator function * @param $cache Reference to cache object to decorate @@ -21,41 +21,41 @@ class HTMLPurifier_DefinitionCache_Decorator extends HTMLPurifier_DefinitionCach $decorator->type = $cache->type; return $decorator; } - + /** * Cross-compatible clone substitute */ public function copy() { return new HTMLPurifier_DefinitionCache_Decorator(); } - + public function add($def, $config) { return $this->cache->add($def, $config); } - + public function set($def, $config) { return $this->cache->set($def, $config); } - + public function replace($def, $config) { return $this->cache->replace($def, $config); } - + public function get($config) { return $this->cache->get($config); } - + public function remove($config) { return $this->cache->remove($config); } - + public function flush($config) { return $this->cache->flush($config); } - + public function cleanup($config) { return $this->cache->cleanup($config); } - + } diff --git a/library/HTMLPurifier/DefinitionCache/Decorator/Cleanup.php b/library/HTMLPurifier/DefinitionCache/Decorator/Cleanup.php index 842382e4..0652106c 100644 --- a/library/HTMLPurifier/DefinitionCache/Decorator/Cleanup.php +++ b/library/HTMLPurifier/DefinitionCache/Decorator/Cleanup.php @@ -7,36 +7,36 @@ class HTMLPurifier_DefinitionCache_Decorator_Cleanup extends HTMLPurifier_DefinitionCache_Decorator { - + public $name = 'Cleanup'; - + public function copy() { return new HTMLPurifier_DefinitionCache_Decorator_Cleanup(); } - + public function add($def, $config) { $status = parent::add($def, $config); if (!$status) parent::cleanup($config); return $status; } - + public function set($def, $config) { $status = parent::set($def, $config); if (!$status) parent::cleanup($config); return $status; } - + public function replace($def, $config) { $status = parent::replace($def, $config); if (!$status) parent::cleanup($config); return $status; } - + public function get($config) { $ret = parent::get($config); if (!$ret) parent::cleanup($config); return $ret; } - + } diff --git a/library/HTMLPurifier/DefinitionCache/Decorator/Memory.php b/library/HTMLPurifier/DefinitionCache/Decorator/Memory.php index 83ed2c03..c1407c21 100644 --- a/library/HTMLPurifier/DefinitionCache/Decorator/Memory.php +++ b/library/HTMLPurifier/DefinitionCache/Decorator/Memory.php @@ -2,44 +2,44 @@ /** * Definition cache decorator class that saves all cache retrievals - * to PHP's memory; good for unit tests or circumstances where + * to PHP's memory; good for unit tests or circumstances where * there are lots of configuration objects floating around. */ class HTMLPurifier_DefinitionCache_Decorator_Memory extends HTMLPurifier_DefinitionCache_Decorator { - + protected $definitions; public $name = 'Memory'; - + public function copy() { return new HTMLPurifier_DefinitionCache_Decorator_Memory(); } - + public function add($def, $config) { $status = parent::add($def, $config); if ($status) $this->definitions[$this->generateKey($config)] = $def; return $status; } - + public function set($def, $config) { $status = parent::set($def, $config); if ($status) $this->definitions[$this->generateKey($config)] = $def; return $status; } - + public function replace($def, $config) { $status = parent::replace($def, $config); if ($status) $this->definitions[$this->generateKey($config)] = $def; return $status; } - + public function get($config) { $key = $this->generateKey($config); if (isset($this->definitions[$key])) return $this->definitions[$key]; $this->definitions[$key] = parent::get($config); return $this->definitions[$key]; } - + } diff --git a/library/HTMLPurifier/DefinitionCache/Decorator/Template.php.in b/library/HTMLPurifier/DefinitionCache/Decorator/Template.php.in index d741764c..ba141434 100644 --- a/library/HTMLPurifier/DefinitionCache/Decorator/Template.php.in +++ b/library/HTMLPurifier/DefinitionCache/Decorator/Template.php.in @@ -8,39 +8,39 @@ require_once 'HTMLPurifier/DefinitionCache/Decorator.php'; class HTMLPurifier_DefinitionCache_Decorator_Template extends HTMLPurifier_DefinitionCache_Decorator { - + var $name = 'Template'; // replace this - + function copy() { // replace class name with yours return new HTMLPurifier_DefinitionCache_Decorator_Template(); } - + // remove methods you don't need - + function add($def, $config) { return parent::add($def, $config); } - + function set($def, $config) { return parent::set($def, $config); } - + function replace($def, $config) { return parent::replace($def, $config); } - + function get($config) { return parent::get($config); } - + function flush() { return parent::flush(); } - + function cleanup($config) { return parent::cleanup($config); } - + } diff --git a/library/HTMLPurifier/DefinitionCache/Null.php b/library/HTMLPurifier/DefinitionCache/Null.php index 8e39e69d..6a0101cb 100644 --- a/library/HTMLPurifier/DefinitionCache/Null.php +++ b/library/HTMLPurifier/DefinitionCache/Null.php @@ -5,34 +5,34 @@ */ class HTMLPurifier_DefinitionCache_Null extends HTMLPurifier_DefinitionCache { - + public function add($def, $config) { return false; } - + public function set($def, $config) { return false; } - + public function replace($def, $config) { return false; } - + public function remove($config) { return false; } - + public function get($config) { return false; } - + public function flush($config) { return false; } - + public function cleanup($config) { return false; } - + } diff --git a/library/HTMLPurifier/DefinitionCache/Serializer.php b/library/HTMLPurifier/DefinitionCache/Serializer.php index ef082217..eba9f7d0 100644 --- a/library/HTMLPurifier/DefinitionCache/Serializer.php +++ b/library/HTMLPurifier/DefinitionCache/Serializer.php @@ -3,7 +3,7 @@ class HTMLPurifier_DefinitionCache_Serializer extends HTMLPurifier_DefinitionCache { - + public function add($def, $config) { if (!$this->checkDefType($def)) return; $file = $this->generateFilePath($config); @@ -11,14 +11,14 @@ class HTMLPurifier_DefinitionCache_Serializer extends if (!$this->_prepareDir($config)) return false; return $this->_write($file, serialize($def)); } - + public function set($def, $config) { if (!$this->checkDefType($def)) return; $file = $this->generateFilePath($config); if (!$this->_prepareDir($config)) return false; return $this->_write($file, serialize($def)); } - + public function replace($def, $config) { if (!$this->checkDefType($def)) return; $file = $this->generateFilePath($config); @@ -26,19 +26,19 @@ class HTMLPurifier_DefinitionCache_Serializer extends if (!$this->_prepareDir($config)) return false; return $this->_write($file, serialize($def)); } - + public function get($config) { $file = $this->generateFilePath($config); if (!file_exists($file)) return false; return unserialize(file_get_contents($file)); } - + public function remove($config) { $file = $this->generateFilePath($config); if (!file_exists($file)) return false; return unlink($file); } - + public function flush($config) { if (!$this->_prepareDir($config)) return false; $dir = $this->generateDirectoryPath($config); @@ -49,7 +49,7 @@ class HTMLPurifier_DefinitionCache_Serializer extends unlink($dir . '/' . $filename); } } - + public function cleanup($config) { if (!$this->_prepareDir($config)) return false; $dir = $this->generateDirectoryPath($config); @@ -61,7 +61,7 @@ class HTMLPurifier_DefinitionCache_Serializer extends if ($this->isOld($key, $config)) unlink($dir . '/' . $filename); } } - + /** * Generates the file path to the serial file corresponding to * the configuration and definition name @@ -71,7 +71,7 @@ class HTMLPurifier_DefinitionCache_Serializer extends $key = $this->generateKey($config); return $this->generateDirectoryPath($config) . '/' . $key . '.ser'; } - + /** * Generates the path to the directory contain this cache's serial files * @note No trailing slash @@ -81,7 +81,7 @@ class HTMLPurifier_DefinitionCache_Serializer extends $base = $this->generateBaseDirectoryPath($config); return $base . '/' . $this->type; } - + /** * Generates path to base directory that contains all definition type * serials @@ -92,7 +92,7 @@ class HTMLPurifier_DefinitionCache_Serializer extends $base = is_null($base) ? HTMLPURIFIER_PREFIX . '/HTMLPurifier/DefinitionCache/Serializer' : $base; return $base; } - + /** * Convenience wrapper function for file_put_contents * @param $file File name to write to @@ -102,7 +102,7 @@ class HTMLPurifier_DefinitionCache_Serializer extends private function _write($file, $data) { return file_put_contents($file, $data); } - + /** * Prepares the directory that this type stores the serials in * @return True if successful @@ -127,7 +127,7 @@ class HTMLPurifier_DefinitionCache_Serializer extends } return true; } - + /** * Tests permissions on a directory and throws out friendly * error messages and attempts to chmod it itself if possible @@ -166,6 +166,6 @@ class HTMLPurifier_DefinitionCache_Serializer extends } return false; } - + } diff --git a/library/HTMLPurifier/DefinitionCacheFactory.php b/library/HTMLPurifier/DefinitionCacheFactory.php index fca1b6c4..dae95350 100644 --- a/library/HTMLPurifier/DefinitionCacheFactory.php +++ b/library/HTMLPurifier/DefinitionCacheFactory.php @@ -5,18 +5,18 @@ */ class HTMLPurifier_DefinitionCacheFactory { - + protected $caches = array('Serializer' => array()); protected $implementations = array(); protected $decorators = array(); - + /** * Initialize default decorators */ public function setup() { $this->addDecorator('Cleanup'); } - + /** * Retrieves an instance of global definition cache factory. */ @@ -30,16 +30,16 @@ class HTMLPurifier_DefinitionCacheFactory } return $instance; } - + /** * Registers a new definition cache object * @param $short Short name of cache object, for reference - * @param $long Full class name of cache object, for construction + * @param $long Full class name of cache object, for construction */ public function register($short, $long) { $this->implementations[$short] = $long; } - + /** * Factory method that creates a cache object based on configuration * @param $name Name of definitions handled by cache @@ -73,10 +73,10 @@ class HTMLPurifier_DefinitionCacheFactory $this->caches[$method][$type] = $cache; return $this->caches[$method][$type]; } - + /** * Registers a decorator to add to all new cache objects - * @param + * @param */ public function addDecorator($decorator) { if (is_string($decorator)) { @@ -85,6 +85,6 @@ class HTMLPurifier_DefinitionCacheFactory } $this->decorators[$decorator->name] = $decorator; } - + } diff --git a/library/HTMLPurifier/Doctype.php b/library/HTMLPurifier/Doctype.php index 5e83a869..cfc6556a 100644 --- a/library/HTMLPurifier/Doctype.php +++ b/library/HTMLPurifier/Doctype.php @@ -12,38 +12,38 @@ class HTMLPurifier_Doctype * Full name of doctype */ public $name; - + /** * List of standard modules (string identifiers or literal objects) * that this doctype uses */ public $modules = array(); - + /** * List of modules to use for tidying up code */ public $tidyModules = array(); - + /** * Is the language derived from XML (i.e. XHTML)? */ public $xml = true; - + /** * List of aliases for this doctype */ public $aliases = array(); - + /** * Public DTD identifier */ public $dtdPublic; - + /** * System DTD identifier */ public $dtdSystem; - + public function __construct($name = null, $xml = true, $modules = array(), $tidyModules = array(), $aliases = array(), $dtd_public = null, $dtd_system = null ) { diff --git a/library/HTMLPurifier/DoctypeRegistry.php b/library/HTMLPurifier/DoctypeRegistry.php index 6c969efc..54b40701 100644 --- a/library/HTMLPurifier/DoctypeRegistry.php +++ b/library/HTMLPurifier/DoctypeRegistry.php @@ -2,17 +2,17 @@ class HTMLPurifier_DoctypeRegistry { - + /** * Hash of doctype names to doctype objects */ protected $doctypes; - + /** * Lookup table of aliases to real doctype names */ protected $aliases; - + /** * Registers a doctype to the registry * @note Accepts a fully-formed doctype object, or the @@ -45,7 +45,7 @@ class HTMLPurifier_DoctypeRegistry if (isset($this->aliases[$name])) unset($this->aliases[$name]); return $doctype; } - + /** * Retrieves reference to a doctype of a certain name * @note This function resolves aliases @@ -62,7 +62,7 @@ class HTMLPurifier_DoctypeRegistry } return $this->doctypes[$doctype]; } - + /** * Creates a doctype based on a configuration object, * will perform initialization on the doctype @@ -74,7 +74,7 @@ class HTMLPurifier_DoctypeRegistry public function make($config) { return clone $this->get($this->getDoctypeFromConfig($config)); } - + /** * Retrieves the doctype from the configuration object */ @@ -97,6 +97,6 @@ class HTMLPurifier_DoctypeRegistry } return $doctype; } - + } diff --git a/library/HTMLPurifier/ElementDef.php b/library/HTMLPurifier/ElementDef.php index 341ce349..d89c813e 100644 --- a/library/HTMLPurifier/ElementDef.php +++ b/library/HTMLPurifier/ElementDef.php @@ -8,13 +8,13 @@ */ class HTMLPurifier_ElementDef { - + /** * Does the definition work by itself, or is it created solely * for the purpose of merging into another definition? */ public $standalone = true; - + /** * Associative array of attribute name to HTMLPurifier_AttrDef * @note Before being processed by HTMLPurifier_AttrCollections @@ -27,22 +27,22 @@ class HTMLPurifier_ElementDef * HTMLPurifier_HTMLDefinition->setup() processing. */ public $attr = array(); - + /** * Indexed list of tag's HTMLPurifier_AttrTransform to be done before validation */ public $attr_transform_pre = array(); - + /** * Indexed list of tag's HTMLPurifier_AttrTransform to be done after validation */ public $attr_transform_post = array(); - + /** * HTMLPurifier_ChildDef of this tag. */ public $child; - + /** * Abstract string representation of internal ChildDef rules. See * HTMLPurifier_ContentSets for how this is parsed and then transformed @@ -51,7 +51,7 @@ class HTMLPurifier_ElementDef * being processed by HTMLDefinition */ public $content_model; - + /** * Value of $child->type, used to determine which ChildDef to use, * used in combination with $content_model. @@ -60,23 +60,23 @@ class HTMLPurifier_ElementDef * being processed by HTMLDefinition */ public $content_model_type; - - - + + + /** * Does the element have a content model (#PCDATA | Inline)*? This - * is important for chameleon ins and del processing in + * is important for chameleon ins and del processing in * HTMLPurifier_ChildDef_Chameleon. Dynamically set: modules don't * have to worry about this one. */ public $descendants_are_inline = false; - + /** * List of the names of required attributes this element has. Dynamically * populated by HTMLPurifier_HTMLDefinition::getElement */ public $required_attr = array(); - + /** * Lookup table of tags excluded from all descendants of this tag. * @note SGML permits exclusions for all descendants, but this is @@ -89,7 +89,7 @@ class HTMLPurifier_ElementDef * distinctions. */ public $excludes = array(); - + /** * Low-level factory constructor for creating new standalone element defs */ @@ -100,14 +100,14 @@ class HTMLPurifier_ElementDef $def->attr = $attr; return $def; } - + /** * Merges the values of another element definition into this one. * Values from the new element def take precedence if a value is * not mergeable. */ public function mergeIn($def) { - + // later keys takes precedence foreach($def->attr as $k => $v) { if ($k === 0) { @@ -127,7 +127,7 @@ class HTMLPurifier_ElementDef $this->_mergeAssocArray($this->attr_transform_pre, $def->attr_transform_pre); $this->_mergeAssocArray($this->attr_transform_post, $def->attr_transform_post); $this->_mergeAssocArray($this->excludes, $def->excludes); - + if(!empty($def->content_model)) { $this->content_model .= ' | ' . $def->content_model; $this->child = false; @@ -138,9 +138,9 @@ class HTMLPurifier_ElementDef } if(!is_null($def->child)) $this->child = $def->child; if($def->descendants_are_inline) $this->descendants_are_inline = $def->descendants_are_inline; - + } - + /** * Merges one array into another, removes values which equal false * @param $a1 Array by reference that is merged into @@ -155,7 +155,7 @@ class HTMLPurifier_ElementDef $a1[$k] = $v; } } - + } diff --git a/library/HTMLPurifier/Encoder.php b/library/HTMLPurifier/Encoder.php index 28259f23..6e9c5d48 100644 --- a/library/HTMLPurifier/Encoder.php +++ b/library/HTMLPurifier/Encoder.php @@ -6,31 +6,31 @@ */ class HTMLPurifier_Encoder { - + /** * Constructor throws fatal error if you attempt to instantiate class */ private function __construct() { trigger_error('Cannot instantiate encoder, call methods statically', E_USER_ERROR); } - + /** * Error-handler that mutes errors, alternative to shut-up operator. */ private static function muteErrorHandler() {} - + /** * Cleans a UTF-8 string for well-formedness and SGML validity - * + * * It will parse according to UTF-8 and return a valid UTF8 string, with * non-SGML codepoints excluded. - * + * * @note Just for reference, the non-SGML code points are 0 to 31 and * 127 to 159, inclusive. However, we allow code points 9, 10 * and 13, which are the tab, line feed and carriage return * respectively. 128 and above the code points map to multibyte * UTF-8 representations. - * + * * @note Fallback code adapted from utf8ToUnicode by Henri Sivonen and * hsivonen@iki.fi at under the * LGPL license. Notes on what changed are inside, but in general, @@ -45,7 +45,7 @@ class HTMLPurifier_Encoder * Once again, PHP 6 should solve all our problems. */ public static function cleanUTF8($str, $force_php = false) { - + // UTF-8 validity is checked since PHP 4.3.5 // This is an optimization: if the string is already valid UTF-8, no // need to do PHP stuff. 99% of the time, this will be the case. @@ -54,31 +54,31 @@ class HTMLPurifier_Encoder if (preg_match('/^[\x{9}\x{A}\x{D}\x{20}-\x{7E}\x{A0}-\x{D7FF}\x{E000}-\x{FFFD}\x{10000}-\x{10FFFF}]*$/Du', $str)) { return $str; } - + $mState = 0; // cached expected number of octets after the current octet // until the beginning of the next UTF8 character sequence $mUcs4 = 0; // cached Unicode character $mBytes = 1; // cached expected number of octets in the current sequence - + // original code involved an $out that was an array of Unicode // codepoints. Instead of having to convert back into UTF-8, we've // decided to directly append valid UTF-8 characters onto a string // $out once they're done. $char accumulates raw bytes, while $mUcs4 // turns into the Unicode code point, so there's some redundancy. - + $out = ''; $char = ''; - + $len = strlen($str); for($i = 0; $i < $len; $i++) { $in = ord($str{$i}); $char .= $str[$i]; // append byte to char if (0 == $mState) { - // When mState is zero we expect either a US-ASCII character + // When mState is zero we expect either a US-ASCII character // or a multi-octet sequence. if (0 == (0x80 & ($in))) { // US-ASCII, pass straight through. - if (($in <= 31 || $in == 127) && + if (($in <= 31 || $in == 127) && !($in == 9 || $in == 13 || $in == 10) // save \r\t\n ) { // control characters, remove @@ -108,12 +108,12 @@ class HTMLPurifier_Encoder $mBytes = 4; } elseif (0xF8 == (0xFC & ($in))) { // First octet of 5 octet sequence. - // - // This is illegal because the encoded codepoint must be + // + // This is illegal because the encoded codepoint must be // either: // (a) not the shortest form or // (b) outside the Unicode range of 0-0x10FFFF. - // Rather than trying to resynchronize, we will carry on + // Rather than trying to resynchronize, we will carry on // until the end of the sequence and let the later error // handling code catch it. $mUcs4 = ($in); @@ -128,7 +128,7 @@ class HTMLPurifier_Encoder $mState = 5; $mBytes = 6; } else { - // Current octet is neither in the US-ASCII range nor a + // Current octet is neither in the US-ASCII range nor a // legal first octet of a multi-octet sequence. $mState = 0; $mUcs4 = 0; @@ -144,13 +144,13 @@ class HTMLPurifier_Encoder $tmp = $in; $tmp = ($tmp & 0x0000003F) << $shift; $mUcs4 |= $tmp; - + if (0 == --$mState) { // End of the multi-octet sequence. mUcs4 now contains // the final Unicode codepoint to be output - + // Check for illegal sequences and codepoints. - + // From Unicode 3.1, non-shortest form is illegal if (((2 == $mBytes) && ($mUcs4 < 0x0080)) || ((3 == $mBytes) && ($mUcs4 < 0x0800)) || @@ -161,7 +161,7 @@ class HTMLPurifier_Encoder // Codepoints outside the Unicode range are illegal ($mUcs4 > 0x10FFFF) ) { - + } elseif (0xFEFF != $mUcs4 && // omit BOM // check for valid Char unicode codepoints ( @@ -196,7 +196,7 @@ class HTMLPurifier_Encoder } return $out; } - + /** * Translates a Unicode codepoint into its corresponding UTF-8 character. * @note Based on Feyd's function at @@ -209,7 +209,7 @@ class HTMLPurifier_Encoder * maintenance/generate-entity-file.php (although this is superior, * due to its sanity checks). */ - + // +----------+----------+----------+----------+ // | 33222222 | 22221111 | 111111 | | // | 10987654 | 32109876 | 54321098 | 76543210 | bit @@ -221,17 +221,17 @@ class HTMLPurifier_Encoder // +----------+----------+----------+----------+ // | 00000000 | 00011111 | 11111111 | 11111111 | Theoretical upper limit of legal scalars: 2097151 (0x001FFFFF) // | 00000000 | 00010000 | 11111111 | 11111111 | Defined upper limit of legal scalar codes - // +----------+----------+----------+----------+ - + // +----------+----------+----------+----------+ + public static function unichr($code) { if($code > 1114111 or $code < 0 or ($code >= 55296 and $code <= 57343) ) { // bits are set outside the "valid" range as defined - // by UNICODE 4.1.0 + // by UNICODE 4.1.0 return ''; } - - $x = $y = $z = $w = 0; + + $x = $y = $z = $w = 0; if ($code < 128) { // regular ASCII character $x = $code; @@ -248,18 +248,18 @@ class HTMLPurifier_Encoder $z = (($code >> 12) & 63) | 128; $w = (($code >> 18) & 7) | 240; } - } + } } // set up the actual character $ret = ''; if($w) $ret .= chr($w); if($z) $ret .= chr($z); if($y) $ret .= chr($y); - $ret .= chr($x); - + $ret .= chr($x); + return $ret; } - + /** * Converts a string to UTF-8 based on configuration. */ @@ -290,7 +290,7 @@ class HTMLPurifier_Encoder } trigger_error('Encoding not supported, please install iconv', E_USER_ERROR); } - + /** * Converts a string from UTF-8 based on configuration. * @note Currently, this is a lossy conversion, with unexpressable @@ -325,7 +325,7 @@ class HTMLPurifier_Encoder } trigger_error('Encoding not supported', E_USER_ERROR); } - + /** * Lossless (character-wise) conversion of HTML to ASCII * @param $str UTF-8 string to be converted to ASCII @@ -372,13 +372,13 @@ class HTMLPurifier_Encoder } return $result; } - + /** * This expensive function tests whether or not a given character * encoding supports ASCII. 7/8-bit encodings like Shift_JIS will * fail this test, and require special processing. Variable width * encodings shouldn't ever fail. - * + * * @param string $encoding Encoding name to test, as per iconv format * @param bool $bypass Whether or not to bypass the precompiled arrays. * @return Array of UTF-8 characters to their corresponding ASCII, @@ -419,7 +419,7 @@ class HTMLPurifier_Encoder $encodings[$encoding] = $ret; return $ret; } - - + + } diff --git a/library/HTMLPurifier/EntityLookup.php b/library/HTMLPurifier/EntityLookup.php index f9252a2e..0d52e916 100644 --- a/library/HTMLPurifier/EntityLookup.php +++ b/library/HTMLPurifier/EntityLookup.php @@ -4,12 +4,12 @@ * Object that provides entity lookup table from entity name to character */ class HTMLPurifier_EntityLookup { - + /** * Assoc array of entity name to character represented. */ public $table; - + /** * Sets up the entity lookup table from the serialized file contents. * @note The serialized contents are versioned, but were generated @@ -22,7 +22,7 @@ class HTMLPurifier_EntityLookup { } $this->table = unserialize(file_get_contents($file)); } - + /** * Retrieves sole instance of the object. * @param Optional prototype of custom lookup table to overload with. @@ -38,6 +38,6 @@ class HTMLPurifier_EntityLookup { } return $instance; } - + } diff --git a/library/HTMLPurifier/EntityParser.php b/library/HTMLPurifier/EntityParser.php index cb4c5082..6ca02aa9 100644 --- a/library/HTMLPurifier/EntityParser.php +++ b/library/HTMLPurifier/EntityParser.php @@ -9,20 +9,20 @@ */ class HTMLPurifier_EntityParser { - + /** * Reference to entity lookup table. */ protected $_entity_lookup; - + /** * Callback regex string for parsing entities. - */ + */ protected $_substituteEntitiesRegex = '/&(?:[#]x([a-fA-F0-9]+)|[#]0*(\d+)|([A-Za-z_:][A-Za-z0-9.\-_:]*));?/'; // 1. hex 2. dec 3. string (XML style) - - + + /** * Decimal to parsed string conversion table for special entities. */ @@ -34,7 +34,7 @@ class HTMLPurifier_EntityParser 60 => '<', 62 => '>' ); - + /** * Stripped entity names to decimal conversion table for special entities. */ @@ -45,12 +45,12 @@ class HTMLPurifier_EntityParser 'lt' => 60, 'gt' => 62 ); - + /** * Substitutes non-special entities with their parsed equivalents. Since * running this whenever you have parsed character is t3h 5uck, we run * it before everything else. - * + * * @param $string String to have non-special entities parsed. * @returns Parsed string. */ @@ -62,16 +62,16 @@ class HTMLPurifier_EntityParser $string ); } - + /** * Callback function for substituteNonSpecialEntities() that does the work. - * + * * @param $matches PCRE matches array, with 0 the entire match, and * either index 1, 2 or 3 set with a hex value, dec value, * or string (respectively). * @returns Replacement string. */ - + protected function nonSpecialEntityCallback($matches) { // replaces all but big five $entity = $matches[0]; @@ -79,10 +79,10 @@ class HTMLPurifier_EntityParser if ($is_num) { $is_hex = (@$entity[2] === 'x'); $code = $is_hex ? hexdec($matches[1]) : (int) $matches[2]; - + // abort for special characters if (isset($this->_special_dec2str[$code])) return $entity; - + return HTMLPurifier_Encoder::unichr($code); } else { if (isset($this->_special_ent2dec[$matches[3]])) return $entity; @@ -96,13 +96,13 @@ class HTMLPurifier_EntityParser } } } - + /** * Substitutes only special entities with their parsed equivalents. - * + * * @notice We try to avoid calling this function because otherwise, it * would have to be called a lot (for every parsed section). - * + * * @param $string String to have non-special entities parsed. * @returns Parsed string. */ @@ -112,12 +112,12 @@ class HTMLPurifier_EntityParser array($this, 'specialEntityCallback'), $string); } - + /** * Callback function for substituteSpecialEntities() that does the work. - * + * * This callback has same syntax as nonSpecialEntityCallback(). - * + * * @param $matches PCRE-style matches array, with 0 the entire match, and * either index 1, 2 or 3 set with a hex value, dec value, * or string (respectively). @@ -138,6 +138,6 @@ class HTMLPurifier_EntityParser $entity; } } - + } diff --git a/library/HTMLPurifier/ErrorCollector.php b/library/HTMLPurifier/ErrorCollector.php index 16cc89c6..1a1fa026 100644 --- a/library/HTMLPurifier/ErrorCollector.php +++ b/library/HTMLPurifier/ErrorCollector.php @@ -6,7 +6,7 @@ */ class HTMLPurifier_ErrorCollector { - + /** * Identifiers for the returned error array. These are purposely numeric * so list() can be used. @@ -15,23 +15,23 @@ class HTMLPurifier_ErrorCollector const SEVERITY = 1; const MESSAGE = 2; const CHILDREN = 3; - + protected $errors; protected $_current; protected $_stacks = array(array()); protected $locale; protected $generator; protected $context; - + protected $lines = array(); - + public function __construct($context) { $this->locale =& $context->get('Locale'); $this->context = $context; $this->_current =& $this->_stacks[0]; $this->errors =& $this->_stacks[0]; } - + /** * Sends an error message to the collector for later use * @param $severity int Error severity, PHP error style (don't use E_USER_) @@ -40,19 +40,19 @@ class HTMLPurifier_ErrorCollector * @param $subst2 string ... */ public function send($severity, $msg) { - + $args = array(); if (func_num_args() > 2) { $args = func_get_args(); array_shift($args); unset($args[0]); } - + $token = $this->context->get('CurrentToken', true); $line = $token ? $token->line : $this->context->get('CurrentLine', true); $col = $token ? $token->col : $this->context->get('CurrentCol', true); $attr = $this->context->get('CurrentAttr', true); - + // perform special substitutions, also add custom parameters $subst = array(); if (!is_null($token)) { @@ -62,15 +62,15 @@ class HTMLPurifier_ErrorCollector $subst['$CurrentAttr.Name'] = $attr; if (isset($token->attr[$attr])) $subst['$CurrentAttr.Value'] = $token->attr[$attr]; } - + if (empty($args)) { $msg = $this->locale->getMessage($msg); } else { $msg = $this->locale->formatMessage($msg, $args); } - + if (!empty($subst)) $msg = strtr($msg, $subst); - + // (numerically indexed) $error = array( self::LINENO => $line, @@ -79,10 +79,10 @@ class HTMLPurifier_ErrorCollector self::CHILDREN => array() ); $this->_current[] = $error; - - + + // NEW CODE BELOW ... - + $struct = null; // Top-level errors are either: // TOKEN type, if $value is set appropriately, or @@ -106,7 +106,7 @@ class HTMLPurifier_ErrorCollector } } ksort($this->lines, SORT_NUMERIC); - + // Now, check if we need to operate on a lower structure if (!empty($attr)) { $struct = $struct->getChild(HTMLPurifier_ErrorStruct::ATTR, $attr); @@ -121,11 +121,11 @@ class HTMLPurifier_ErrorCollector $struct->value = array($cssprop, 'PUT VALUE HERE'); } } - + // Ok, structs are all setup, now time to register the error $struct->addError($severity, $msg); } - + /** * Retrieves raw error data for custom formatter to use * @param List of arrays in format of array(line of error, @@ -135,7 +135,7 @@ class HTMLPurifier_ErrorCollector public function getRaw() { return $this->errors; } - + /** * Default HTML formatting implementation for error messages * @param $config Configuration array, vital for HTML output nature @@ -143,12 +143,12 @@ class HTMLPurifier_ErrorCollector */ public function getHTMLFormatted($config, $errors = null) { $ret = array(); - + $this->generator = new HTMLPurifier_Generator($config, $this->context); if ($errors === null) $errors = $this->errors; - + // 'At line' message needs to be removed - + // generation code for new structure goes here. It needs to be recursive. foreach ($this->lines as $line => $col_array) { if ($line == -1) continue; @@ -159,15 +159,15 @@ class HTMLPurifier_ErrorCollector if (isset($this->lines[-1])) { $this->_renderStruct($ret, $this->lines[-1]); } - + if (empty($errors)) { return '

            ' . $this->locale->getMessage('ErrorCollector: No errors') . '

            '; } else { return '
            • ' . implode('
            • ', $ret) . '
            '; } - + } - + private function _renderStruct(&$ret, $struct, $line = null, $col = null) { $stack = array($struct); $context_stack = array(array()); @@ -203,6 +203,6 @@ class HTMLPurifier_ErrorCollector } } } - + } diff --git a/library/HTMLPurifier/ErrorStruct.php b/library/HTMLPurifier/ErrorStruct.php index 9da712b7..9b323293 100644 --- a/library/HTMLPurifier/ErrorStruct.php +++ b/library/HTMLPurifier/ErrorStruct.php @@ -8,7 +8,7 @@ */ class HTMLPurifier_ErrorStruct { - + /** * Possible values for $children first-key. Note that top-level structures * are automatically token-level. @@ -16,12 +16,12 @@ class HTMLPurifier_ErrorStruct const TOKEN = 0; const ATTR = 1; const CSSPROP = 2; - + /** * Type of this struct. */ public $type; - + /** * Value of the struct we are recording errors for. There are various * values for this: @@ -30,19 +30,19 @@ class HTMLPurifier_ErrorStruct * - CSSPROP: array('prop-name', 'value') */ public $value; - + /** * Errors registered for this structure. */ public $errors = array(); - + /** * Child ErrorStructs that are from this structure. For example, a TOKEN * ErrorStruct would contain ATTR ErrorStructs. This is a multi-dimensional * array in structure: [TYPE]['identifier'] */ public $children = array(); - + public function getChild($type, $id) { if (!isset($this->children[$type][$id])) { $this->children[$type][$id] = new HTMLPurifier_ErrorStruct(); @@ -50,9 +50,9 @@ class HTMLPurifier_ErrorStruct } return $this->children[$type][$id]; } - + public function addError($severity, $message) { $this->errors[] = array($severity, $message); } - + } diff --git a/library/HTMLPurifier/Exception.php b/library/HTMLPurifier/Exception.php index d36d88e0..e0417d9f 100644 --- a/library/HTMLPurifier/Exception.php +++ b/library/HTMLPurifier/Exception.php @@ -6,6 +6,6 @@ */ class HTMLPurifier_Exception extends Exception { - + } diff --git a/library/HTMLPurifier/Filter.php b/library/HTMLPurifier/Filter.php index 61b9b0d6..3222eba8 100644 --- a/library/HTMLPurifier/Filter.php +++ b/library/HTMLPurifier/Filter.php @@ -2,44 +2,44 @@ /** * Represents a pre or post processing filter on HTML Purifier's output - * + * * Sometimes, a little ad-hoc fixing of HTML has to be done before * it gets sent through HTML Purifier: you can use filters to acheive * this effect. For instance, YouTube videos can be preserved using * this manner. You could have used a decorator for this task, but * PHP's support for them is not terribly robust, so we're going * to just loop through the filters. - * + * * Filters should be exited first in, last out. If there are three filters, * named 1, 2 and 3, the order of execution should go 1->preFilter, * 2->preFilter, 3->preFilter, purify, 3->postFilter, 2->postFilter, * 1->postFilter. - * + * * @note Methods are not declared abstract as it is perfectly legitimate * for an implementation not to want anything to happen on a step */ class HTMLPurifier_Filter { - + /** * Name of the filter for identification purposes */ public $name; - + /** - * Pre-processor function, handles HTML before HTML Purifier + * Pre-processor function, handles HTML before HTML Purifier */ public function preFilter($html, $config, $context) { return $html; } - + /** * Post-processor function, handles HTML after HTML Purifier */ public function postFilter($html, $config, $context) { return $html; } - + } diff --git a/library/HTMLPurifier/Filter/ExtractStyleBlocks.php b/library/HTMLPurifier/Filter/ExtractStyleBlocks.php index 438d7b79..84ce1e5d 100644 --- a/library/HTMLPurifier/Filter/ExtractStyleBlocks.php +++ b/library/HTMLPurifier/Filter/ExtractStyleBlocks.php @@ -4,11 +4,11 @@ * This filter extracts '; $js = $htmlpurifier_form->getJavaScript(); echo ''; - + $frm->show(); } function phorum_htmlpurifier_show_config_info() { global $PHORUM; - + // update mod_htmlpurifier for housekeeping phorum_htmlpurifier_commit_settings(); - + // politely tell user how to edit settings manually ?>
            How to edit settings for HTML Purifier module
            diff --git a/plugins/phorum/settings/migrate-sigs-form.php b/plugins/phorum/settings/migrate-sigs-form.php index ad4877b5..2800b7c3 100644 --- a/plugins/phorum/settings/migrate-sigs-form.php +++ b/plugins/phorum/settings/migrate-sigs-form.php @@ -1,7 +1,7 @@ hidden("module", "modsettings"); $frm->hidden("mod", "htmlpurifier"); diff --git a/plugins/phorum/settings/migrate-sigs.php b/plugins/phorum/settings/migrate-sigs.php index 700e9a9e..b337fc2b 100644 --- a/plugins/phorum/settings/migrate-sigs.php +++ b/plugins/phorum/settings/migrate-sigs.php @@ -19,14 +19,14 @@ function phorum_htmlpurifier_migrate_sigs_check() { function phorum_htmlpurifier_migrate_sigs($offset) { global $PHORUM; - + if(!$offset) return; // bail out quick if $offset == 0 - + // theoretically, we could get rid of this multi-request // doo-hickery if safe mode is off @set_time_limit(0); // attempt to let this run $increment = $PHORUM['mod_htmlpurifier']['migrate-sigs-increment']; - + require_once(dirname(__FILE__) . '/../migrate.php'); // migrate signatures // do this in batches so we don't run out of time/space @@ -51,13 +51,13 @@ function phorum_htmlpurifier_migrate_sigs($offset) { } } unset($userinfos); // free up memory - + // query for highest ID in database $type = $PHORUM['DBCONFIG']['type']; $sql = "select MAX(user_id) from {$PHORUM['user_table']}"; $row = phorum_db_interact(DB_RETURN_ROW, $sql); $top_id = (int) $row[0]; - + $offset += $increment; if ($offset > $top_id) { // test for end condition echo 'Migration finished'; @@ -71,5 +71,5 @@ function phorum_htmlpurifier_migrate_sigs($offset) { // relies on output buffering to work header("Location: http://$host$uri/$extra"); exit; - + } diff --git a/release1-update.php b/release1-update.php index 54574ce0..30448e70 100644 --- a/release1-update.php +++ b/release1-update.php @@ -9,7 +9,7 @@ if (php_sapi_name() != 'cli') { } if (!isset($argv[1])) { - echo + echo 'php release.php [version] HTML Purifier release script '; diff --git a/smoketests/all.php b/smoketests/all.php index b17ce22b..af641749 100644 --- a/smoketests/all.php +++ b/smoketests/all.php @@ -5,7 +5,7 @@ require_once 'common.php'; header('Content-type: text/html; charset=UTF-8'); echo ''; -?> diff --git a/smoketests/attrTransform.php b/smoketests/attrTransform.php index e1cf7a42..84d06498 100644 --- a/smoketests/attrTransform.php +++ b/smoketests/attrTransform.php @@ -2,7 +2,7 @@ require 'common.php'; -?> diff --git a/smoketests/attrTransform.xml b/smoketests/attrTransform.xml index ca0ee5b1..f08562fa 100644 --- a/smoketests/attrTransform.xml +++ b/smoketests/attrTransform.xml @@ -177,8 +177,8 @@
          • 1
          • 2
          ]]>
        • 1
        • 2
        • ]]>
          - - + + " ); } - + function test_generateFromTokens_Scripting_missingCloseTag() { $this->assertGeneration( array( @@ -183,7 +183,7 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness "" ); } - + function test_generateFromTokens_Scripting_disableWrapper() { $this->config->set('Output', 'CommentScriptContents', false); $this->assertGeneration( @@ -207,38 +207,38 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness "" ); } - + function test_generateFromTokens_XHTMLoff() { $this->config->set('HTML', 'XHTML', false); - + // omit trailing slash $this->assertGeneration( array( new HTMLPurifier_Token_Empty('br') ), '
          ' ); - + // there should be a test for attribute minimization, but it is // impossible for something like that to happen due to our current // definitions! fix it later - + // namespaced attributes must be dropped $this->assertGeneration( array( new HTMLPurifier_Token_Start('p', array('xml:lang'=>'fr')) ), '

          ' ); - + } - + function test_generateFromTokens_TidyFormat() { // abort test if tidy isn't loaded if (!extension_loaded('tidy')) return; - + // just don't test; Tidy is exploding on me. return; - + $this->config->set('Core', 'TidyFormat', true); $this->config->set('Output', 'Newline', "\n"); - + // nice wrapping please $this->assertGeneration( array( @@ -248,18 +248,18 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness ), "

          \n Text\n
          \n" ); - + } - + function test_generateFromTokens_sortAttr() { $this->config->set('Output', 'SortAttr', true); - + $this->assertGeneration( array( new HTMLPurifier_Token_Start('p', array('b'=>'c', 'a'=>'d')) ), '

          ' ); - + } - + } diff --git a/tests/HTMLPurifier/HTMLDefinitionTest.php b/tests/HTMLPurifier/HTMLDefinitionTest.php index fd33609a..f994e5bb 100644 --- a/tests/HTMLPurifier/HTMLDefinitionTest.php +++ b/tests/HTMLPurifier/HTMLDefinitionTest.php @@ -2,53 +2,53 @@ class HTMLPurifier_HTMLDefinitionTest extends HTMLPurifier_Harness { - + function expectError($error = false, $message = '%s') { // Because we're testing a definition, it's vital that the cache // is turned off for tests that expect errors. $this->config->set('Cache', 'DefinitionImpl', null); parent::expectError($error); } - + function test_parseTinyMCEAllowedList() { - + $def = new HTMLPurifier_HTMLDefinition(); - - // note: this is case-sensitive, but its config schema + + // note: this is case-sensitive, but its config schema // counterpart is not. This is generally a good thing for users, // but it's a slight internal inconsistency - + $this->assertEqual( $def->parseTinyMCEAllowedList(''), array(array(), array()) ); - + $this->assertEqual( $def->parseTinyMCEAllowedList('a,b,c'), array(array('a' => true, 'b' => true, 'c' => true), array()) ); - + $this->assertEqual( $def->parseTinyMCEAllowedList('a[x|y|z]'), array(array('a' => true), array('a.x' => true, 'a.y' => true, 'a.z' => true)) ); - + $this->assertEqual( $def->parseTinyMCEAllowedList('*[id]'), array(array(), array('*.id' => true)) ); - + $this->assertEqual( $def->parseTinyMCEAllowedList('a[*]'), array(array('a' => true), array('a.*' => true)) ); - + $this->assertEqual( $def->parseTinyMCEAllowedList('span[style],strong,a[href|title]'), array(array('span' => true, 'strong' => true, 'a' => true), array('span.style' => true, 'a.href' => true, 'a.title' => true)) ); - + $this->assertEqual( // alternate form: $def->parseTinyMCEAllowedList( @@ -59,100 +59,100 @@ a[href|title] $val = array(array('span' => true, 'strong' => true, 'a' => true), array('span.style' => true, 'a.href' => true, 'a.title' => true)) ); - + $this->assertEqual( $def->parseTinyMCEAllowedList(' span [ style ], strong'."\n\t".'a[href | title]'), $val ); - + } - + function test_Allowed() { - + $config1 = HTMLPurifier_Config::create(array( 'HTML.AllowedElements' => array('b', 'i', 'p', 'a'), 'HTML.AllowedAttributes' => array('a@href', '*@id') )); - + $config2 = HTMLPurifier_Config::create(array( 'HTML.Allowed' => 'b,i,p,a[href],*[id]' )); - + $this->assertEqual($config1->getHTMLDefinition(), $config2->getHTMLDefinition()); - + } - + function assertPurification_AllowedElements_p() { $this->assertPurification('

          Jelly

          ', '

          Jelly

          '); } - + function test_AllowedElements() { $this->config->set('HTML', 'AllowedElements', 'p'); $this->assertPurification_AllowedElements_p(); } - + function test_AllowedElements_multiple() { $this->config->set('HTML', 'AllowedElements', 'p,div'); $this->assertPurification('

          Jelly

          ', '

          Jelly

          '); } - + function test_AllowedElements_invalidElement() { $this->config->set('HTML', 'AllowedElements', 'obviously_invalid,p'); $this->expectError(new PatternExpectation("/Element 'obviously_invalid' is not supported/")); $this->assertPurification_AllowedElements_p(); } - + function test_AllowedElements_invalidElement_xssAttempt() { $this->config->set('HTML', 'AllowedElements', '', '' ); } - + function testPreserve() { $this->assertResult( '' ); } - + function testCDATAEnclosure() { $this->assertResult( '' ); } - + function testAllAttributes() { $this->assertResult( '' ); } - + function testUnsupportedAttributes() { $this->assertResult( '' ); } - + } diff --git a/tests/HTMLPurifier/HTMLModule/TidyTest.php b/tests/HTMLPurifier/HTMLModule/TidyTest.php index 4250b49a..e4f5ad83 100644 --- a/tests/HTMLPurifier/HTMLModule/TidyTest.php +++ b/tests/HTMLPurifier/HTMLModule/TidyTest.php @@ -8,14 +8,14 @@ Mock::generatePartial( class HTMLPurifier_HTMLModule_TidyTest extends HTMLPurifier_Harness { - + function test_getFixesForLevel() { - + $module = new HTMLPurifier_HTMLModule_Tidy(); $module->fixesForLevel['light'][] = 'light-fix'; $module->fixesForLevel['medium'][] = 'medium-fix'; $module->fixesForLevel['heavy'][] = 'heavy-fix'; - + $this->assertIdentical( array(), $module->getFixesForLevel('none') @@ -32,22 +32,22 @@ class HTMLPurifier_HTMLModule_TidyTest extends HTMLPurifier_Harness array('light-fix' => true, 'medium-fix' => true, 'heavy-fix' => true), $module->getFixesForLevel('heavy') ); - + $this->expectError('Tidy level turbo not recognized'); $module->getFixesForLevel('turbo'); - + } - + function test_setup() { - + $i = 0; // counter, helps us isolate expectations - + // initialize partial mock $module = new HTMLPurifier_HTMLModule_Tidy_TestForConstruct(); $module->fixesForLevel['light'] = array('light-fix-1', 'light-fix-2'); $module->fixesForLevel['medium'] = array('medium-fix-1', 'medium-fix-2'); $module->fixesForLevel['heavy'] = array('heavy-fix-1', 'heavy-fix-2'); - + $j = 0; $fixes = array( 'light-fix-1' => $lf1 = $j++, @@ -58,15 +58,15 @@ class HTMLPurifier_HTMLModule_TidyTest extends HTMLPurifier_Harness 'heavy-fix-2' => $hf2 = $j++ ); $module->setReturnValue('makeFixes', $fixes); - + $config = HTMLPurifier_Config::create(array( 'HTML.TidyLevel' => 'none' )); $module->expectAt($i++, 'populate', array(array())); $module->setup($config); - + // basic levels - + $config = HTMLPurifier_Config::create(array( 'HTML.TidyLevel' => 'light' )); @@ -75,7 +75,7 @@ class HTMLPurifier_HTMLModule_TidyTest extends HTMLPurifier_Harness 'light-fix-2' => $lf2 ))); $module->setup($config); - + $config = HTMLPurifier_Config::create(array( 'HTML.TidyLevel' => 'heavy' )); @@ -88,9 +88,9 @@ class HTMLPurifier_HTMLModule_TidyTest extends HTMLPurifier_Harness 'heavy-fix-2' => $hf2 ))); $module->setup($config); - + // fine grained tuning - + $config = HTMLPurifier_Config::create(array( 'HTML.TidyLevel' => 'none', 'HTML.TidyAdd' => array('light-fix-1', 'medium-fix-1') @@ -100,7 +100,7 @@ class HTMLPurifier_HTMLModule_TidyTest extends HTMLPurifier_Harness 'medium-fix-1' => $mf1 ))); $module->setup($config); - + $config = HTMLPurifier_Config::create(array( 'HTML.TidyLevel' => 'medium', 'HTML.TidyRemove' => array('light-fix-1', 'medium-fix-1') @@ -110,90 +110,90 @@ class HTMLPurifier_HTMLModule_TidyTest extends HTMLPurifier_Harness 'medium-fix-2' => $mf2 ))); $module->setup($config); - + } - + function test_makeFixesForLevel() { - + $module = new HTMLPurifier_HTMLModule_Tidy(); $module->defaultLevel = 'heavy'; - + $module->makeFixesForLevel(array( 'fix-1' => 0, 'fix-2' => 1, 'fix-3' => 2 )); - + $this->assertIdentical($module->fixesForLevel['heavy'], array('fix-1', 'fix-2', 'fix-3')); $this->assertIdentical($module->fixesForLevel['medium'], array()); $this->assertIdentical($module->fixesForLevel['light'], array()); - + } function test_makeFixesForLevel_undefinedLevel() { - + $module = new HTMLPurifier_HTMLModule_Tidy(); $module->defaultLevel = 'bananas'; - + $this->expectError('Default level bananas does not exist'); - + $module->makeFixesForLevel(array( 'fix-1' => 0 )); - + } - + function test_getFixType() { - + // syntax needs documenting - + $module = new HTMLPurifier_HTMLModule_Tidy(); - + $this->assertIdentical( $module->getFixType('a'), array('tag_transform', array('element' => 'a')) ); - + $this->assertIdentical( $module->getFixType('a@href'), $reuse = array('attr_transform_pre', array('element' => 'a', 'attr' => 'href')) ); - + $this->assertIdentical( $module->getFixType('a@href#pre'), $reuse ); - + $this->assertIdentical( $module->getFixType('a@href#post'), array('attr_transform_post', array('element' => 'a', 'attr' => 'href')) ); - + $this->assertIdentical( $module->getFixType('xml:foo@xml:bar'), array('attr_transform_pre', array('element' => 'xml:foo', 'attr' => 'xml:bar')) ); - + $this->assertIdentical( $module->getFixType('blockquote#child'), array('child', array('element' => 'blockquote')) ); - + $this->assertIdentical( $module->getFixType('@lang'), array('attr_transform_pre', array('attr' => 'lang')) ); - + $this->assertIdentical( $module->getFixType('@lang#post'), array('attr_transform_post', array('attr' => 'lang')) ); - + } - + function test_populate() { - + $i = 0; - + $module = new HTMLPurifier_HTMLModule_Tidy(); $module->populate(array( 'element' => $element = $i++, @@ -204,7 +204,7 @@ class HTMLPurifier_HTMLModule_TidyTest extends HTMLPurifier_Harness '@attr' => $global_attr = $i++, '@attr#post' => $global_attr_post = $i++ )); - + $module2 = new HTMLPurifier_HTMLModule_Tidy(); $e = $module2->addBlankElement('element'); $e->attr_transform_pre['attr'] = $attr; @@ -214,10 +214,10 @@ class HTMLPurifier_HTMLModule_TidyTest extends HTMLPurifier_Harness $module2->info_tag_transform['element'] = $element; $module2->info_attr_transform_pre['attr'] = $global_attr; $module2->info_attr_transform_post['attr'] = $global_attr_post; - + $this->assertEqual($module, $module2); - + } - + } diff --git a/tests/HTMLPurifier/HTMLModuleManagerTest.php b/tests/HTMLPurifier/HTMLModuleManagerTest.php index 2daa734c..b357419e 100644 --- a/tests/HTMLPurifier/HTMLModuleManagerTest.php +++ b/tests/HTMLPurifier/HTMLModuleManagerTest.php @@ -2,118 +2,118 @@ class HTMLPurifier_HTMLModuleManagerTest extends HTMLPurifier_Harness { - + protected function createManager() { $manager = new HTMLPurifier_HTMLModuleManager(); - + $this->config->set('HTML', 'CustomDoctype', 'Blank'); $manager->doctypes->register('Blank'); - + $attrdef_nmtokens = new HTMLPurifier_AttrDef_HTML_Nmtokens(); - + generate_mock_once('HTMLPurifier_AttrDef'); $attrdef = new HTMLPurifier_AttrDefMock(); $attrdef->setReturnValue('make', $attrdef_nmtokens); $manager->attrTypes->set('NMTOKENS', $attrdef); return $manager; } - + function test_addModule() { - + $manager = $this->createManager(); - + // ...but we add user modules - + $common_module = new HTMLPurifier_HTMLModule(); $common_module->name = 'Common'; $common_module->attr_collections['Common'] = array('class' => 'NMTOKENS'); $common_module->content_sets['Flow'] = 'Block | Inline'; $manager->addModule($common_module); - + $structural_module = new HTMLPurifier_HTMLModule(); $structural_module->name = 'Structural'; $structural_module->addElement('p', 'Block', 'Inline', 'Common'); $manager->addModule($structural_module); - + $formatting_module = new HTMLPurifier_HTMLModule(); $formatting_module->name = 'Formatting'; $formatting_module->addElement('em', 'Inline', 'Inline', 'Common'); $manager->addModule($formatting_module); - + $unsafe_module = new HTMLPurifier_HTMLModule(); $unsafe_module->name = 'Unsafe'; $unsafe_module->safe = false; $unsafe_module->addElement('div', 'Block', 'Flow'); $manager->addModule($unsafe_module); - + $config = HTMLPurifier_Config::createDefault(); $config->set('HTML', 'Trusted', false); $config->set('HTML', 'CustomDoctype', 'Blank'); - + $manager->setup($config); - + $attrdef_nmtokens = new HTMLPurifier_AttrDef_HTML_Nmtokens(); - + $p = new HTMLPurifier_ElementDef(); $p->attr['class'] = $attrdef_nmtokens; $p->child = new HTMLPurifier_ChildDef_Optional(array('em', '#PCDATA')); $p->content_model = 'em | #PCDATA'; $p->content_model_type = 'optional'; $p->descendants_are_inline = true; - + $em = new HTMLPurifier_ElementDef(); $em->attr['class'] = $attrdef_nmtokens; $em->child = new HTMLPurifier_ChildDef_Optional(array('em', '#PCDATA')); $em->content_model = 'em | #PCDATA'; $em->content_model_type = 'optional'; $em->descendants_are_inline = true; - + $this->assertEqual( array('p' => $p, 'em' => $em), $manager->getElements() ); - + // test trusted parameter override - + $div = new HTMLPurifier_ElementDef(); $div->child = new HTMLPurifier_ChildDef_Optional(array('p', 'div', 'em', '#PCDATA')); $div->content_model = 'p | div | em | #PCDATA'; $div->content_model_type = 'optional'; $div->descendants_are_inline = false; - + $this->assertEqual($div, $manager->getElement('div', true)); - + } - + function testAllowedModules() { - + $manager = new HTMLPurifier_HTMLModuleManager(); $manager->doctypes->register( 'Fantasy Inventory 1.0', true, array('Weapons', 'Magic') ); - + // register these modules so it doesn't blow up $weapons_module = new HTMLPurifier_HTMLModule(); $weapons_module->name = 'Weapons'; $manager->registerModule($weapons_module); - + $magic_module = new HTMLPurifier_HTMLModule(); $magic_module->name = 'Magic'; $manager->registerModule($magic_module); - + $config = HTMLPurifier_Config::create(array( 'HTML.CustomDoctype' => 'Fantasy Inventory 1.0', 'HTML.AllowedModules' => 'Weapons' )); $manager->setup($config); - + $this->assertTrue( isset($manager->modules['Weapons'])); $this->assertFalse(isset($manager->modules['Magic'])); - + } - - - + + + } diff --git a/tests/HTMLPurifier/HTMLModuleTest.php b/tests/HTMLPurifier/HTMLModuleTest.php index f1da074e..92f7dcba 100644 --- a/tests/HTMLPurifier/HTMLModuleTest.php +++ b/tests/HTMLPurifier/HTMLModuleTest.php @@ -2,21 +2,21 @@ class HTMLPurifier_HTMLModuleTest extends HTMLPurifier_Harness { - + function test_addElementToContentSet() { - + $module = new HTMLPurifier_HTMLModule(); - + $module->addElementToContentSet('b', 'Inline'); $this->assertIdentical($module->content_sets, array('Inline' => 'b')); - + $module->addElementToContentSet('i', 'Inline'); $this->assertIdentical($module->content_sets, array('Inline' => 'b | i')); - + } - + function test_addElement() { - + $module = new HTMLPurifier_HTMLModule(); $def = $module->addElement( 'a', 'Inline', 'Optional: #PCDATA', array('Common'), @@ -24,7 +24,7 @@ class HTMLPurifier_HTMLModuleTest extends HTMLPurifier_Harness 'href' => 'URI' ) ); - + $module2 = new HTMLPurifier_HTMLModule(); $def2 = new HTMLPurifier_ElementDef(); $def2->content_model = '#PCDATA'; @@ -36,17 +36,17 @@ class HTMLPurifier_HTMLModuleTest extends HTMLPurifier_Harness $module2->info['a'] = $def2; $module2->elements = array('a'); $module2->content_sets['Inline'] = 'a'; - + $this->assertIdentical($module, $module2); $this->assertIdentical($def, $def2); $this->assertReference($def, $module->info['a']); - + } - + function test_parseContents() { - + $module = new HTMLPurifier_HTMLModule(); - + // pre-defined templates $this->assertIdentical( $module->parseContents('Inline'), @@ -60,7 +60,7 @@ class HTMLPurifier_HTMLModuleTest extends HTMLPurifier_Harness $module->parseContents('Empty'), array('empty', '') ); - + // normalization procedures $this->assertIdentical( $module->parseContents('optional: a'), @@ -74,53 +74,53 @@ class HTMLPurifier_HTMLModuleTest extends HTMLPurifier_Harness $module->parseContents('Optional: a'), array('optional', 'a') ); - + // others $this->assertIdentical( $module->parseContents('Optional: a | b | c'), array('optional', 'a | b | c') ); - + // object pass-through generate_mock_once('HTMLPurifier_AttrDef'); $this->assertIdentical( $module->parseContents(new HTMLPurifier_AttrDefMock()), array(null, null) ); - + } - + function test_mergeInAttrIncludes() { - + $module = new HTMLPurifier_HTMLModule(); - + $attr = array(); $module->mergeInAttrIncludes($attr, 'Common'); $this->assertIdentical($attr, array(0 => array('Common'))); - + $attr = array('a' => 'b'); $module->mergeInAttrIncludes($attr, array('Common', 'Good')); $this->assertIdentical($attr, array('a' => 'b', 0 => array('Common', 'Good'))); - + } - + function test_addBlankElement() { - + $module = new HTMLPurifier_HTMLModule(); $def = $module->addBlankElement('a'); - + $def2 = new HTMLPurifier_ElementDef(); $def2->standalone = false; - + $this->assertReference($module->info['a'], $def); $this->assertIdentical($def, $def2); - + } - + function test_makeLookup() { - + $module = new HTMLPurifier_HTMLModule(); - + $this->assertIdentical( $module->makeLookup('foo'), array('foo' => true) @@ -129,7 +129,7 @@ class HTMLPurifier_HTMLModuleTest extends HTMLPurifier_Harness $module->makeLookup(array('foo')), array('foo' => true) ); - + $this->assertIdentical( $module->makeLookup('foo', 'two'), array('foo' => true, 'two' => true) @@ -138,8 +138,8 @@ class HTMLPurifier_HTMLModuleTest extends HTMLPurifier_Harness $module->makeLookup(array('foo', 'two')), array('foo' => true, 'two' => true) ); - + } - + } diff --git a/tests/HTMLPurifier/HTMLT.php b/tests/HTMLPurifier/HTMLT.php index 628640b3..75c7eae2 100644 --- a/tests/HTMLPurifier/HTMLT.php +++ b/tests/HTMLPurifier/HTMLT.php @@ -3,12 +3,12 @@ class HTMLPurifier_HTMLT extends HTMLPurifier_Harness { protected $path; - + public function __construct($path) { $this->path = $path; parent::__construct($path); } - + public function testHtmlt() { $parser = new HTMLPurifier_StringHashParser(); $hash = $parser->parseFile($this->path); // assume parser normalizes to "\n" diff --git a/tests/HTMLPurifier/Harness.php b/tests/HTMLPurifier/Harness.php index 7a71bc5d..100c440a 100644 --- a/tests/HTMLPurifier/Harness.php +++ b/tests/HTMLPurifier/Harness.php @@ -5,13 +5,13 @@ */ class HTMLPurifier_Harness extends UnitTestCase { - + public function __construct() { parent::__construct(); } - + protected $config, $context, $purifier; - + /** * Generates easily accessible default config/context, as well as * a convenience purifier for integration testing. @@ -22,7 +22,7 @@ class HTMLPurifier_Harness extends UnitTestCase '); $this->purifier = new HTMLPurifier(); } - + /** * Asserts a purification. Good for integration testing. */ @@ -31,8 +31,8 @@ class HTMLPurifier_Harness extends UnitTestCase $result = $this->purifier->purify($input, $this->config); $this->assertIdentical($expect, $result); } - - + + /** * Accepts config and context and prepares them into a valid state * @param &$config Reference to config variable @@ -42,7 +42,7 @@ class HTMLPurifier_Harness extends UnitTestCase $config = HTMLPurifier_Config::create($config); if (!$context) $context = new HTMLPurifier_Context(); } - + /** * Generates default configuration and context objects * @return Defaults in form of array($config, $context) @@ -50,14 +50,14 @@ class HTMLPurifier_Harness extends UnitTestCase protected function createCommon() { return array(HTMLPurifier_Config::createDefault(), new HTMLPurifier_Context); } - + /** * Normalizes a string to Unix (\n) endings */ protected function normalize(&$string) { $string = str_replace(array("\r\n", "\r"), "\n", $string); } - + /** * If $expect is false, ignore $result and check if status failed. * Otherwise, check if $status if true and $result === $expect. @@ -73,7 +73,7 @@ class HTMLPurifier_Harness extends UnitTestCase $this->assertIdentical($result, $expect); } } - + public function getTests() { // __onlytest makes only one test get triggered foreach (get_class_methods(get_class($this)) as $method) { @@ -84,6 +84,6 @@ class HTMLPurifier_Harness extends UnitTestCase } return parent::getTests(); } - + } diff --git a/tests/HTMLPurifier/IDAccumulatorTest.php b/tests/HTMLPurifier/IDAccumulatorTest.php index f173f45d..142aebf5 100644 --- a/tests/HTMLPurifier/IDAccumulatorTest.php +++ b/tests/HTMLPurifier/IDAccumulatorTest.php @@ -2,37 +2,37 @@ class HTMLPurifier_IDAccumulatorTest extends HTMLPurifier_Harness { - + function test() { - + // initialize the accumulator $accumulator = new HTMLPurifier_IDAccumulator(); - + $this->assertTrue( $accumulator->add('id1')); $this->assertTrue( $accumulator->add('id2')); $this->assertFalse($accumulator->add('id1')); // repeated id - + // you can also access the properties (they're public) $this->assertTrue( isset($accumulator->ids['id2']) ); - + } - + function testLoad() { - + $accumulator = new HTMLPurifier_IDAccumulator(); - + $accumulator->load(array('id1', 'id2', 'id3')); - + $this->assertFalse($accumulator->add('id1')); // repeated id $this->assertTrue($accumulator->add('id4')); - + } - + function testBuild() { $this->config->set('Attr', 'IDBlacklist', array('foo')); $accumulator = HTMLPurifier_IDAccumulator::build($this->config, $this->context); $this->assertTrue( isset($accumulator->ids['foo']) ); } - + } diff --git a/tests/HTMLPurifier/Injector/AutoParagraphTest.php b/tests/HTMLPurifier/Injector/AutoParagraphTest.php index dda70a57..477f8891 100644 --- a/tests/HTMLPurifier/Injector/AutoParagraphTest.php +++ b/tests/HTMLPurifier/Injector/AutoParagraphTest.php @@ -2,19 +2,19 @@ class HTMLPurifier_Injector_AutoParagraphTest extends HTMLPurifier_InjectorHarness { - + function setup() { parent::setup(); $this->config->set('AutoFormat', 'AutoParagraph', true); } - + function testSingleParagraph() { $this->assertResult( 'Foobar', '

          Foobar

          ' ); } - + function testSingleMultiLineParagraph() { $this->assertResult( 'Par 1 @@ -23,7 +23,7 @@ Par 1 still', Par 1 still

          ' ); } - + function testTwoParagraphs() { $this->assertResult( 'Par1 @@ -34,12 +34,12 @@ Par2',

          Par2

          " ); } - + function testTwoParagraphsWithLotsOfSpace() { $this->assertResult( 'Par1 - + Par2', '

          Par1

          @@ -47,7 +47,7 @@ Par2',

          Par2

          ' ); } - + function testTwoParagraphsWithInlineElements() { $this->assertResult( 'Par1 @@ -58,7 +58,7 @@ Par2',

          Par2

          ' ); } - + function testSingleParagraphThatLooksLikeTwo() { $this->assertResult( 'Par1 @@ -69,7 +69,7 @@ Par2', Par2

          ' ); } - + function testAddParagraphAdjacentToParagraph() { $this->assertResult( 'Par1

          Par2

          ', @@ -78,14 +78,14 @@ Par2

          '

          Par2

          ' ); } - + function testParagraphUnclosedInlineElement() { $this->assertResult( 'Par1', '

          Par1

          ' ); } - + function testPreservePreTags() { $this->assertResult( '
          Par1
          @@ -93,7 +93,7 @@ Par2

          ' Par1
          ' ); } - + function testIgnoreTrailingWhitespace() { $this->assertResult( 'Par1 @@ -104,7 +104,7 @@ Par1' ' ); } - + function testDoNotParagraphBlockElements() { $this->assertResult( 'Par1 @@ -119,14 +119,14 @@ Par3',

          Par3

          ' ); } - + function testParagraphTextAndInlineNodes() { $this->assertResult( 'Par1', '

          Par1

          ' ); } - + function testPreserveLeadingWhitespace() { $this->assertResult( ' @@ -137,7 +137,7 @@ Par',

          Par

          ' ); } - + function testPreserveSurroundingWhitespace() { $this->assertResult( ' @@ -152,7 +152,7 @@ Par ' ); } - + function testParagraphInsideBlockNode() { $this->assertResult( '
          Par1 @@ -163,7 +163,7 @@ Par2
          ',

          Par2

          ' ); } - + function testParagraphInlineNodeInsideBlockNode() { $this->assertResult( '
          Par1 @@ -174,11 +174,11 @@ Par2
          ',

          Par2

          ' ); } - + function testNoParagraphWhenOnlyOneInsideBlockNode() { $this->assertResult('
          Par1
          '); } - + function testParagraphTwoInlineNodesInsideBlockNode() { $this->assertResult( '
          Par1 @@ -189,7 +189,7 @@ Par2
          ',

          Par2

          ' ); } - + function testPreserveInlineNodesInPreTag() { $this->assertResult( '
          Par1
          @@ -197,7 +197,7 @@ Par2',
           Par2
          ' ); } - + function testSplitUpInternalsOfPTagInBlockNode() { $this->assertResult( '

          Foo @@ -208,7 +208,7 @@ Bar

          ',

          Bar

          ' ); } - + function testSplitUpInlineNodesInPTagInBlockNode() { $this->assertResult( '

          Foo @@ -219,11 +219,11 @@ Bar

          ',

          Bar

          ' ); } - + function testNoParagraphSingleInlineNodeInBlockNode() { $this->assertResult( '
          Foo
          ' ); } - + function testParagraphInBlockquote() { $this->assertResult( '
          Par1 @@ -234,7 +234,7 @@ Par2
          ',

          Par2

          ' ); } - + function testNoParagraphBetweenListItem() { $this->assertResult( '
          • Foo
          • @@ -242,14 +242,14 @@ Par2',
          • Bar
          ' ); } - + function testParagraphSingleElementWithSurroundingSpace() { $this->assertResult( '
          Bar -
          ', +', '

          Bar

          @@ -257,42 +257,42 @@ Bar
          ' ); } - + function testIgnoreExtraSpaceWithLeadingInlineNode() { $this->assertResult( 'Par1a -Par2', +Par2', '

          Par1a

          Par2

          ' ); } - + function testAbsorbExtraEndingPTag() { $this->assertResult( 'Par1 -Par2

          ', +Par2

          ', '

          Par1

          Par2

          ' ); } - + function testAbsorbExtraEndingDivTag() { $this->assertResult( 'Par1 -Par2', +Par2', '

          Par1

          Par2

          ' ); } - + function testDoNotParagraphSingleSurroundingSpaceInBlockNode() { $this->assertResult( '
          @@ -300,7 +300,7 @@ Par1
          ' ); } - + function testBlockNodeTextDelimeterInBlockNode() { $this->assertResult( '
          Par1 @@ -311,14 +311,14 @@ Par1
          Par2
          ' ); } - + function testBlockNodeTextDelimeterWithoutDoublespaceInBlockNode() { $this->assertResult( '
          Par1
          Par2
          ' ); } - + function testBlockNodeTextDelimeterWithoutDoublespace() { $this->assertResult( 'Par1 @@ -329,7 +329,7 @@ Par1
          Par2
          ' ); } - + function testTwoParagraphsOfTextAndInlineNode() { $this->assertResult( 'Par1 @@ -340,32 +340,32 @@ Par1

          Par2

          ' ); } - + function testLeadingInlineNodeParagraph() { $this->assertResult( ' Foo', '

          Foo

          ' ); } - + function testTrailingInlineNodeParagraph() { $this->assertResult( '
        • Foo bar
        • ' ); } - + function testTwoInlineNodeParagraph() { $this->assertResult( '
        • bazbar
        • ' ); } - + function testNoParagraphTrailingBlockNodeInBlockNode() { $this->assertResult( '
          asdf
          asdf
          ' ); } - + function testParagraphTrailingBlockNodeWithDoublespaceInBlockNode() { $this->assertResult( '
          asdf
          @@ -376,14 +376,14 @@ Par1

          asdf

          ' ); } - + function testParagraphTwoInlineNodesAndWhitespaceNode() { $this->assertResult( 'One Two', '

          One Two

          ' ); } - + function testNoParagraphWithInlineRootNode() { $this->config->set('HTML', 'Parent', 'span'); $this->assertResult( @@ -392,13 +392,13 @@ Par1 Par2' ); } - + function testInlineAndBlockTagInDivNoParagraph() { $this->assertResult( '
          bar mmm
          asdf
          ' ); } - + function testInlineAndBlockTagInDivNeedingParagraph() { $this->assertResult( '
          bar mmm @@ -409,7 +409,7 @@ Par2'
          asdf
          ' ); } - + function testTextInlineNodeTextThenDoubleNewlineNeedsParagraph() { $this->assertResult( '
          asdf bar mmm @@ -420,7 +420,7 @@ Par2'
          asdf
          ' ); } - + function testUpcomingTokenHasNewline() { $this->assertResult( '
          Testfoobarbingbang @@ -431,7 +431,7 @@ boo
          ',

          boo

          ' ); } - + function testEmptyTokenAtEndOfDiv() { $this->assertResult( '

          foo

          @@ -440,7 +440,7 @@ boo
          ', ' ); } - + function testEmptyDoubleLineTokenAtEndOfDiv() { $this->assertResult( '

          foo

          @@ -451,26 +451,26 @@ boo
          ', ' ); } - + function testTextState11Root() { $this->assertResult('
          '); } - + function testTextState11Element() { $this->assertResult( "
          "); } - + function testTextStateLikeElementState111NoWhitespace() { $this->assertResult('

          P

          Boo
          ', '

          P

          Boo
          '); } - + function testElementState111NoWhitespace() { $this->assertResult('

          P

          Boo
          ', '

          P

          Boo
          '); } - + function testElementState133() { $this->assertResult( "
          B
          Ba
          @@ -481,13 +481,13 @@ Bar
          ",

          Bar

          " ); } - + function testElementState22() { $this->assertResult( '
          • foo
          ' ); } - + function testElementState311() { $this->assertResult( '

          Foo

          Bar', @@ -496,12 +496,12 @@ Bar",

          Bar

          ' ); } - + function testErrorNeeded() { $this->config->set('HTML', 'Allowed', 'b'); $this->expectError('Cannot enable AutoParagraph injector because p is not allowed'); $this->assertResult('foobar'); } - + } diff --git a/tests/HTMLPurifier/Injector/DisplayLinkURITest.php b/tests/HTMLPurifier/Injector/DisplayLinkURITest.php index e2f8e75a..4099d0b1 100644 --- a/tests/HTMLPurifier/Injector/DisplayLinkURITest.php +++ b/tests/HTMLPurifier/Injector/DisplayLinkURITest.php @@ -2,19 +2,19 @@ class HTMLPurifier_Injector_DisplayLinkURITest extends HTMLPurifier_InjectorHarness { - + function setup() { parent::setup(); $this->config->set('AutoFormat', 'DisplayLinkURI', true); } - + function testBasicLink() { $this->assertResult( 'Don\'t go here!', 'Don\'t go here! (http://malware.example.com)' ); } - + function testEmptyLink() { $this->assertResult( 'Don\'t go here!', @@ -27,6 +27,6 @@ class HTMLPurifier_Injector_DisplayLinkURITest extends HTMLPurifier_InjectorHarn ' (http://malware.example.com)' ); } - + } ?> \ No newline at end of file diff --git a/tests/HTMLPurifier/Injector/LinkifyTest.php b/tests/HTMLPurifier/Injector/LinkifyTest.php index 0ae884a6..1e44a75a 100644 --- a/tests/HTMLPurifier/Injector/LinkifyTest.php +++ b/tests/HTMLPurifier/Injector/LinkifyTest.php @@ -2,44 +2,44 @@ class HTMLPurifier_Injector_LinkifyTest extends HTMLPurifier_InjectorHarness { - + function setup() { parent::setup(); $this->config->set('AutoFormat', 'Linkify', true); } - + function testLinkifyURLInRootNode() { $this->assertResult( 'http://example.com', 'http://example.com' ); } - + function testLinkifyURLInInlineNode() { $this->assertResult( 'http://example.com', 'http://example.com' ); } - + function testBasicUsageCase() { $this->assertResult( 'This URL http://example.com is what you need', 'This URL http://example.com is what you need' ); } - + function testIgnoreURLInATag() { $this->assertResult( 'http://example.com/' ); } - + function testNeeded() { $this->config->set('HTML', 'Allowed', 'b'); $this->expectError('Cannot enable Linkify injector because a is not allowed'); $this->assertResult('http://example.com/'); } - + } diff --git a/tests/HTMLPurifier/Injector/PurifierLinkifyTest.php b/tests/HTMLPurifier/Injector/PurifierLinkifyTest.php index f4e811e2..6f54bde8 100644 --- a/tests/HTMLPurifier/Injector/PurifierLinkifyTest.php +++ b/tests/HTMLPurifier/Injector/PurifierLinkifyTest.php @@ -2,57 +2,57 @@ class HTMLPurifier_Injector_PurifierLinkifyTest extends HTMLPurifier_InjectorHarness { - + function setup() { parent::setup(); $this->config->set('AutoFormat', 'PurifierLinkify', true); $this->config->set('AutoFormatParam', 'PurifierLinkifyDocURL', '#%s'); } - + function testNoTriggerCharacer() { $this->assertResult('Foobar'); } - + function testTriggerCharacterInIrrelevantContext() { $this->assertResult('20% off!'); } - + function testPreserveNamespace() { $this->assertResult('%Core namespace (not recognized)'); } - + function testLinkifyBasic() { $this->assertResult( '%Namespace.Directive', '%Namespace.Directive' ); } - + function testLinkifyWithAdjacentTextNodes() { $this->assertResult( 'This %Namespace.Directive thing', 'This %Namespace.Directive thing' ); } - + function testLinkifyInBlock() { $this->assertResult( '
          This %Namespace.Directive thing
          ', '' ); } - + function testPreserveInATag() { $this->assertResult( '%Namespace.Directive' ); } - + function testNeeded() { $this->config->set('HTML', 'Allowed', 'b'); $this->expectError('Cannot enable PurifierLinkify injector because a is not allowed'); $this->assertResult('%Namespace.Directive'); } - + } diff --git a/tests/HTMLPurifier/Injector/RemoveEmptyTest.php b/tests/HTMLPurifier/Injector/RemoveEmptyTest.php index 4726a5df..01ccae99 100644 --- a/tests/HTMLPurifier/Injector/RemoveEmptyTest.php +++ b/tests/HTMLPurifier/Injector/RemoveEmptyTest.php @@ -2,57 +2,57 @@ class HTMLPurifier_Injector_RemoveEmptyTest extends HTMLPurifier_InjectorHarness { - + public function setup() { parent::setup(); $this->config->set('AutoFormat', 'RemoveEmpty', true); } - + function testPreserve() { $this->assertResult('asdf'); } - + function testRemove() { $this->assertResult('', ''); } - + function testRemoveWithSpace() { $this->assertResult(' ', ''); } - + function testRemoveWithAttr() { $this->assertResult('', ''); } - + function testRemoveIdAndName() { $this->assertResult('', ''); } - + function testPreserveColgroup() { $this->assertResult('
          Cell 1
          '); } - + function testRemoveEmptyTable() { $this->assertResult('
          ', ''); } - + function testChameleonRemoveBlockInNodeInInline() { $this->assertResult( '
          Not allowed!
          ', 'Not allowed!' ); } - + function testChameleonRemoveBlockInBlockNodeWithInlineContent() { $this->assertResult( '

          Not allowed!

          ', '

          Not allowed!

          ' ); } - + function testNestedChameleonRemoveBlockInNodeWithInlineContent() { $this->assertResult( '

          Not allowed!

          ', '

          Not allowed!

          ' ); } - + function testNestedChameleonPreserveBlockInBlock() { $this->assertResult( '
          Allowed!
          ' ); } - + function testChameleonEscapeInvalidBlockInInline() { $this->config->set('Core', 'EscapeInvalidChildren', true); $this->assertResult( // alt config @@ -84,7 +84,7 @@ class HTMLPurifier_Strategy_FixNestingTest extends HTMLPurifier_StrategyHarness '<div>Not allowed!</div>' ); } - + function testExclusionsIntegration() { // test exclusions $this->assertResult( @@ -92,17 +92,17 @@ class HTMLPurifier_Strategy_FixNestingTest extends HTMLPurifier_StrategyHarness '' ); } - + function testPreserveInlineNodeInInlineRootNode() { $this->config->set('HTML', 'Parent', 'span'); $this->assertResult('Bold'); } - + function testRemoveBlockNodeInInlineRootNode() { $this->config->set('HTML', 'Parent', 'span'); $this->assertResult('
          Reject
          ', 'Reject'); } - + function testInvalidParentError() { // test fallback to div $this->config->set('HTML', 'Parent', 'obviously-impossible'); @@ -110,27 +110,27 @@ class HTMLPurifier_Strategy_FixNestingTest extends HTMLPurifier_StrategyHarness $this->expectError('Cannot use unrecognized element as parent'); $this->assertResult('
          Accept
          '); } - + function testCascadingRemovalOfNodesMissingRequiredChildren() { $this->assertResult('
          ', ''); } - + function testCascadingRemovalSpecialCaseCannotScrollOneBack() { $this->assertResult('
          ', ''); } - + function testLotsOfCascadingRemovalOfNodes() { $this->assertResult('
          ', ''); } - + function testAdjacentRemovalOfNodeMissingRequiredChildren() { $this->assertResult('
          ', ''); } - + function testStrictBlockquoteInHTML401() { $this->config->set('HTML', 'Doctype', 'HTML 4.01 Strict'); $this->assertResult('
          text
          ', '

          text

          '); } - + } diff --git a/tests/HTMLPurifier/Strategy/FixNesting_ErrorsTest.php b/tests/HTMLPurifier/Strategy/FixNesting_ErrorsTest.php index 73c627ee..517349b5 100644 --- a/tests/HTMLPurifier/Strategy/FixNesting_ErrorsTest.php +++ b/tests/HTMLPurifier/Strategy/FixNesting_ErrorsTest.php @@ -2,39 +2,39 @@ class HTMLPurifier_Strategy_FixNesting_ErrorsTest extends HTMLPurifier_Strategy_ErrorsHarness { - + protected function getStrategy() { return new HTMLPurifier_Strategy_FixNesting(); } - + function testNodeRemoved() { $this->expectErrorCollection(E_ERROR, 'Strategy_FixNesting: Node removed'); $this->expectContext('CurrentToken', new HTMLPurifier_Token_Start('ul', array(), 1)); $this->invoke('
            '); } - + function testNodeExcluded() { $this->expectErrorCollection(E_ERROR, 'Strategy_FixNesting: Node excluded'); $this->expectContext('CurrentToken', new HTMLPurifier_Token_Start('a', array(), 2)); $this->invoke("\n"); } - + function testNodeReorganized() { $this->expectErrorCollection(E_WARNING, 'Strategy_FixNesting: Node reorganized'); $this->expectContext('CurrentToken', new HTMLPurifier_Token_Start('span', array(), 1)); $this->invoke("Valid
            Invalid
            "); } - + function testNoNodeReorganizedForEmptyNode() { $this->expectNoErrorCollection(); $this->invoke(""); } - + function testNodeContentsRemoved() { $this->expectErrorCollection(E_ERROR, 'Strategy_FixNesting: Node contents removed'); $this->expectContext('CurrentToken', new HTMLPurifier_Token_Start('span', array(), 1)); $this->invoke("
            "); } - + } diff --git a/tests/HTMLPurifier/Strategy/MakeWellFormedTest.php b/tests/HTMLPurifier/Strategy/MakeWellFormedTest.php index 816bdbca..2d28509a 100644 --- a/tests/HTMLPurifier/Strategy/MakeWellFormedTest.php +++ b/tests/HTMLPurifier/Strategy/MakeWellFormedTest.php @@ -2,105 +2,105 @@ class HTMLPurifier_Strategy_MakeWellFormedTest extends HTMLPurifier_StrategyHarness { - + function setUp() { parent::setUp(); $this->obj = new HTMLPurifier_Strategy_MakeWellFormed(); } - + function testEmptyInput() { $this->assertResult(''); } - + function testWellFormedInput() { $this->assertResult('This is bold text.'); } - + function testUnclosedTagTerminatedByDocumentEnd() { $this->assertResult( 'Unclosed tag, gasp!', 'Unclosed tag, gasp!' ); } - + function testUnclosedTagTerminatedByParentNodeEnd() { $this->assertResult( 'Bold and italic?', 'Bold and italic?' ); } - + function testRemoveStrayClosingTag() { $this->assertResult( 'Unused end tags... recycle!', 'Unused end tags... recycle!' ); } - + function testConvertStartToEmpty() { $this->assertResult( '
            ', '
            ' ); } - + function testConvertEmptyToStart() { $this->assertResult( '
            ', '
            ' ); } - + function testAutoCloseParagraph() { $this->assertResult( '

            Paragraph 1

            Paragraph 2', '

            Paragraph 1

            Paragraph 2

            ' ); } - + function testAutoCloseParagraphInsideDiv() { $this->assertResult( '

            Paragraphs

            In

            A

            Div

            ', '

            Paragraphs

            In

            A

            Div

            ' ); } - + function testAutoCloseListItem() { $this->assertResult( '
            1. Item 1
            2. Item 2
            ', '
            1. Item 1
            2. Item 2
            ' ); } - + function testAutoCloseColgroup() { $this->assertResult( '
            ', '
            ' ); } - + function testAutoCloseMultiple() { $this->assertResult( '
            ', '
            ' ); } - + function testUnrecognized() { $this->assertResult( 'foo', 'foo' ); } - + function testBlockquoteWithInline() { $this->config->set('HTML', 'Doctype', 'XHTML 1.0 Strict'); $this->assertResult( - // This is actually invalid, but will be fixed by + // This is actually invalid, but will be fixed by // ChildDef_StrictBlockquote '
            foobar
            ' ); } - + } diff --git a/tests/HTMLPurifier/Strategy/MakeWellFormed_ErrorsTest.php b/tests/HTMLPurifier/Strategy/MakeWellFormed_ErrorsTest.php index 2f38c996..25cd4bae 100644 --- a/tests/HTMLPurifier/Strategy/MakeWellFormed_ErrorsTest.php +++ b/tests/HTMLPurifier/Strategy/MakeWellFormed_ErrorsTest.php @@ -2,53 +2,53 @@ class HTMLPurifier_Strategy_MakeWellFormed_ErrorsTest extends HTMLPurifier_Strategy_ErrorsHarness { - + protected function getStrategy() { return new HTMLPurifier_Strategy_MakeWellFormed(); } - + function testUnnecessaryEndTagRemoved() { $this->expectErrorCollection(E_WARNING, 'Strategy_MakeWellFormed: Unnecessary end tag removed'); $this->expectContext('CurrentToken', new HTMLPurifier_Token_End('b', array(), 1, 0)); $this->invoke('
            '); } - + function testUnnecessaryEndTagToText() { $this->config->set('Core', 'EscapeInvalidTags', true); $this->expectErrorCollection(E_WARNING, 'Strategy_MakeWellFormed: Unnecessary end tag to text'); $this->expectContext('CurrentToken', new HTMLPurifier_Token_End('b', array(), 1, 0)); $this->invoke(''); } - + function testTagAutoClosed() { $this->expectErrorCollection(E_NOTICE, 'Strategy_MakeWellFormed: Tag auto closed', new HTMLPurifier_Token_Start('b', array(), 1, 0)); $this->expectContext('CurrentToken', new HTMLPurifier_Token_Start('div', array(), 1, 6)); $this->invoke('Foo
            Bar
            '); } - + function testStrayEndTagRemoved() { $this->expectErrorCollection(E_WARNING, 'Strategy_MakeWellFormed: Stray end tag removed'); $this->expectContext('CurrentToken', new HTMLPurifier_Token_End('b', array(), 1, 3)); $this->invoke('
            '); } - + function testStrayEndTagToText() { $this->config->set('Core', 'EscapeInvalidTags', true); $this->expectErrorCollection(E_WARNING, 'Strategy_MakeWellFormed: Stray end tag to text'); $this->expectContext('CurrentToken', new HTMLPurifier_Token_End('b', array(), 1, 3)); $this->invoke(''); } - + function testTagClosedByElementEnd() { $this->expectErrorCollection(E_NOTICE, 'Strategy_MakeWellFormed: Tag closed by element end', new HTMLPurifier_Token_Start('b', array(), 1, 3)); $this->expectContext('CurrentToken', new HTMLPurifier_Token_End('i', array(), 1, 12)); $this->invoke('Foobar'); } - + function testTagClosedByDocumentEnd() { $this->expectErrorCollection(E_NOTICE, 'Strategy_MakeWellFormed: Tag closed by document end', new HTMLPurifier_Token_Start('b', array(), 1, 0)); $this->invoke('Foobar'); } - + } diff --git a/tests/HTMLPurifier/Strategy/MakeWellFormed_InjectorTest.php b/tests/HTMLPurifier/Strategy/MakeWellFormed_InjectorTest.php index 212b2d4c..dbdb4c5b 100644 --- a/tests/HTMLPurifier/Strategy/MakeWellFormed_InjectorTest.php +++ b/tests/HTMLPurifier/Strategy/MakeWellFormed_InjectorTest.php @@ -2,7 +2,7 @@ class HTMLPurifier_Strategy_MakeWellFormed_InjectorTest extends HTMLPurifier_StrategyHarness { - + function setUp() { parent::setUp(); $this->obj = new HTMLPurifier_Strategy_MakeWellFormed(); @@ -11,7 +11,7 @@ class HTMLPurifier_Strategy_MakeWellFormed_InjectorTest extends HTMLPurifier_Str $this->config->set('AutoFormat', 'RemoveEmpty', true); generate_mock_once('HTMLPurifier_Injector'); } - + function testEndHandler() { $mock = new HTMLPurifier_InjectorMock(); $b = new HTMLPurifier_Token_End('b'); @@ -31,48 +31,48 @@ class HTMLPurifier_Strategy_MakeWellFormed_InjectorTest extends HTMLPurifier_Str $this->config->set('AutoFormat', 'Custom', array($mock)); $this->assertResult('asdf', 'asdf'); } - + function testErrorRequiredElementNotAllowed() { $this->config->set('HTML', 'Allowed', ''); $this->expectError('Cannot enable AutoParagraph injector because p is not allowed'); $this->expectError('Cannot enable Linkify injector because a is not allowed'); $this->assertResult('Foobar'); } - + function testErrorRequiredAttributeNotAllowed() { $this->config->set('HTML', 'Allowed', 'a,p'); $this->expectError('Cannot enable Linkify injector because a.href is not allowed'); $this->assertResult('

            http://example.com

            '); } - + function testOnlyAutoParagraph() { $this->assertResult( 'Foobar', '

            Foobar

            ' ); } - + function testParagraphWrappingOnlyLink() { $this->assertResult( 'http://example.com', '

            http://example.com

            ' ); } - + function testParagraphWrappingNodeContainingLink() { $this->assertResult( 'http://example.com', '

            http://example.com

            ' ); } - + function testParagraphWrappingPoorlyFormedNodeContainingLink() { $this->assertResult( 'http://example.com', '

            http://example.com

            ' ); } - + function testTwoParagraphsContainingOnlyOneLink() { $this->assertResult( "http://example.com\n\nhttp://dev.example.com", @@ -81,7 +81,7 @@ class HTMLPurifier_Strategy_MakeWellFormed_InjectorTest extends HTMLPurifier_Str

            http://dev.example.com

            ' ); } - + function testParagraphNextToDivWithLinks() { $this->assertResult( 'http://example.com
            http://example.com
            ', @@ -90,14 +90,14 @@ class HTMLPurifier_Strategy_MakeWellFormed_InjectorTest extends HTMLPurifier_Str ' ); } - + function testRealisticLinkInSentence() { $this->assertResult( 'This URL http://example.com is what you need', '

            This URL http://example.com is what you need

            ' ); } - + function testParagraphAfterLinkifiedURL() { $this->assertResult( "http://google.com @@ -108,7 +108,7 @@ class HTMLPurifier_Strategy_MakeWellFormed_InjectorTest extends HTMLPurifier_Str

            b

            " ); } - + function testEmptyAndParagraph() { // This is a fairly degenerate case, but it demonstrates that // the two don't error out together, at least. @@ -128,7 +128,7 @@ asdf

            " ); } - + function testRewindAndParagraph() { $this->assertResult( "bar @@ -145,5 +145,5 @@ foo",

            foo

            " ); } - + } diff --git a/tests/HTMLPurifier/Strategy/RemoveForeignElementsTest.php b/tests/HTMLPurifier/Strategy/RemoveForeignElementsTest.php index f86f34af..2ac3daa4 100644 --- a/tests/HTMLPurifier/Strategy/RemoveForeignElementsTest.php +++ b/tests/HTMLPurifier/Strategy/RemoveForeignElementsTest.php @@ -2,41 +2,41 @@ class HTMLPurifier_Strategy_RemoveForeignElementsTest extends HTMLPurifier_StrategyHarness { - + function setUp() { parent::setUp(); $this->obj = new HTMLPurifier_Strategy_RemoveForeignElements(); } - + function testBlankInput() { $this->assertResult(''); } - + function testPreserveRecognizedElements() { $this->assertResult('This is bold text.'); } - + function testRemoveForeignElements() { $this->assertResult( 'BlingBong', 'BlingBong' ); } - + function testRemoveScriptAndContents() { $this->assertResult( '', '' ); } - + function testRemoveStyleAndContents() { $this->assertResult( '', '' ); } - + function testRemoveOnlyScriptTagsLegacy() { $this->config->set('Core', 'RemoveScriptContents', false); $this->assertResult( @@ -44,7 +44,7 @@ class HTMLPurifier_Strategy_RemoveForeignElementsTest extends HTMLPurifier_Strat 'alert();' ); } - + function testRemoveOnlyScriptTags() { $this->config->set('Core', 'HiddenElements', array()); $this->assertResult( @@ -52,20 +52,20 @@ class HTMLPurifier_Strategy_RemoveForeignElementsTest extends HTMLPurifier_Strat 'alert();' ); } - + function testRemoveInvalidImg() { $this->assertResult('', ''); } - + function testPreserveValidImg() { $this->assertResult('foobar.gif'); } - + function testPreserveInvalidImgWhenRemovalIsDisabled() { $this->config->set('Core', 'RemoveInvalidImg', false); $this->assertResult(''); } - + function testTextifyCommentedScriptContents() { $this->config->set('HTML', 'Trusted', true); $this->config->set('Output', 'CommentScriptContents', false); // simplify output @@ -78,7 +78,7 @@ alert(<b>bold</b>); // ' ); } - + function testRequiredAttributesTestNotPerformedOnEndTag() { $this->config->set('HTML', 'DefinitionID', 'HTMLPurifier_Strategy_RemoveForeignElementsTest'. @@ -87,21 +87,21 @@ alert(<b>bold</b>); $def->addElement('f', 'Block', 'Optional: #PCDATA', false, array('req*' => 'Text')); $this->assertResult('Foo Bar'); } - + function testPreserveCommentsWithHTMLTrusted() { $this->config->set('HTML', 'Trusted', true); $this->assertResult(''); } - + function testRemoveTrailingHyphensInComment() { $this->config->set('HTML', 'Trusted', true); $this->assertResult('', ''); } - + function testCollapseDoubleHyphensInComment() { $this->config->set('HTML', 'Trusted', true); $this->assertResult('', ''); } - + } diff --git a/tests/HTMLPurifier/Strategy/RemoveForeignElements_ErrorsTest.php b/tests/HTMLPurifier/Strategy/RemoveForeignElements_ErrorsTest.php index 9d92f4ef..7c91e5b7 100644 --- a/tests/HTMLPurifier/Strategy/RemoveForeignElements_ErrorsTest.php +++ b/tests/HTMLPurifier/Strategy/RemoveForeignElements_ErrorsTest.php @@ -2,69 +2,69 @@ class HTMLPurifier_Strategy_RemoveForeignElements_ErrorsTest extends HTMLPurifier_Strategy_ErrorsHarness { - + public function setup() { parent::setup(); $this->config->set('HTML', 'TidyLevel', 'heavy'); } - + protected function getStrategy() { return new HTMLPurifier_Strategy_RemoveForeignElements(); } - + function testTagTransform() { $this->expectErrorCollection(E_NOTICE, 'Strategy_RemoveForeignElements: Tag transform', 'center'); $this->expectContext('CurrentToken', new HTMLPurifier_Token_Start('div', array('style' => 'text-align:center;'), 1)); $this->invoke('
            '); } - + function testMissingRequiredAttr() { // a little fragile, since img has two required attributes $this->expectErrorCollection(E_ERROR, 'Strategy_RemoveForeignElements: Missing required attribute', 'alt'); $this->expectContext('CurrentToken', new HTMLPurifier_Token_Empty('img', array(), 1)); $this->invoke(''); } - + function testForeignElementToText() { $this->config->set('Core', 'EscapeInvalidTags', true); $this->expectErrorCollection(E_WARNING, 'Strategy_RemoveForeignElements: Foreign element to text'); $this->expectContext('CurrentToken', new HTMLPurifier_Token_Start('invalid', array(), 1)); $this->invoke(''); } - + function testForeignElementRemoved() { // uses $CurrentToken.Serialized $this->expectErrorCollection(E_ERROR, 'Strategy_RemoveForeignElements: Foreign element removed'); $this->expectContext('CurrentToken', new HTMLPurifier_Token_Start('invalid', array(), 1)); $this->invoke(''); } - + function testCommentRemoved() { $this->expectErrorCollection(E_NOTICE, 'Strategy_RemoveForeignElements: Comment removed'); $this->expectContext('CurrentToken', new HTMLPurifier_Token_Comment(' test ', 1)); $this->invoke(''); } - + function testTrailingHyphenInCommentRemoved() { $this->config->set('HTML', 'Trusted', true); $this->expectErrorCollection(E_NOTICE, 'Strategy_RemoveForeignElements: Trailing hyphen in comment removed'); $this->expectContext('CurrentToken', new HTMLPurifier_Token_Comment(' test --', 1)); $this->invoke(''); } - + function testDoubleHyphenInCommentRemoved() { $this->config->set('HTML', 'Trusted', true); $this->expectErrorCollection(E_NOTICE, 'Strategy_RemoveForeignElements: Hyphens in comment collapsed'); $this->expectContext('CurrentToken', new HTMLPurifier_Token_Comment(' test --- test -- test ', 1)); $this->invoke(''); } - + function testForeignMetaElementRemoved() { $this->collector->expectAt(0, 'send', array(E_ERROR, 'Strategy_RemoveForeignElements: Foreign meta element removed')); $this->collector->expectContextAt(0, 'CurrentToken', new HTMLPurifier_Token_Start('script', array(), 1)); $this->collector->expectAt(1, 'send', array(E_ERROR, 'Strategy_RemoveForeignElements: Token removed to end', 'script')); $this->invoke('') ), array('Good', 'Sketchy', 'foo' => '') ); - + $this->assertIsA($this->purifier->context, 'array'); - + } - + function testGetInstance() { $purifier = HTMLPurifier::getInstance(); $purifier2 = HTMLPurifier::getInstance(); $this->assertReference($purifier, $purifier2); } - + function testMakeAbsolute() { $this->config->set('URI', 'Base', 'http://example.com/bar/baz.php'); $this->config->set('URI', 'MakeAbsolute', true); @@ -35,7 +35,7 @@ class HTMLPurifierTest extends HTMLPurifier_Harness 'Foobar' ); } - + function test_addFilter_deprecated() { $this->expectError('HTMLPurifier->addFilter() is deprecated, use configuration directives in the Filter namespace or Filter.Custom'); generate_mock_once('HTMLPurifier_Filter'); @@ -44,6 +44,6 @@ class HTMLPurifierTest extends HTMLPurifier_Harness $mock->expectOnce('postFilter'); $this->purifier->purify('foo'); } - + } diff --git a/tests/PHPT/Controller/SimpleTest.php b/tests/PHPT/Controller/SimpleTest.php index fb962bf6..4d3fa374 100644 --- a/tests/PHPT/Controller/SimpleTest.php +++ b/tests/PHPT/Controller/SimpleTest.php @@ -5,18 +5,18 @@ */ class PHPT_Controller_SimpleTest extends SimpleTestCase { - + protected $_path; - + public function __construct($path) { $this->_path = $path; parent::__construct($path); } - + public function testPhpt() { $suite = new PHPT_Suite(array($this->_path)); $phpt_reporter = new PHPT_Reporter_SimpleTest($this->reporter); $suite->run($phpt_reporter); } - + } diff --git a/tests/PHPT/Reporter/SimpleTest.php b/tests/PHPT/Reporter/SimpleTest.php index f3965ca2..cd5c08f7 100644 --- a/tests/PHPT/Reporter/SimpleTest.php +++ b/tests/PHPT/Reporter/SimpleTest.php @@ -5,18 +5,18 @@ */ class PHPT_Reporter_SimpleTest implements PHPT_Reporter { - + /** SimpleTest reporter to proxy results to */ protected $reporter; - + /** @param SimpleTest reporter */ public function __construct($reporter) { $this->reporter = $reporter; } - + // TODO: Figure out what the proper calls should be, since we've given // each Suite its own UnitTestCase controller - + /** * Called when the Reporter is started from a PHPT_Suite * @todo Figure out if Suites can be named @@ -24,42 +24,42 @@ class PHPT_Reporter_SimpleTest implements PHPT_Reporter public function onSuiteStart(PHPT_Suite $suite) { //$this->reporter->paintGroupStart('PHPT Suite', $suite->count()); } - + /** * Called when the Reporter is finished in a PHPT_Suite */ public function onSuiteEnd(PHPT_Suite $suite) { //$this->reporter->paintGroupEnd('PHPT Suite'); } - + /** * Called when a Case is started */ public function onCaseStart(PHPT_Case $case) { //$this->reporter->paintCaseStart($case->name); } - + /** * Called when a Case ends */ public function onCaseEnd(PHPT_Case $case) { //$this->reporter->paintCaseEnd($case->name); } - + /** * Called when a Case runs without Exception */ public function onCasePass(PHPT_Case $case) { $this->reporter->paintPass("{$case->name} in {$case->filename}"); } - + /** * Called when a PHPT_Case_VetoException is thrown during a Case's run() */ public function onCaseSkip(PHPT_Case $case, PHPT_Case_VetoException $veto) { $this->reporter->paintSkip($veto->getMessage() . ' [' . $case->filename .']'); } - + /** * Called when any Exception other than a PHPT_Case_VetoException is encountered * during a Case's run() @@ -67,9 +67,9 @@ class PHPT_Reporter_SimpleTest implements PHPT_Reporter public function onCaseFail(PHPT_Case $case, PHPT_Case_FailureException $failure) { $this->reporter->paintFail($failure->getReason()); } - + public function onParserError(Exception $exception) { $this->reporter->paintException($exception); } - + } diff --git a/tests/common.php b/tests/common.php index de7cb966..af2e7f5b 100644 --- a/tests/common.php +++ b/tests/common.php @@ -76,12 +76,12 @@ require 'path2class.func.php'; * - Only strings, integers and booleans are accepted * @param $AC * Arguments array to populate. This takes a simple format of 'argument' - * => default value. Depending on the type of the default value, + * => default value. Depending on the type of the default value, * arguments will be typecast accordingly. For example, if * 'flag' => false is passed, all arguments for that will be cast to * boolean. Do *not* pass null, as it will not be recognized. * @param $aliases - * + * */ function htmlpurifier_parse_args(&$AC, $aliases) { if (empty($_GET)) { diff --git a/tests/index.php b/tests/index.php index a9446e4f..a109f7e9 100755 --- a/tests/index.php +++ b/tests/index.php @@ -2,7 +2,7 @@ /** @file * Unit tester - * + * * The heart and soul of HTML Purifier's correctness; anything and everything * is tested here! Arguments are specified like --arg=opt, allowed arguments * are: @@ -132,7 +132,7 @@ foreach ($test_dirs as $dir) { $raw_files = $FS->globr($dir, '*Test.php'); foreach ($raw_files as $file) { $file = str_replace('\\', '/', $file); - if (isset($test_dirs_exclude[$file])) continue; + if (isset($test_dirs_exclude[$file])) continue; $test_files[] = $file; } } @@ -175,19 +175,19 @@ if ($AC['file']) { } if ($AC['file']) { - + $test = new TestSuite($AC['file']); htmlpurifier_add_test($test, $AC['file']); - + } else { - + $standalone = ''; if ($AC['standalone']) $standalone = ' (standalone)'; $test = new TestSuite('All HTML Purifier tests on PHP ' . PHP_VERSION . $standalone); foreach ($test_files as $test_file) { htmlpurifier_add_test($test, $test_file); } - + } if ($AC['dry']) $reporter->makeDry(); diff --git a/tests/multitest.php b/tests/multitest.php index 66c73bc2..4e2b7d4c 100644 --- a/tests/multitest.php +++ b/tests/multitest.php @@ -2,7 +2,7 @@ /** @file * Multiple PHP Versions test - * + * * This file tests HTML Purifier in all versions of PHP. Arguments * are specified like --arg=opt, allowed arguments are: * - quiet (q), if specified no informative messages are enabled (please use @@ -12,16 +12,16 @@ * "--distro=standalone". * - quick, run only the most recent versions of each release series * - disable-flush, by default flush is run, this disables it - * - file (f), xml, type: these correspond to the parameters in index.php - * + * - file (f), xml, type: these correspond to the parameters in index.php + * * @note * It requires a script called phpv that takes an extra argument (the * version number of PHP) before all other arguments. Contact me if you'd * like to set up a similar script. The name of the script can be * edited with $phpv - * + * * @note - * Also, configuration must be set up with a variable called + * Also, configuration must be set up with a variable called * $versions_to_test specifying version numbers to pass to $phpv */ diff --git a/tests/test_files.php b/tests/test_files.php index 6c86c9ae..80ed69d5 100644 --- a/tests/test_files.php +++ b/tests/test_files.php @@ -35,7 +35,7 @@ switch ($AC['type']) { case 'vtest': $vtest_dirs[] = 'HTMLPurifier/ConfigSchema/Validator'; if ($break) break; - + case 'phpt': if (!$AC['disable-phpt'] && version_compare(PHP_VERSION, '5.2', '>=')) { $phpt_dirs[] = 'HTMLPurifier/PHPT';