Latest updates from Amine (7/8/2016)

master
Mahmoud Al-Qudsi 2016-07-12 16:58:19 -05:00
parent 35f6dd81a6
commit b765c8a93d
457 changed files with 44830 additions and 44675 deletions

@ -3,7 +3,7 @@
Plugin Name: Visitors contributions Plugin Name: Visitors contributions
Plugin URI: http://codecanyon.net/user/Leavy Plugin URI: http://codecanyon.net/user/Leavy
Description: A wordpress plugin that gives your visitors the possiblity to develop your website content by submiting new versions to your articles. Description: A wordpress plugin that gives your visitors the possiblity to develop your website content by submiting new versions to your articles.
Version: 1.07 Version: 1.11
Author: Leavy Author: Leavy
Author URI: http://codecanyon.net/user/Leavy Author URI: http://codecanyon.net/user/Leavy
*/ */

@ -1,230 +1,230 @@
/* line 2, style.scss */ /* line 2, style.scss */
* { * {
-webkit-box-sizing: border-box; -webkit-box-sizing: border-box;
-moz-box-sizing: border-box; -moz-box-sizing: border-box;
box-sizing: border-box; box-sizing: border-box;
} }
/* line 3, style.scss */ /* line 3, style.scss */
body { body {
margin: 0; margin: 0;
padding: 0; padding: 0;
font-family: sans-serif; font-family: sans-serif;
} }
/* line 6, _grid.scss */ /* line 6, _grid.scss */
.col-1, .col-m-1, .col-l-1, .col-2, .col-m-2, .col-l-2, .col-3, .col-m-3, .col-l-3, .col-4, .col-m-4, .col-l-4, .col-5, .col-m-5, .col-l-5, .col-6, .col-m-6, .col-l-6, .col-7, .col-m-7, .col-l-7, .col-8, .col-m-8, .col-l-8, .col-9, .col-m-9, .col-l-9, .col-10, .col-m-10, .col-l-10, .col-11, .col-m-11, .col-l-11, .col-12, .col-m-12, .col-l-12 { .col-1, .col-m-1, .col-l-1, .col-2, .col-m-2, .col-l-2, .col-3, .col-m-3, .col-l-3, .col-4, .col-m-4, .col-l-4, .col-5, .col-m-5, .col-l-5, .col-6, .col-m-6, .col-l-6, .col-7, .col-m-7, .col-l-7, .col-8, .col-m-8, .col-l-8, .col-9, .col-m-9, .col-l-9, .col-10, .col-m-10, .col-l-10, .col-11, .col-m-11, .col-l-11, .col-12, .col-m-12, .col-l-12 {
float: right; float: right;
position: relative; position: relative;
min-height: 1px; min-height: 1px;
padding: 0 10px; padding: 0 10px;
/*border: 1px solid rgba(255, 0, 0, 0.5);*/ /*border: 1px solid rgba(255, 0, 0, 0.5);*/
} }
/* line 16, _grid.scss */ /* line 16, _grid.scss */
.col-1 { .col-1 {
width: 8.33333%; width: 8.33333%;
} }
/* line 16, _grid.scss */ /* line 16, _grid.scss */
.col-2 { .col-2 {
width: 16.66667%; width: 16.66667%;
} }
/* line 16, _grid.scss */ /* line 16, _grid.scss */
.col-3 { .col-3 {
width: 25%; width: 25%;
} }
/* line 16, _grid.scss */ /* line 16, _grid.scss */
.col-4 { .col-4 {
width: 33.33333%; width: 33.33333%;
} }
/* line 16, _grid.scss */ /* line 16, _grid.scss */
.col-5 { .col-5 {
width: 41.66667%; width: 41.66667%;
} }
/* line 16, _grid.scss */ /* line 16, _grid.scss */
.col-6 { .col-6 {
width: 50%; width: 50%;
} }
/* line 16, _grid.scss */ /* line 16, _grid.scss */
.col-7 { .col-7 {
width: 58.33333%; width: 58.33333%;
} }
/* line 16, _grid.scss */ /* line 16, _grid.scss */
.col-8 { .col-8 {
width: 66.66667%; width: 66.66667%;
} }
/* line 16, _grid.scss */ /* line 16, _grid.scss */
.col-9 { .col-9 {
width: 75%; width: 75%;
} }
/* line 16, _grid.scss */ /* line 16, _grid.scss */
.col-10 { .col-10 {
width: 83.33333%; width: 83.33333%;
} }
/* line 16, _grid.scss */ /* line 16, _grid.scss */
.col-11 { .col-11 {
width: 91.66667%; width: 91.66667%;
} }
/* line 16, _grid.scss */ /* line 16, _grid.scss */
.col-12 { .col-12 {
width: 100%; width: 100%;
} }
/* line 23, _grid.scss */ /* line 23, _grid.scss */
.row { .row {
margin: 0 -10px; margin: 0 -10px;
overflow: hidden; overflow: hidden;
*zoom: 1; *zoom: 1;
} }
/* line 27, _grid.scss */ /* line 27, _grid.scss */
.col-center { .col-center {
margin: 0 auto; margin: 0 auto;
float: none; float: none;
} }
@media only screen and (min-width: 640px) { @media only screen and (min-width: 640px) {
/* line 30, _grid.scss */ /* line 30, _grid.scss */
.col-m-center { .col-m-center {
margin: 0 auto; margin: 0 auto;
float: none; float: none;
} }
/* line 32, _grid.scss */ /* line 32, _grid.scss */
.col-m-1 { .col-m-1 {
width: 8.33333%; width: 8.33333%;
} }
/* line 32, _grid.scss */ /* line 32, _grid.scss */
.col-m-2 { .col-m-2 {
width: 16.66667%; width: 16.66667%;
} }
/* line 32, _grid.scss */ /* line 32, _grid.scss */
.col-m-3 { .col-m-3 {
width: 25%; width: 25%;
} }
/* line 32, _grid.scss */ /* line 32, _grid.scss */
.col-m-4 { .col-m-4 {
width: 33.33333%; width: 33.33333%;
} }
/* line 32, _grid.scss */ /* line 32, _grid.scss */
.col-m-5 { .col-m-5 {
width: 41.66667%; width: 41.66667%;
} }
/* line 32, _grid.scss */ /* line 32, _grid.scss */
.col-m-6 { .col-m-6 {
width: 50%; width: 50%;
} }
/* line 32, _grid.scss */ /* line 32, _grid.scss */
.col-m-7 { .col-m-7 {
width: 58.33333%; width: 58.33333%;
} }
/* line 32, _grid.scss */ /* line 32, _grid.scss */
.col-m-8 { .col-m-8 {
width: 66.66667%; width: 66.66667%;
} }
/* line 32, _grid.scss */ /* line 32, _grid.scss */
.col-m-9 { .col-m-9 {
width: 75%; width: 75%;
} }
/* line 32, _grid.scss */ /* line 32, _grid.scss */
.col-m-10 { .col-m-10 {
width: 83.33333%; width: 83.33333%;
} }
/* line 32, _grid.scss */ /* line 32, _grid.scss */
.col-m-11 { .col-m-11 {
width: 91.66667%; width: 91.66667%;
} }
/* line 32, _grid.scss */ /* line 32, _grid.scss */
.col-m-12 { .col-m-12 {
width: 100%; width: 100%;
} }
} }
@media only screen and (min-width: 1024px) { @media only screen and (min-width: 1024px) {
/* line 39, _grid.scss */ /* line 39, _grid.scss */
.col-l-center { .col-l-center {
margin: 0 auto; margin: 0 auto;
float: none; float: none;
} }
/* line 41, _grid.scss */ /* line 41, _grid.scss */
.col-l-1 { .col-l-1 {
width: 8.33333%; width: 8.33333%;
} }
/* line 41, _grid.scss */ /* line 41, _grid.scss */
.col-l-2 { .col-l-2 {
width: 16.66667%; width: 16.66667%;
} }
/* line 41, _grid.scss */ /* line 41, _grid.scss */
.col-l-3 { .col-l-3 {
width: 25%; width: 25%;
} }
/* line 41, _grid.scss */ /* line 41, _grid.scss */
.col-l-4 { .col-l-4 {
width: 33.33333%; width: 33.33333%;
} }
/* line 41, _grid.scss */ /* line 41, _grid.scss */
.col-l-5 { .col-l-5 {
width: 41.66667%; width: 41.66667%;
} }
/* line 41, _grid.scss */ /* line 41, _grid.scss */
.col-l-6 { .col-l-6 {
width: 50%; width: 50%;
} }
/* line 41, _grid.scss */ /* line 41, _grid.scss */
.col-l-7 { .col-l-7 {
width: 58.33333%; width: 58.33333%;
} }
/* line 41, _grid.scss */ /* line 41, _grid.scss */
.col-l-8 { .col-l-8 {
width: 66.66667%; width: 66.66667%;
} }
/* line 41, _grid.scss */ /* line 41, _grid.scss */
.col-l-9 { .col-l-9 {
width: 75%; width: 75%;
} }
/* line 41, _grid.scss */ /* line 41, _grid.scss */
.col-l-10 { .col-l-10 {
width: 83.33333%; width: 83.33333%;
} }
/* line 41, _grid.scss */ /* line 41, _grid.scss */
.col-l-11 { .col-l-11 {
width: 91.66667%; width: 91.66667%;
} }
/* line 41, _grid.scss */ /* line 41, _grid.scss */
.col-l-12 { .col-l-12 {
width: 100%; width: 100%;
} }
} }

@ -32,12 +32,14 @@ if(!empty($_POST)){
"visitor_notif_message"=>"Your suggestion was submitted.", "visitor_notif_message"=>"Your suggestion was submitted.",
"admin_notif_message"=>"A new suggestion was submitted." "admin_notif_message"=>"A new suggestion was submitted."
]); ]);
$mail = [ $mail = [
"post_title"=>$post->post_title, "post_title"=>$post->post_title,
"post_url"=>get_permalink($post_id), "post_url"=>get_permalink($post_id),
"visitor_name"=>$visitor_name, "visitor_name"=>$visitor_name,
"visitor_comment"=>$visitor_comment,
"visitor_email"=>$visitor_email, "visitor_email"=>$visitor_email,
"edit_time"=>date('H:i')." - ".date('d/m/y'), "edit_time"=>date('m/d/Y')." at ".date('h:i a'),
"blog_title" => get_bloginfo("name"), "blog_title" => get_bloginfo("name"),
"visitor_notif_message"=>$options["visitor_notif_message"], "visitor_notif_message"=>$options["visitor_notif_message"],
"admin_notif_message"=>$options["admin_notif_message"] "admin_notif_message"=>$options["admin_notif_message"]

@ -14,8 +14,14 @@ class visitors_edits_EMAIL{
"notify_admin"=>null "notify_admin"=>null
]); ]);
$headers = "Content-Type: text/html; charset=UTF-8\r\n"; $headers= "MIME-Version: 1.0\r\n";
wp_mail($destination, $this->subject, $this->body, $headers); $headers .= "Content-Type: text/html; charset=UTF-8\r\n";
wp_mail($destination, $this->subject, $this->body,$headers);
/*
subject : $this->subject
body : $this->body
*/
} }
private function loadTemplate($template){ private function loadTemplate($template){
ob_start(); ob_start();

@ -64,6 +64,11 @@
Author : #visitor_name# (#visitor_email#) Author : #visitor_name# (#visitor_email#)
</td> </td>
</tr> </tr>
<tr>
<td align="center "style="font-family:'Questrial',Helvetica,sans-serif; text-align:center;color:#262626;mso-line-height-rule:exactly;line-height:28px">
Summary : #visitor_comment#
</td>
</tr>
<tr><td height="30" style="font-size:30px; line-height:30px">&nbsp;</td></tr> <tr><td height="30" style="font-size:30px; line-height:30px">&nbsp;</td></tr>
<tr> <tr>
<td align="center "style="font-family:'Questrial',Helvetica,sans-serif; text-align:center;color:#262626;mso-line-height-rule:exactly;line-height:28px"> <td align="center "style="font-family:'Questrial',Helvetica,sans-serif; text-align:center;color:#262626;mso-line-height-rule:exactly;line-height:28px">

@ -1,16 +1,13 @@
visitors_edits_tools={ visitors_edits_tools={
data:{}, data:{},
clearTag:function(content,tag){
var regexp=RegExp("<"+tag+">.*?<\/"+tag+">", "gi");
var editedContent=content.replace(regexp,"");
return editedContent;
},
clearTag:function(content,tag){ clearTag:function(content,tag){
var $contentDiv=jQuery("<div/>").html(content); var $contentDiv=jQuery("<div/>").html(content);
$contentDiv.find(tag).each(function(){ $contentDiv.find(tag).each(function(){
$tag=jQuery(this); $tag=jQuery(this);
$tag.remove(); $tag.remove();
}); });
if($contentDiv.find(tag).length>0)
return visitors_edits_tools.clearTag($contentDiv.html(),tag);
return $contentDiv.html(); return $contentDiv.html();
}, },
clearTagName:function(content,tag){ clearTagName:function(content,tag){
@ -19,6 +16,8 @@ visitors_edits_tools={
$tag=jQuery(this); $tag=jQuery(this);
$tag.replaceWith($tag.html()); $tag.replaceWith($tag.html());
}); });
if($contentDiv.find(tag).length>0)
return visitors_edits_tools.clearTagName($contentDiv.html(),tag);
return $contentDiv.html(); return $contentDiv.html();
}, },
clearClassName:function(content,classname){ clearClassName:function(content,classname){
@ -27,6 +26,8 @@ visitors_edits_tools={
$elm=jQuery(this); $elm=jQuery(this);
$elm.removeClass(classname); $elm.removeClass(classname);
}); });
if($contentDiv.find("."+classname).length>0)
return visitors_edits_tools.clearTagName($contentDiv.html(),classname);
return $contentDiv.html(); return $contentDiv.html();
}, },
clear:function(ed){ clear:function(ed){
@ -87,6 +88,7 @@ visitors_edits_tools={
content=visitors_edits_tools.clearTag(content,"del"); content=visitors_edits_tools.clearTag(content,"del");
content=visitors_edits_tools.clearClassName(content,"diffmod"); content=visitors_edits_tools.clearClassName(content,"diffmod");
ed.setContent(content); ed.setContent(content);
console.log("Cleaned");
}); });
//Load content //Load content
setTimeout(function(){ setTimeout(function(){
@ -117,5 +119,5 @@ visitors_edits_tools={
})(jQuery); })(jQuery);
function editSubmit(){ function editSubmit(){
tinyMCE.activeEditor.execCommand("visitors_edits_clean"); tinyMCE.activeEditor.execCommand("visitors_edits_clean");
return true; return true;
} }

3024
js/jquery.validate.js vendored

File diff suppressed because it is too large Load Diff

@ -0,0 +1,5 @@
composer.lock
vendor/
/demo/bower_components
/demo/node_modules
.DS_Store

@ -0,0 +1,133 @@
imports:
- php
tools:
js_hint: true
php_code_sniffer: true
php_cs_fixer:
config: { level: psr2 }
enabled: true
build:
tests:
override:
-
command: 'vendor/bin/phpunit --coverage-clover=code-coverage-file'
coverage:
file: 'code-coverage-file'
format: 'php-clover'
filter:
excluded_paths:
- tests/*
checks:
php:
uppercase_constants: true
unused_variables: true
unreachable_code: true
unused_methods: true
sql_injection_vulnerabilities: true
spacing_of_function_arguments: true
spacing_around_non_conditional_operators: true
spacing_around_conditional_operators: true
too_many_arguments: true
return_doc_comments: true
require_scope_for_properties: true
require_scope_for_methods: true
require_braces_around_control_structures: true
psr2_control_structure_declaration: true
code_rating: true
duplication: true
variable_existence: true
useless_calls: true
use_statement_alias_conflict: true
unused_properties: true
unused_parameters: true
security_vulnerabilities: true
precedence_mistakes: true
precedence_in_conditions: true
parameter_non_unique: true
no_property_on_interface: true
no_non_implemented_abstract_methods: true
deprecated_code_usage: true
closure_use_not_conflicting: true
closure_use_modifiable: true
avoid_useless_overridden_methods: true
avoid_conflicting_incrementers: true
assignment_of_null_return: true
verify_access_scope_valid: true
symfony_request_injection: true
simplify_boolean_return: true
side_effects_or_types: true
scope_indentation:
spaces_per_level: '4'
return_doc_comment_if_not_inferrable: true
remove_trailing_whitespace: true
remove_php_closing_tag: true
remove_extra_empty_lines: true
psr2_switch_declaration: true
psr2_class_declaration: true
property_assignments: true
properties_in_camelcaps: true
phpunit_assertions: true
php5_style_constructor: true
parameters_in_camelcaps: true
parameter_doc_comments: true
param_doc_comment_if_not_inferrable: true
overriding_private_members: true
one_class_per_file: true
optional_parameters_at_the_end: true
non_commented_empty_catch_block: true
no_unnecessary_if: true
no_unnecessary_function_call_in_for_loop: true
no_space_inside_cast_operator: true
no_space_before_semicolon: true
no_space_around_object_operator: true
no_short_open_tag: true
no_short_method_names:
minimum: '3'
no_goto: true
no_global_keyword: true
no_exit: true
no_eval: true
no_long_variable_names:
maximum: '40'
no_empty_statements: true
no_error_suppression: true
no_else_if_statements: true
no_duplicate_arguments: true
no_debug_code: true
no_commented_out_code: true
missing_arguments: true
method_calls_on_non_object: true
lowercase_php_keywords: true
lowercase_basic_constants: true
instanceof_class_exists: true
function_in_camel_caps: true
fix_use_statements:
remove_unused: true
preserve_multiple: false
preserve_blanklines: false
order_alphabetically: true
fix_identation_4spaces: true
ensure_lower_case_builtin_functions: true
fix_doc_comments: true
avoid_unnecessary_concatenation: true
avoid_entity_manager_injection: true
avoid_closing_tag: true
require_php_tag_first: true
line_length:
max_length: '120'
function_body_start_on_new_line: true
fix_php_opening_tag: true
fix_linefeed: true
classes_in_camel_caps: true
catch_class_exists: true
avoid_tab_indentation: true
avoid_superglobals: true
avoid_multiple_statements_on_same_line: true
avoid_length_functions_in_loops: true
avoid_duplicate_types: true
avoid_corrupting_byteorder_marks: true
argument_type_checks: true
no_underscore_prefix_in_properties: true
no_underscore_prefix_in_methods: true
blank_line_after_namespace_declaration: true
verify_argument_usable_as_reference: true

@ -1,145 +1,145 @@
# Change Log # Change Log
## [v0.1.1](https://github.com/caxy/php-htmldiff/tree/v0.1.1) (2016-03-16) ## [v0.1.1](https://github.com/caxy/php-htmldiff/tree/v0.1.1) (2016-03-16)
[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.1.0...v0.1.1) [Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.1.0...v0.1.1)
**Features and Enhancements:** **Features and Enhancements:**
- Update TableDiff HTMLPurifier Initialization [\#35](https://github.com/caxy/php-htmldiff/pull/35) ([dbergunder](https://github.com/dbergunder)) - Update TableDiff HTMLPurifier Initialization [\#35](https://github.com/caxy/php-htmldiff/pull/35) ([dbergunder](https://github.com/dbergunder))
**Miscellaneous:** **Miscellaneous:**
- Update the README and add additional documentation [\#34](https://github.com/caxy/php-htmldiff/pull/34) ([jschroed91](https://github.com/jschroed91)) - Update the README and add additional documentation [\#34](https://github.com/caxy/php-htmldiff/pull/34) ([jschroed91](https://github.com/jschroed91))
## [0.1.0](https://github.com/caxy/php-htmldiff/tree/0.1.0) (2016-03-10) ## [0.1.0](https://github.com/caxy/php-htmldiff/tree/0.1.0) (2016-03-10)
[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.14...0.1.0) [Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.14...0.1.0)
**Features and Enhancements:** **Features and Enhancements:**
- Allow caching of the calculated diffs using a doctrine cache provider [\#33](https://github.com/caxy/php-htmldiff/pull/33) ([jschroed91](https://github.com/jschroed91)) - Allow caching of the calculated diffs using a doctrine cache provider [\#33](https://github.com/caxy/php-htmldiff/pull/33) ([jschroed91](https://github.com/jschroed91))
- Create configuration class for HtmlDiff config options [\#32](https://github.com/caxy/php-htmldiff/pull/32) ([jschroed91](https://github.com/jschroed91)) - Create configuration class for HtmlDiff config options [\#32](https://github.com/caxy/php-htmldiff/pull/32) ([jschroed91](https://github.com/jschroed91))
- New Feature: Table Diffing [\#31](https://github.com/caxy/php-htmldiff/pull/31) ([jschroed91](https://github.com/jschroed91)) - New Feature: Table Diffing [\#31](https://github.com/caxy/php-htmldiff/pull/31) ([jschroed91](https://github.com/jschroed91))
- Detect link changes to resolve [\#28](https://github.com/caxy/php-htmldiff/issues/28) [\#30](https://github.com/caxy/php-htmldiff/pull/30) ([jschroed91](https://github.com/jschroed91)) - Detect link changes to resolve [\#28](https://github.com/caxy/php-htmldiff/issues/28) [\#30](https://github.com/caxy/php-htmldiff/pull/30) ([jschroed91](https://github.com/jschroed91))
- Setup PHPUnit testsuite with basic functional test and a few test cases [\#26](https://github.com/caxy/php-htmldiff/pull/26) ([jschroed91](https://github.com/jschroed91)) - Setup PHPUnit testsuite with basic functional test and a few test cases [\#26](https://github.com/caxy/php-htmldiff/pull/26) ([jschroed91](https://github.com/jschroed91))
## [0.1.0-beta.1](https://github.com/caxy/php-htmldiff/tree/0.1.0-beta.1) (2016-02-26) ## [0.1.0-beta.1](https://github.com/caxy/php-htmldiff/tree/0.1.0-beta.1) (2016-02-26)
[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.14...0.1.0-beta.1) [Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.14...0.1.0-beta.1)
**Features and Enhancements:** **Features and Enhancements:**
- New Feature: Table Diffing [\#31](https://github.com/caxy/php-htmldiff/pull/31) ([jschroed91](https://github.com/jschroed91)) - New Feature: Table Diffing [\#31](https://github.com/caxy/php-htmldiff/pull/31) ([jschroed91](https://github.com/jschroed91))
- Detect link changes to resolve [\#28](https://github.com/caxy/php-htmldiff/issues/28) [\#30](https://github.com/caxy/php-htmldiff/pull/30) ([jschroed91](https://github.com/jschroed91)) - Detect link changes to resolve [\#28](https://github.com/caxy/php-htmldiff/issues/28) [\#30](https://github.com/caxy/php-htmldiff/pull/30) ([jschroed91](https://github.com/jschroed91))
- Setup PHPUnit testsuite with basic functional test and a few test cases [\#26](https://github.com/caxy/php-htmldiff/pull/26) ([jschroed91](https://github.com/jschroed91)) - Setup PHPUnit testsuite with basic functional test and a few test cases [\#26](https://github.com/caxy/php-htmldiff/pull/26) ([jschroed91](https://github.com/jschroed91))
## [0.0.14](https://github.com/caxy/php-htmldiff/tree/0.0.14) (2016-02-03) ## [0.0.14](https://github.com/caxy/php-htmldiff/tree/0.0.14) (2016-02-03)
[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.13...0.0.14) [Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.13...0.0.14)
**Fixed bugs:** **Fixed bugs:**
- Fix HtmlDiff matching logic skipping over single word matches [\#25](https://github.com/caxy/php-htmldiff/pull/25) ([jschroed91](https://github.com/jschroed91)) - Fix HtmlDiff matching logic skipping over single word matches [\#25](https://github.com/caxy/php-htmldiff/pull/25) ([jschroed91](https://github.com/jschroed91))
## [0.0.13](https://github.com/caxy/php-htmldiff/tree/0.0.13) (2016-01-12) ## [0.0.13](https://github.com/caxy/php-htmldiff/tree/0.0.13) (2016-01-12)
[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.12...0.0.13) [Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.12...0.0.13)
**Fixed bugs:** **Fixed bugs:**
- Misc. list diffing updates and fixes [\#24](https://github.com/caxy/php-htmldiff/pull/24) ([jschroed91](https://github.com/jschroed91)) - Misc. list diffing updates and fixes [\#24](https://github.com/caxy/php-htmldiff/pull/24) ([jschroed91](https://github.com/jschroed91))
- Updated list diff class to maintain the tags on lists. [\#23](https://github.com/caxy/php-htmldiff/pull/23) ([adamCaxy](https://github.com/adamCaxy)) - Updated list diff class to maintain the tags on lists. [\#23](https://github.com/caxy/php-htmldiff/pull/23) ([adamCaxy](https://github.com/adamCaxy))
## [0.0.12](https://github.com/caxy/php-htmldiff/tree/0.0.12) (2015-11-11) ## [0.0.12](https://github.com/caxy/php-htmldiff/tree/0.0.12) (2015-11-11)
[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.11...0.0.12) [Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.11...0.0.12)
**Fixed bugs:** **Fixed bugs:**
- feature-list\_diffing-new [\#20](https://github.com/caxy/php-htmldiff/pull/20) ([adamCaxy](https://github.com/adamCaxy)) - feature-list\_diffing-new [\#20](https://github.com/caxy/php-htmldiff/pull/20) ([adamCaxy](https://github.com/adamCaxy))
## [0.0.11](https://github.com/caxy/php-htmldiff/tree/0.0.11) (2015-11-06) ## [0.0.11](https://github.com/caxy/php-htmldiff/tree/0.0.11) (2015-11-06)
[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.10...0.0.11) [Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.10...0.0.11)
**Features and Enhancements:** **Features and Enhancements:**
- Feature list diffing new [\#19](https://github.com/caxy/php-htmldiff/pull/19) ([adamCaxy](https://github.com/adamCaxy)) - Feature list diffing new [\#19](https://github.com/caxy/php-htmldiff/pull/19) ([adamCaxy](https://github.com/adamCaxy))
## [0.0.10](https://github.com/caxy/php-htmldiff/tree/0.0.10) (2015-10-21) ## [0.0.10](https://github.com/caxy/php-htmldiff/tree/0.0.10) (2015-10-21)
[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.9...0.0.10) [Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.9...0.0.10)
**Fixed bugs:** **Fixed bugs:**
- Fix: Updated code so that null is not given in list formatting. [\#17](https://github.com/caxy/php-htmldiff/pull/17) ([adamCaxy](https://github.com/adamCaxy)) - Fix: Updated code so that null is not given in list formatting. [\#17](https://github.com/caxy/php-htmldiff/pull/17) ([adamCaxy](https://github.com/adamCaxy))
## [0.0.9](https://github.com/caxy/php-htmldiff/tree/0.0.9) (2015-10-20) ## [0.0.9](https://github.com/caxy/php-htmldiff/tree/0.0.9) (2015-10-20)
[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.8...0.0.9) [Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.8...0.0.9)
**Fixed bugs:** **Fixed bugs:**
- Missed an array\_column in ListDiff. Updated to use ArrayColumn function. [\#16](https://github.com/caxy/php-htmldiff/pull/16) ([jschroed91](https://github.com/jschroed91)) - Missed an array\_column in ListDiff. Updated to use ArrayColumn function. [\#16](https://github.com/caxy/php-htmldiff/pull/16) ([jschroed91](https://github.com/jschroed91))
## [0.0.8](https://github.com/caxy/php-htmldiff/tree/0.0.8) (2015-10-20) ## [0.0.8](https://github.com/caxy/php-htmldiff/tree/0.0.8) (2015-10-20)
[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.7...0.0.8) [Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.7...0.0.8)
**Fixed bugs:** **Fixed bugs:**
- Added update for php versions that do not have array\_column as a function. [\#15](https://github.com/caxy/php-htmldiff/pull/15) ([jschroed91](https://github.com/jschroed91)) - Added update for php versions that do not have array\_column as a function. [\#15](https://github.com/caxy/php-htmldiff/pull/15) ([jschroed91](https://github.com/jschroed91))
## [0.0.7](https://github.com/caxy/php-htmldiff/tree/0.0.7) (2015-10-20) ## [0.0.7](https://github.com/caxy/php-htmldiff/tree/0.0.7) (2015-10-20)
[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.6...0.0.7) [Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.6...0.0.7)
**Features and Enhancements:** **Features and Enhancements:**
- Created ListDiff class to handle diffing of lists. [\#14](https://github.com/caxy/php-htmldiff/pull/14) ([adamCaxy](https://github.com/adamCaxy)) - Created ListDiff class to handle diffing of lists. [\#14](https://github.com/caxy/php-htmldiff/pull/14) ([adamCaxy](https://github.com/adamCaxy))
## [0.0.6](https://github.com/caxy/php-htmldiff/tree/0.0.6) (2015-09-11) ## [0.0.6](https://github.com/caxy/php-htmldiff/tree/0.0.6) (2015-09-11)
[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.5...0.0.6) [Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.5...0.0.6)
**Features and Enhancements:** **Features and Enhancements:**
- Feature - html tag isolation [\#12](https://github.com/caxy/php-htmldiff/pull/12) ([jschroed91](https://github.com/jschroed91)) - Feature - html tag isolation [\#12](https://github.com/caxy/php-htmldiff/pull/12) ([jschroed91](https://github.com/jschroed91))
- ICC-4313 | ICC-4314 | Replace Special HTML Elements with placeholder tokens and update diffing logic [\#11](https://github.com/caxy/php-htmldiff/pull/11) ([usaqlain01](https://github.com/usaqlain01)) - ICC-4313 | ICC-4314 | Replace Special HTML Elements with placeholder tokens and update diffing logic [\#11](https://github.com/caxy/php-htmldiff/pull/11) ([usaqlain01](https://github.com/usaqlain01))
## [0.0.5](https://github.com/caxy/php-htmldiff/tree/0.0.5) (2015-03-03) ## [0.0.5](https://github.com/caxy/php-htmldiff/tree/0.0.5) (2015-03-03)
[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.4...0.0.5) [Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.4...0.0.5)
**Features and Enhancements:** **Features and Enhancements:**
- Support derived classes [\#10](https://github.com/caxy/php-htmldiff/pull/10) ([mkalkbrenner](https://github.com/mkalkbrenner)) - Support derived classes [\#10](https://github.com/caxy/php-htmldiff/pull/10) ([mkalkbrenner](https://github.com/mkalkbrenner))
## [0.0.4](https://github.com/caxy/php-htmldiff/tree/0.0.4) (2015-01-09) ## [0.0.4](https://github.com/caxy/php-htmldiff/tree/0.0.4) (2015-01-09)
[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.3...0.0.4) [Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.3...0.0.4)
**Fixed bugs:** **Fixed bugs:**
- Check for empty oldText or newText before processing del or ins in processReplaceOperation [\#9](https://github.com/caxy/php-htmldiff/pull/9) ([jschroed91](https://github.com/jschroed91)) - Check for empty oldText or newText before processing del or ins in processReplaceOperation [\#9](https://github.com/caxy/php-htmldiff/pull/9) ([jschroed91](https://github.com/jschroed91))
## [0.0.3](https://github.com/caxy/php-htmldiff/tree/0.0.3) (2015-01-08) ## [0.0.3](https://github.com/caxy/php-htmldiff/tree/0.0.3) (2015-01-08)
[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.2...0.0.3) [Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.2...0.0.3)
**Features and Enhancements:** **Features and Enhancements:**
- Add option to insert a space between del and ins tags [\#8](https://github.com/caxy/php-htmldiff/pull/8) ([jschroed91](https://github.com/jschroed91)) - Add option to insert a space between del and ins tags [\#8](https://github.com/caxy/php-htmldiff/pull/8) ([jschroed91](https://github.com/jschroed91))
- Updated demo to accept input and diff on the fly [\#5](https://github.com/caxy/php-htmldiff/pull/5) ([jschroed91](https://github.com/jschroed91)) - Updated demo to accept input and diff on the fly [\#5](https://github.com/caxy/php-htmldiff/pull/5) ([jschroed91](https://github.com/jschroed91))
## [0.0.2](https://github.com/caxy/php-htmldiff/tree/0.0.2) (2014-08-12) ## [0.0.2](https://github.com/caxy/php-htmldiff/tree/0.0.2) (2014-08-12)
[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.1...0.0.2) [Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.1...0.0.2)
**Features and Enhancements:** **Features and Enhancements:**
- Break out HTML content to individual HTML, CSS, JS files [\#6](https://github.com/caxy/php-htmldiff/pull/6) ([mgersten-caxy](https://github.com/mgersten-caxy)) - Break out HTML content to individual HTML, CSS, JS files [\#6](https://github.com/caxy/php-htmldiff/pull/6) ([mgersten-caxy](https://github.com/mgersten-caxy))
**Fixed bugs:** **Fixed bugs:**
- Fix error caused when passing empty array into setSpecialCaseTags [\#7](https://github.com/caxy/php-htmldiff/pull/7) ([jschroed91](https://github.com/jschroed91)) - Fix error caused when passing empty array into setSpecialCaseTags [\#7](https://github.com/caxy/php-htmldiff/pull/7) ([jschroed91](https://github.com/jschroed91))
## [0.0.1](https://github.com/caxy/php-htmldiff/tree/0.0.1) (2014-07-31) ## [0.0.1](https://github.com/caxy/php-htmldiff/tree/0.0.1) (2014-07-31)
**Features and Enhancements:** **Features and Enhancements:**
- Added static properties for the default config variables [\#4](https://github.com/caxy/php-htmldiff/pull/4) ([jschroed91](https://github.com/jschroed91)) - Added static properties for the default config variables [\#4](https://github.com/caxy/php-htmldiff/pull/4) ([jschroed91](https://github.com/jschroed91))
- Feature nonpartial word diffing [\#3](https://github.com/caxy/php-htmldiff/pull/3) ([jschroed91](https://github.com/jschroed91)) - Feature nonpartial word diffing [\#3](https://github.com/caxy/php-htmldiff/pull/3) ([jschroed91](https://github.com/jschroed91))
- Added option to group together diffed words in output [\#2](https://github.com/caxy/php-htmldiff/pull/2) ([jschroed91](https://github.com/jschroed91)) - Added option to group together diffed words in output [\#2](https://github.com/caxy/php-htmldiff/pull/2) ([jschroed91](https://github.com/jschroed91))
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*

@ -1,74 +1,74 @@
# Contributor Covenant Code of Conduct # Contributor Covenant Code of Conduct
## Our Pledge ## Our Pledge
In the interest of fostering an open and welcoming environment, we as In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience, size, disability, ethnicity, gender identity and expression, level of experience,
nationality, personal appearance, race, religion, or sexual identity and nationality, personal appearance, race, religion, or sexual identity and
orientation. orientation.
## Our Standards ## Our Standards
Examples of behavior that contributes to creating a positive environment Examples of behavior that contributes to creating a positive environment
include: include:
* Using welcoming and inclusive language * Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences * Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism * Gracefully accepting constructive criticism
* Focusing on what is best for the community * Focusing on what is best for the community
* Showing empathy towards other community members * Showing empathy towards other community members
Examples of unacceptable behavior by participants include: Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or * The use of sexualized language or imagery and unwelcome sexual attention or
advances advances
* Trolling, insulting/derogatory comments, and personal or political attacks * Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment * Public or private harassment
* Publishing others' private information, such as a physical or electronic * Publishing others' private information, such as a physical or electronic
address, without explicit permission address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a * Other conduct which could reasonably be considered inappropriate in a
professional setting professional setting
## Our Responsibilities ## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior. response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate, permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful. threatening, offensive, or harmful.
## Scope ## Scope
This Code of Conduct applies both within project spaces and in public spaces This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers. further defined and clarified by project maintainers.
## Enforcement ## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at dev@caxy.com. All reported by contacting the project team at dev@caxy.com. All
complaints will be reviewed and investigated and will result in a response that complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident. obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other faith may face temporary or permanent repercussions as determined by other
members of the project's leadership. members of the project's leadership.
## Attribution ## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at [http://contributor-covenant.org/version/1/4][version] available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org [homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/ [version]: http://contributor-covenant.org/version/1/4/

@ -1,33 +1,33 @@
Contributing Contributing
============ ============
First of all, **thank you** for contributing, **you are awesome**! First of all, **thank you** for contributing, **you are awesome**!
Here are a few rules to follow in order to ease code reviews, and discussions before Here are a few rules to follow in order to ease code reviews, and discussions before
maintainers accept and merge your work. maintainers accept and merge your work.
You MUST follow the [PSR-1](http://www.php-fig.org/psr/1/) and You MUST follow the [PSR-1](http://www.php-fig.org/psr/1/) and
[PSR-2](http://www.php-fig.org/psr/2/). If you don't know about any of them, you [PSR-2](http://www.php-fig.org/psr/2/). If you don't know about any of them, you
should really read the recommendations. Can't wait? Use the [PHP-CS-Fixer should really read the recommendations. Can't wait? Use the [PHP-CS-Fixer
tool](http://cs.sensiolabs.org/). tool](http://cs.sensiolabs.org/).
You MUST run the test suite. You MUST run the test suite.
You MUST write (or update) unit tests. You MUST write (or update) unit tests.
You SHOULD write documentation. You SHOULD write documentation.
Please, write [commit messages that make Please, write [commit messages that make
sense](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html), sense](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html),
and [rebase your branch](http://git-scm.com/book/en/Git-Branching-Rebasing) and [rebase your branch](http://git-scm.com/book/en/Git-Branching-Rebasing)
before submitting your Pull Request. before submitting your Pull Request.
One may ask you to [squash your One may ask you to [squash your
commits](http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html) commits](http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html)
too. This is used to "clean" your Pull Request before merging it (we don't want too. This is used to "clean" your Pull Request before merging it (we don't want
commits such as `fix tests`, `fix 2`, `fix 3`, etc.). commits such as `fix tests`, `fix 2`, `fix 3`, etc.).
Also, while creating your Pull Request on GitHub, you MUST write a description Also, while creating your Pull Request on GitHub, you MUST write a description
which gives the context and/or explains why you are creating it. which gives the context and/or explains why you are creating it.
Thank you! Thank you!

@ -1,130 +1,130 @@
GNU GENERAL PUBLIC LICENSE GNU GENERAL PUBLIC LICENSE
Version 2, June 1991 Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc. Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
Everyone is permitted to copy and distribute verbatim copies Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed. of this license document, but changing it is not allowed.
Preamble Preamble
The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too.
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.
Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and modification follow. The precise terms and conditions for copying, distribution and modification follow.
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.
You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License.
c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.
In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.
7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.
This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.
10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
NO WARRANTY NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.
one line to give the program's name and an idea of what it does. one line to give the program's name and an idea of what it does.
Copyright (C) yyyy name of author Copyright (C) yyyy name of author
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Also add information on how to contact you by electronic and paper mail. Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this when it starts in an interactive mode: If the program is interactive, make it output a short notice like this when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details Gnomovision comes with ABSOLUTELY NO WARRANTY; for details
type `show w'. This is free software, and you are welcome type `show w'. This is free software, and you are welcome
to redistribute it under certain conditions; type `show c' to redistribute it under certain conditions; type `show c'
for details. for details.
The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright Yoyodyne, Inc., hereby disclaims all copyright
interest in the program `Gnomovision' interest in the program `Gnomovision'
(which makes passes at compilers) written (which makes passes at compilers) written
by James Hacker. by James Hacker.
signature of Ty Coon, 1 April 1989 signature of Ty Coon, 1 April 1989
Ty Coon, President of Vice Ty Coon, President of Vice
This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License.

@ -1,201 +1,201 @@
php-htmldiff php-htmldiff
============ ============
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/caxy/php-htmldiff/badges/quality-score.png?b=master)][badge_score] [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/caxy/php-htmldiff/badges/quality-score.png?b=master)][badge_score]
[![Build Status](https://scrutinizer-ci.com/g/caxy/php-htmldiff/badges/build.png?b=master)][badge_status] [![Build Status](https://scrutinizer-ci.com/g/caxy/php-htmldiff/badges/build.png?b=master)][badge_status]
[![Code Coverage](https://scrutinizer-ci.com/g/caxy/php-htmldiff/badges/coverage.png?b=master)][badge_coverage] [![Code Coverage](https://scrutinizer-ci.com/g/caxy/php-htmldiff/badges/coverage.png?b=master)][badge_coverage]
[![Packagist](https://img.shields.io/packagist/dt/caxy/php-htmldiff.svg)][badge_packagist] [![Packagist](https://img.shields.io/packagist/dt/caxy/php-htmldiff.svg)][badge_packagist]
[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/caxy/php-htmldiff.svg)][badge_resolve] [![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/caxy/php-htmldiff.svg)][badge_resolve]
[![Percentage of issues still open](http://isitmaintained.com/badge/open/caxy/php-htmldiff.svg)][badge_issues] [![Percentage of issues still open](http://isitmaintained.com/badge/open/caxy/php-htmldiff.svg)][badge_issues]
php-htmldiff is a library for comparing two HTML files/snippets and highlighting the differences using simple HTML. php-htmldiff is a library for comparing two HTML files/snippets and highlighting the differences using simple HTML.
This HTML Diff implementation was forked from [rashid2538/php-htmldiff][upstream] and has been modified with new features, This HTML Diff implementation was forked from [rashid2538/php-htmldiff][upstream] and has been modified with new features,
bug fixes, and enhancements to the original code. bug fixes, and enhancements to the original code.
For more information on these modifications, read the [differences from rashid2538/php-htmldiff][differences] or view the [CHANGELOG][changelog]. For more information on these modifications, read the [differences from rashid2538/php-htmldiff][differences] or view the [CHANGELOG][changelog].
## Installation ## Installation
The recommended way to install php-htmldiff is through [Composer][composer]. The recommended way to install php-htmldiff is through [Composer][composer].
Require the [caxy/php-htmldiff][badge_packagist] package by running following command: Require the [caxy/php-htmldiff][badge_packagist] package by running following command:
```sh ```sh
composer require caxy/php-htmldiff composer require caxy/php-htmldiff
``` ```
This will resolve the latest stable version. This will resolve the latest stable version.
Otherwise, install the library and setup the autoloader yourself. Otherwise, install the library and setup the autoloader yourself.
### Working with Symfony ### Working with Symfony
If you are using Symfony, you can use the [caxy/HtmlDiffBundle][htmldiffbundle] to make life easy! If you are using Symfony, you can use the [caxy/HtmlDiffBundle][htmldiffbundle] to make life easy!
## Usage ## Usage
```php ```php
use Caxy\HtmlDiff\HtmlDiff; use Caxy\HtmlDiff\HtmlDiff;
$htmlDiff = new HtmlDiff($oldHtml, $newHtml); $htmlDiff = new HtmlDiff($oldHtml, $newHtml);
$content = $htmlDiff->build(); $content = $htmlDiff->build();
``` ```
## Configuration ## Configuration
The configuration for HtmlDiff is contained in the `Caxy\HtmlDiff\HtmlDiffConfig` class. The configuration for HtmlDiff is contained in the `Caxy\HtmlDiff\HtmlDiffConfig` class.
There are two ways to set the configuration: There are two ways to set the configuration:
1. [Configure an Existing HtmlDiff Object](#configure-an-existing-htmldiff-object) 1. [Configure an Existing HtmlDiff Object](#configure-an-existing-htmldiff-object)
2. [Create and Use a HtmlDiffConfig Object](#create-and-use-a-htmldiffconfig-object) 2. [Create and Use a HtmlDiffConfig Object](#create-and-use-a-htmldiffconfig-object)
#### Configure an Existing HtmlDiff Object #### Configure an Existing HtmlDiff Object
When a new `HtmlDiff` object is created, it creates a `HtmlDiffConfig` object with the default configuration. When a new `HtmlDiff` object is created, it creates a `HtmlDiffConfig` object with the default configuration.
You can change the configuration using setters on the object: You can change the configuration using setters on the object:
```php ```php
use Caxy\HtmlDiff\HtmlDiff; use Caxy\HtmlDiff\HtmlDiff;
// ... // ...
$htmlDiff = new HtmlDiff($oldHtml, $newHtml); $htmlDiff = new HtmlDiff($oldHtml, $newHtml);
// Set some of the configuration options. // Set some of the configuration options.
$htmlDiff->getConfig() $htmlDiff->getConfig()
->setMatchThreshold(80) ->setMatchThreshold(80)
->setInsertSpaceInReplace(true) ->setInsertSpaceInReplace(true)
; ;
// Calculate the differences using the configuration and get the html diff. // Calculate the differences using the configuration and get the html diff.
$content = $htmlDiff->build(); $content = $htmlDiff->build();
// ... // ...
``` ```
#### Create and Use a HtmlDiffConfig Object #### Create and Use a HtmlDiffConfig Object
You can also set the configuration by creating an instance of You can also set the configuration by creating an instance of
`Caxy\HtmlDiff\HtmlDiffConfig` and using it when creating a new `HtmlDiff` `Caxy\HtmlDiff\HtmlDiffConfig` and using it when creating a new `HtmlDiff`
object using `HtmlDiff::create`. object using `HtmlDiff::create`.
This is useful when creating more than one instance of `HtmlDiff`: This is useful when creating more than one instance of `HtmlDiff`:
```php ```php
use Caxy\HtmlDiff\HtmlDiff; use Caxy\HtmlDiff\HtmlDiff;
use Caxy\HtmlDiff\HtmlDiffConfig; use Caxy\HtmlDiff\HtmlDiffConfig;
// ... // ...
$config = new HtmlDiffConfig(); $config = new HtmlDiffConfig();
$config $config
->setMatchThreshold(95) ->setMatchThreshold(95)
->setInsertSpaceInReplace(true) ->setInsertSpaceInReplace(true)
; ;
// Create an HtmlDiff object with the custom configuration. // Create an HtmlDiff object with the custom configuration.
$firstHtmlDiff = HtmlDiff::create($oldHtml, $newHtml, $config); $firstHtmlDiff = HtmlDiff::create($oldHtml, $newHtml, $config);
$firstContent = $firstHtmlDiff->build(); $firstContent = $firstHtmlDiff->build();
$secondHtmlDiff = HtmlDiff::create($oldHtml2, $newHtml2, $config); $secondHtmlDiff = HtmlDiff::create($oldHtml2, $newHtml2, $config);
$secondHtmlDiff->getConfig()->setMatchThreshold(50); $secondHtmlDiff->getConfig()->setMatchThreshold(50);
$secondContent = $secondHtmlDiff->build(); $secondContent = $secondHtmlDiff->build();
// ... // ...
``` ```
#### Full Configuration with Defaults: #### Full Configuration with Defaults:
```php ```php
$config = new HtmlDiffConfig(); $config = new HtmlDiffConfig();
$config $config
// Percentage required for list items to be considered a match. // Percentage required for list items to be considered a match.
->setMatchThreshold(80) ->setMatchThreshold(80)
// Set the encoding of the text to be diffed. // Set the encoding of the text to be diffed.
->setEncoding('UTF-8') ->setEncoding('UTF-8')
// If true, a space will be added between the <del> and <ins> tags of text that was replaced. // If true, a space will be added between the <del> and <ins> tags of text that was replaced.
->setInsertSpaceInReplace(false) ->setInsertSpaceInReplace(false)
// Option to disable the new Table Diffing feature and treat tables as regular text. // Option to disable the new Table Diffing feature and treat tables as regular text.
->setUseTableDiffing(true) ->setUseTableDiffing(true)
// Pass an instance of \Doctrine\Common\Cache\Cache to cache the calculated diffs. // Pass an instance of \Doctrine\Common\Cache\Cache to cache the calculated diffs.
->setCacheProvider(null) ->setCacheProvider(null)
// Set the cache directory that HTMLPurifier should use. // Set the cache directory that HTMLPurifier should use.
->setPurifierCacheLocation(null) ->setPurifierCacheLocation(null)
// Group consecutive deletions and insertions instead of showing a deletion and insertion for each word individually. // Group consecutive deletions and insertions instead of showing a deletion and insertion for each word individually.
->setGroupDiffs(true) ->setGroupDiffs(true)
// List of characters to consider part of a single word when in the middle of text. // List of characters to consider part of a single word when in the middle of text.
->setSpecialCaseChars(array('.', ',', '(', ')', '\'')) ->setSpecialCaseChars(array('.', ',', '(', ')', '\''))
// List of tags to treat as special case tags. // List of tags to treat as special case tags.
->setSpecialCaseTags(array('strong', 'b', 'i', 'big', 'small', 'u', 'sub', 'sup', 'strike', 's', 'p')) ->setSpecialCaseTags(array('strong', 'b', 'i', 'big', 'small', 'u', 'sub', 'sup', 'strike', 's', 'p'))
// List of tags (and their replacement strings) to be diffed in isolation. // List of tags (and their replacement strings) to be diffed in isolation.
->setIsolatedDiffTags(array( ->setIsolatedDiffTags(array(
'ol' => '[[REPLACE_ORDERED_LIST]]', 'ol' => '[[REPLACE_ORDERED_LIST]]',
'ul' => '[[REPLACE_UNORDERED_LIST]]', 'ul' => '[[REPLACE_UNORDERED_LIST]]',
'sub' => '[[REPLACE_SUB_SCRIPT]]', 'sub' => '[[REPLACE_SUB_SCRIPT]]',
'sup' => '[[REPLACE_SUPER_SCRIPT]]', 'sup' => '[[REPLACE_SUPER_SCRIPT]]',
'dl' => '[[REPLACE_DEFINITION_LIST]]', 'dl' => '[[REPLACE_DEFINITION_LIST]]',
'table' => '[[REPLACE_TABLE]]', 'table' => '[[REPLACE_TABLE]]',
'strong' => '[[REPLACE_STRONG]]', 'strong' => '[[REPLACE_STRONG]]',
'b' => '[[REPLACE_B]]', 'b' => '[[REPLACE_B]]',
'em' => '[[REPLACE_EM]]', 'em' => '[[REPLACE_EM]]',
'i' => '[[REPLACE_I]]', 'i' => '[[REPLACE_I]]',
'a' => '[[REPLACE_A]]', 'a' => '[[REPLACE_A]]',
)) ))
; ;
``` ```
## Contributing ## Contributing
See [CONTRIBUTING][contributing] file. See [CONTRIBUTING][contributing] file.
## Contributor Code of Conduct ## Contributor Code of Conduct
Please note that this project is released with a [Contributor Code of Please note that this project is released with a [Contributor Code of
Conduct][contributor_covenant]. By participating in this project Conduct][contributor_covenant]. By participating in this project
you agree to abide by its terms. See [CODE_OF_CONDUCT][code_of_conduct] file. you agree to abide by its terms. See [CODE_OF_CONDUCT][code_of_conduct] file.
## Credits ## Credits
* [rashid2538][] for the port to PHP and the base for our project: [rashid2538/php-htmldiff][upstream] * [rashid2538][] for the port to PHP and the base for our project: [rashid2538/php-htmldiff][upstream]
* [willdurand][] for an excellent post on [open sourcing libraries][]. * [willdurand][] for an excellent post on [open sourcing libraries][].
Much of this documentation is based off of the examples in the post. Much of this documentation is based off of the examples in the post.
Did we miss anyone? If we did, let us know or put in a pull request! Did we miss anyone? If we did, let us know or put in a pull request!
## License ## License
php-htmldiff is available under [GNU General Public License, version 2][gnu]. See the [LICENSE][license] file for details. php-htmldiff is available under [GNU General Public License, version 2][gnu]. See the [LICENSE][license] file for details.
[badge_score]: https://scrutinizer-ci.com/g/caxy/php-htmldiff/?branch=master [badge_score]: https://scrutinizer-ci.com/g/caxy/php-htmldiff/?branch=master
[badge_status]: https://scrutinizer-ci.com/g/caxy/php-htmldiff/build-status/master [badge_status]: https://scrutinizer-ci.com/g/caxy/php-htmldiff/build-status/master
[badge_coverage]: https://scrutinizer-ci.com/g/caxy/php-htmldiff/?branch=master [badge_coverage]: https://scrutinizer-ci.com/g/caxy/php-htmldiff/?branch=master
[badge_packagist]: https://packagist.org/packages/caxy/php-htmldiff [badge_packagist]: https://packagist.org/packages/caxy/php-htmldiff
[badge_resolve]: http://isitmaintained.com/project/caxy/php-htmldiff "Average time to resolve an issue" [badge_resolve]: http://isitmaintained.com/project/caxy/php-htmldiff "Average time to resolve an issue"
[badge_issues]: http://isitmaintained.com/project/caxy/php-htmldiff "Percentage of issues still open" [badge_issues]: http://isitmaintained.com/project/caxy/php-htmldiff "Percentage of issues still open"
[upstream]: https://github.com/rashid2538/php-htmldiff [upstream]: https://github.com/rashid2538/php-htmldiff
[htmldiffbundle]: https://github.com/caxy/HtmlDiffBundle [htmldiffbundle]: https://github.com/caxy/HtmlDiffBundle
[differences]: https://github.com/caxy/php-htmldiff/blob/master/doc/differences.rst [differences]: https://github.com/caxy/php-htmldiff/blob/master/doc/differences.rst
[changelog]: https://github.com/caxy/php-htmldiff/blob/master/CHANGELOG.md [changelog]: https://github.com/caxy/php-htmldiff/blob/master/CHANGELOG.md
[contributing]: https://github.com/caxy/php-htmldiff/blob/master/CONTRIBUTING.md [contributing]: https://github.com/caxy/php-htmldiff/blob/master/CONTRIBUTING.md
[gnu]: http://www.gnu.org/licenses/gpl-2.0.html [gnu]: http://www.gnu.org/licenses/gpl-2.0.html
[license]: https://github.com/caxy/php-htmldiff/blob/master/LICENSE [license]: https://github.com/caxy/php-htmldiff/blob/master/LICENSE
[code_of_conduct]: https://github.com/caxy/php-htmldiff/blob/master/CODE_OF_CONDUCT.md [code_of_conduct]: https://github.com/caxy/php-htmldiff/blob/master/CODE_OF_CONDUCT.md
[composer]: http://getcomposer.org/ [composer]: http://getcomposer.org/
[contributor_covenant]: http://contributor-covenant.org/ [contributor_covenant]: http://contributor-covenant.org/
[rashid2538]: https://github.com/rashid2538 [rashid2538]: https://github.com/rashid2538
[willdurand]: https://github.com/willdurand [willdurand]: https://github.com/willdurand
[open sourcing libraries]: http://williamdurand.fr/2013/07/04/on-open-sourcing-libraries/ [open sourcing libraries]: http://williamdurand.fr/2013/07/04/on-open-sourcing-libraries/

@ -1,43 +1,43 @@
{ {
"name": "caxy/php-htmldiff", "name": "caxy/php-htmldiff",
"type": "library", "type": "library",
"description": "A library for comparing two HTML files/snippets and highlighting the differences using simple HTML.", "description": "A library for comparing two HTML files/snippets and highlighting the differences using simple HTML.",
"keywords": [ "keywords": [
"diff", "diff",
"html" "html"
], ],
"homepage": "https://github.com/caxy/php-htmldiff", "homepage": "https://github.com/caxy/php-htmldiff",
"license": "GPL-2.0", "license": "GPL-2.0",
"authors": [ "authors": [
{ {
"name": "Josh Schroeder", "name": "Josh Schroeder",
"email": "jschroeder@caxy.com", "email": "jschroeder@caxy.com",
"homepage": "http://www.caxy.com" "homepage": "http://www.caxy.com"
} }
], ],
"support": { "support": {
"issues": "https://github.com/caxy/php-htmldiff/issues" "issues": "https://github.com/caxy/php-htmldiff/issues"
}, },
"require": { "require": {
"php": ">=5.3.3", "php": ">=5.3.3",
"ezyang/htmlpurifier": "^4.7" "ezyang/htmlpurifier": "^4.7"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "~4.8", "phpunit/phpunit": "~4.8",
"doctrine/cache": "~1.0" "doctrine/cache": "~1.0"
}, },
"suggest": { "suggest": {
"doctrine/cache": "Used for caching the calculated diffs using a Doctrine Cache Provider" "doctrine/cache": "Used for caching the calculated diffs using a Doctrine Cache Provider"
}, },
"autoload": { "autoload": {
"psr-0": { "Caxy\\HtmlDiff": "lib/" } "psr-0": { "Caxy\\HtmlDiff": "lib/" }
}, },
"autoload-dev": { "autoload-dev": {
"psr-4": { "Caxy\\Tests\\": "tests/Caxy/Tests" } "psr-4": { "Caxy\\Tests\\": "tests/Caxy/Tests" }
}, },
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "0.1.x-dev" "dev-master": "0.1.x-dev"
} }
} }
} }

@ -1 +1 @@
Just write the code as shown in php file and enjoy. Just write the code as shown in php file and enjoy.

@ -1,16 +1,16 @@
{ {
"name": "php-htmldiff-demo", "name": "php-htmldiff-demo",
"dependencies": { "dependencies": {
"bootstrap": "v4.0.0-alpha.2", "bootstrap": "v4.0.0-alpha.2",
"angular": "1.5.0", "angular": "1.5.0",
"clipboard": "^1.5.8", "clipboard": "^1.5.8",
"font-awesome": "^4.5.0", "font-awesome": "^4.5.0",
"angular-sanitize": "^1.5.0", "angular-sanitize": "^1.5.0",
"tether": "^1.2.0", "tether": "^1.2.0",
"ng-ckeditor": "^0.2.1", "ng-ckeditor": "^0.2.1",
"ckeditor": "^4.5.7", "ckeditor": "^4.5.7",
"angular-ui": "^0.4.0", "angular-ui": "^0.4.0",
"AngularJS-Toaster": "angularjs-toaster#^1.2.0", "AngularJS-Toaster": "angularjs-toaster#^1.2.0",
"angular-bootstrap": "^1.1.2" "angular-bootstrap": "^1.1.2"
} }
} }

@ -1,276 +1,276 @@
/* /*
Document : codes Document : codes
Created on : Sep 23, 2013, 4:41:58 PM Created on : Sep 23, 2013, 4:41:58 PM
Author : mgersten Author : mgersten
Description: CSS related to I-code specific display Description: CSS related to I-code specific display
*/ */
.diff-list > li.normal, .diff-list > li.normal,
.diff-list > li.removed, .diff-list > li.removed,
.diff-list > li.replacement{ .diff-list > li.replacement{
display: table-row; display: table-row;
} }
.diff-list > li.normal:before, .diff-list > li.normal:before,
.diff-list > li.removed:before, .diff-list > li.removed:before,
.diff-list > li.replacement:before{ .diff-list > li.replacement:before{
width: 15px; width: 15px;
overflow: hidden; overflow: hidden;
content: counters(section,".") ". "; content: counters(section,".") ". ";
display: table-cell; display: table-cell;
text-indent: -1em; text-indent: -1em;
padding-left: 1em; padding-left: 1em;
} }
/* overwrite width of :before on ballot pages */ /* overwrite width of :before on ballot pages */
.ballot-monograph .diff-list > li.normal:before, .ballot-monograph .diff-list > li.normal:before,
.ballot-monograph .diff-list > li.removed:before, .ballot-monograph .diff-list > li.removed:before,
.ballot-monograph .diff-list > li.replacement:before { .ballot-monograph .diff-list > li.replacement:before {
width: 30px; width: 30px;
} }
.diff-list > li.normal:before, .diff-list > li.normal:before,
li.replacement + li.replacement:before, li.replacement + li.replacement:before,
.diff-list > li.replacement:first-child:before{ .diff-list > li.replacement:first-child:before{
counter-increment: section; counter-increment: section;
} }
.diff-list > li.removed:before{ .diff-list > li.removed:before{
counter-increment: section; counter-increment: section;
text-decoration: line-through; text-decoration: line-through;
} }
ol.diff-list li.removed + li.replacement { ol.diff-list li.removed + li.replacement {
counter-increment: none; counter-increment: none;
} }
ol.diff-list li.removed + li.removed + li.replacement { ol.diff-list li.removed + li.removed + li.replacement {
counter-increment: section -1; counter-increment: section -1;
} }
ol.diff-list li.removed + li.removed + li.removed + li.replacement { ol.diff-list li.removed + li.removed + li.removed + li.replacement {
counter-increment: section -2; counter-increment: section -2;
} }
ol.diff-list li.removed + li.removed + li.removed + li.removed + li.replacement { ol.diff-list li.removed + li.removed + li.removed + li.removed + li.replacement {
counter-increment: section -3; counter-increment: section -3;
} }
ol.diff-list li.removed + li.removed + li.removed + li.removed + li.removed + li.replacement { ol.diff-list li.removed + li.removed + li.removed + li.removed + li.removed + li.replacement {
counter-increment: section -4; counter-increment: section -4;
} }
ol.diff-list li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.replacement { ol.diff-list li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.replacement {
counter-increment: section -5; counter-increment: section -5;
} }
ol.diff-list li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.replacement { ol.diff-list li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.replacement {
counter-increment: section -6; counter-increment: section -6;
} }
ol.diff-list li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.replacement { ol.diff-list li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.replacement {
counter-increment: section -7; counter-increment: section -7;
} }
ol.diff-list li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.replacement { ol.diff-list li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.replacement {
counter-increment: section -8; counter-increment: section -8;
} }
ol.diff-list li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.replacement { ol.diff-list li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.replacement {
counter-increment: section -9; counter-increment: section -9;
} }
ol.diff-list li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.replacement{ ol.diff-list li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.replacement{
counter-increment: section -10; counter-increment: section -10;
} }
ol.diff-list li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.replacement { ol.diff-list li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.replacement {
counter-increment: section -11; counter-increment: section -11;
} }
.diff-list > li.replacement:before, .diff-list > li.replacement:before,
.diff-list > li.new:before{ .diff-list > li.new:before{
text-decoration: underline; text-decoration: underline;
} }
.diff-list > li > div{ .diff-list > li > div{
display: inline; display: inline;
} }
.diff-list{ .diff-list{
list-style: none; list-style: none;
counter-reset: section; counter-reset: section;
display: table; display: table;
} }
.sectionContent ol, .sectionContent ol,
.revision-container ol{ .revision-container ol{
list-style: none; list-style: none;
counter-reset: section; counter-reset: section;
} }
.sectionContent ol li, .sectionContent ol li,
.revision-container ol li{ .revision-container ol li{
position: relative; position: relative;
padding: 0 0 0 30px; padding: 0 0 0 30px;
color: #000000; color: #000000;
text-indent: 0px; text-indent: 0px;
} }
.sectionContent ol ol li, .sectionContent ol ol li,
.revision-container ol ol li{ .revision-container ol ol li{
padding: 0 0 0 45px; padding: 0 0 0 45px;
} }
.sectionContent ol ol ol li, .sectionContent ol ol ol li,
.revision-container ol ol ol li{ .revision-container ol ol ol li{
padding: 0 0 0 60px; padding: 0 0 0 60px;
} }
.sectionContent ol ol ol ol li, .sectionContent ol ol ol ol li,
.revision-container ol ol ol ol li{ .revision-container ol ol ol ol li{
padding: 0 0 0 75px; padding: 0 0 0 75px;
} }
.sectionContent ol ol ol ol ol li, .sectionContent ol ol ol ol ol li,
.revision-container ol ol ol ol ol li{ .revision-container ol ol ol ol ol li{
padding: 0 0 0 90px; padding: 0 0 0 90px;
} }
.sectionContent ol ol ol ol ol ol li, .sectionContent ol ol ol ol ol ol li,
.revision-container ol ol ol ol ol ol li{ .revision-container ol ol ol ol ol ol li{
padding: 0 0 0 105px; padding: 0 0 0 105px;
} }
.sectionContent ol ol ol ol ol ol ol li, .sectionContent ol ol ol ol ol ol ol li,
.revision-container ol ol ol ol ol ol ol li{ .revision-container ol ol ol ol ol ol ol li{
padding: 0 0 0 120px; padding: 0 0 0 120px;
} }
.sectionContent ol ol ol ol ol ol ol ol li, .sectionContent ol ol ol ol ol ol ol ol li,
.revision-container ol ol ol ol ol ol ol ol li{ .revision-container ol ol ol ol ol ol ol ol li{
padding: 0 0 0 135px; padding: 0 0 0 135px;
} }
.sectionContent ol ol ol ol ol ol ol ol ol li, .sectionContent ol ol ol ol ol ol ol ol ol li,
.revision-container ol ol ol ol ol ol ol ol ol li{ .revision-container ol ol ol ol ol ol ol ol ol li{
padding: 0 0 0 160px; padding: 0 0 0 160px;
} }
.sectionContent ol ol ol ol ol ol ol ol ol ol li, .sectionContent ol ol ol ol ol ol ol ol ol ol li,
.revision-container ol ol ol ol ol ol ol ol ol ol li{ .revision-container ol ol ol ol ol ol ol ol ol ol li{
padding: 0 0 0 175px; padding: 0 0 0 175px;
} }
.sectionContent ol li:before, .sectionContent ol li:before,
.revision-container ol li:before{ .revision-container ol li:before{
counter-increment: section; counter-increment: section;
content:counters(section, ".") "."; content:counters(section, ".") ".";
position: absolute; position: absolute;
left: 0px; left: 0px;
} }
li.italic { li.italic {
font-style: italic; font-style: italic;
} }
.sectionTitle { .sectionTitle {
text-align: center; text-align: center;
margin: 23px 0 15px; margin: 23px 0 15px;
} }
.precontent-title { .precontent-title {
margin-bottom: 10px; margin-bottom: 10px;
display: block; display: block;
} }
.secondParagraph { .secondParagraph {
text-indent: 1em; text-indent: 1em;
} }
.indentedParagraph { .indentedParagraph {
margin-left: 1em; margin-left: 1em;
} }
.outdentOneLevel { .outdentOneLevel {
margin-left: -75px; margin-left: -75px;
} }
ol.list-alpha-upper > li:before { ol.list-alpha-upper > li:before {
content: counter(section, upper-alpha) "."; content: counter(section, upper-alpha) ".";
} }
ol.list-alpha-lower > li:before { ol.list-alpha-lower > li:before {
content: counter(section, lower-alpha) "."; content: counter(section, lower-alpha) ".";
} }
ol.list-roman-upper > li:before { ol.list-roman-upper > li:before {
content: counter(section, upper-roman) "."; content: counter(section, upper-roman) ".";
} }
ol.list-roman-lower > li:before { ol.list-roman-lower > li:before {
content: counter(section, lower-roman) "."; content: counter(section, lower-roman) ".";
} }
ol.list-roman-lower-parentheses > li:before { ol.list-roman-lower-parentheses > li:before {
content: "(" counter(section, lower-roman) ")"; content: "(" counter(section, lower-roman) ")";
} }
ol.list-alpha-lower-parentheses > li:before { ol.list-alpha-lower-parentheses > li:before {
content: "(" counter(section, lower-alpha) ")"; content: "(" counter(section, lower-alpha) ")";
} }
ol.list-numeric-right-parenthesis > li:before { ol.list-numeric-right-parenthesis > li:before {
content: counter(section) ")"; content: counter(section) ")";
} }
.revision-content, .revision-content,
.revision-content p, .revision-content p,
.revision-content ol, .revision-content ol,
.revision-content ul, .revision-content ul,
.revision-content li, .revision-content li,
.revision-content td, .revision-content td,
.sectionContent, .sectionContent,
.sectionContent p, .sectionContent p,
.sectionContent ol, .sectionContent ol,
.sectionContent ul, .sectionContent ul,
.sectionContent li, .sectionContent li,
.sectionContent td, .sectionContent td,
.revision-notes { .revision-notes {
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif !important; font-family: "Helvetica Neue",Helvetica,Arial,sans-serif !important;
font-size: 14px !important; font-size: 14px !important;
font-weight: normal !important; font-weight: normal !important;
line-height: 18px !important; line-height: 18px !important;
color:#404040 !important; color:#404040 !important;
} }
.revision-content .footnotes p, .revision-content .footnotes p,
.revision-content .footnotes ol, .revision-content .footnotes ol,
.revision-content .footnotes ul, .revision-content .footnotes ul,
.revision-content .footnotes li, .revision-content .footnotes li,
.revision-content .footnotes td, .revision-content .footnotes td,
.sectionContent .footnotes p, .sectionContent .footnotes p,
.sectionContent .footnotes ol, .sectionContent .footnotes ol,
.sectionContent .footnotes ul, .sectionContent .footnotes ul,
.sectionContent .footnotes li, .sectionContent .footnotes li,
.sectionContent .footnotes td { .sectionContent .footnotes td {
font-size: 12px !important; font-size: 12px !important;
} }
.diff-list ul.exception ol , .diff-list ul.exception ol ,
.sectionContent ul.exception ol , .sectionContent ul.exception ol ,
.revision-container ul.exception ol{ .revision-container ul.exception ol{
list-style: none; list-style: none;
counter-reset: exception-section; counter-reset: exception-section;
/* Creates a new instance of the section counter with each ol element */ /* Creates a new instance of the section counter with each ol element */
} }
ul.exception, ul.exception,
ul.exception li:before { ul.exception li:before {
list-style: none; list-style: none;
content: none; content: none;
} }
.diff-list ul.exception ol > li:before, .diff-list ul.exception ol > li:before,
.sectionContent ul.exception ol > li:before, .sectionContent ul.exception ol > li:before,
.revision-container ul.exception ol > li:before { .revision-container ul.exception ol > li:before {
counter-increment: exception-section; counter-increment: exception-section;
content:counters(exception-section, ".") "."; content:counters(exception-section, ".") ".";
} }
.sectionContent i > sub, .sectionContent i > sub,
.revision-container i > sub { .revision-container i > sub {
font-style: italic; font-style: italic;
} }
div.print-section a { div.print-section a {
text-align: center; text-align: center;
color: #818181; color: #818181;
display: block; display: block;
text-decoration: none; text-decoration: none;
font-size: 0.8em; font-size: 0.8em;
} }
div.print-section a.disabled { div.print-section a.disabled {
display: none; display: none;
} }
.print-link { .print-link {
color: #818181; color: #818181;
} }
.print-link.disabled { .print-link.disabled {
cursor: text; cursor: text;
text-decoration: none; text-decoration: none;
} }
/* Hack for generic styles that shouldn't exist in the database */ /* Hack for generic styles that shouldn't exist in the database */
.content_bold { .content_bold {
font-weight: bold; font-weight: bold;
} }
.content_italics { .content_italics {
font-style: italic; font-style: italic;
} }

@ -1,212 +1,212 @@
(function() { (function() {
'use strict'; 'use strict';
angular angular
.module('demo') .module('demo')
.controller('DemoController', DemoController); .controller('DemoController', DemoController);
DemoController.$inject = ['$q', '$http', '$sce', '$timeout']; DemoController.$inject = ['$q', '$http', '$sce', '$timeout'];
function DemoController($q, $http, $sce, $timeout) { function DemoController($q, $http, $sce, $timeout) {
var vm = this; var vm = this;
vm.demos = []; vm.demos = [];
vm.updateDelay = 800; vm.updateDelay = 800;
vm.currentTimeout = null; vm.currentTimeout = null;
vm.loading = false; vm.loading = false;
vm.waiting = false; vm.waiting = false;
vm.diffName = ''; vm.diffName = '';
vm.currentDemo = null; vm.currentDemo = null;
vm.debugOutput = {}; vm.debugOutput = {};
vm.matchThreshold = 80; vm.matchThreshold = 80;
vm.overrides = []; vm.overrides = [];
vm.legislativeOverride = null; vm.legislativeOverride = null;
vm.tableDiffNumber = 1; vm.tableDiffNumber = 1;
vm.tableDiffing = true; vm.tableDiffing = true;
vm.editorOptions = {}; vm.editorOptions = {};
vm.ckEditorEnabled = true; vm.ckEditorEnabled = true;
vm.trustHtml = trustHtml; vm.trustHtml = trustHtml;
vm.reset = reset; vm.reset = reset;
vm.update = update; vm.update = update;
vm.swapText = swapText; vm.swapText = swapText;
vm.diffDemo = diffDemo; vm.diffDemo = diffDemo;
vm.diffOverride = diffOverride; vm.diffOverride = diffOverride;
vm.diffTableDemo = diffTableDemo; vm.diffTableDemo = diffTableDemo;
vm.updateDemo = updateDemo; vm.updateDemo = updateDemo;
vm.saveNewDemo = saveNewDemo; vm.saveNewDemo = saveNewDemo;
vm.toggleCkEditor = toggleCkEditor; vm.toggleCkEditor = toggleCkEditor;
activate(); activate();
function activate() { function activate() {
var promises = [loadDemos(), loadOverrides()]; var promises = [loadDemos(), loadOverrides()];
return $q.all(promises).then(function() { return $q.all(promises).then(function() {
}); });
} }
function trustHtml(text) { function trustHtml(text) {
return typeof text !== 'undefined' ? $sce.trustAsHtml(text) : ''; return typeof text !== 'undefined' ? $sce.trustAsHtml(text) : '';
} }
function toggleCkEditor() { function toggleCkEditor() {
vm.ckEditorEnabled = !vm.ckEditorEnabled; vm.ckEditorEnabled = !vm.ckEditorEnabled;
} }
function reset() { function reset() {
vm.oldText = ''; vm.oldText = '';
vm.newText = ''; vm.newText = '';
vm.diff = ''; vm.diff = '';
vm.loading = false; vm.loading = false;
vm.waiting = false; vm.waiting = false;
vm.currentDemo = null; vm.currentDemo = null;
vm.legislativeOverride = null; vm.legislativeOverride = null;
if (vm.currentTimeout) { if (vm.currentTimeout) {
$timeout.cancel(vm.currentTimeout); $timeout.cancel(vm.currentTimeout);
} }
} }
function update() { function update() {
if (vm.currentTimeout) { if (vm.currentTimeout) {
$timeout.cancel(vm.currentTimeout); $timeout.cancel(vm.currentTimeout);
} }
vm.currentTimeout = $timeout(function () { vm.currentTimeout = $timeout(function () {
getDiff(); getDiff();
}, vm.updateDelay); }, vm.updateDelay);
vm.diff = null; vm.diff = null;
vm.waiting = true; vm.waiting = true;
} }
function swapText() { function swapText() {
var oldText = vm.oldText; var oldText = vm.oldText;
vm.oldText = vm.newText; vm.oldText = vm.newText;
vm.newText = oldText; vm.newText = oldText;
getDiff(); getDiff();
} }
function diffDemo(index) { function diffDemo(index) {
if (typeof index === 'undefined') { if (typeof index === 'undefined') {
index = 0; index = 0;
} }
vm.oldText = vm.demos[index]['old']; vm.oldText = vm.demos[index]['old'];
vm.newText = vm.demos[index]['new']; vm.newText = vm.demos[index]['new'];
getDiff(); getDiff();
vm.currentDemo = vm.demos[index]; vm.currentDemo = vm.demos[index];
vm.legislativeOverride = vm.demos[index].hasOwnProperty('legislativeOverride') ? vm.demos[index]['legislativeOverride'] : null; vm.legislativeOverride = vm.demos[index].hasOwnProperty('legislativeOverride') ? vm.demos[index]['legislativeOverride'] : null;
} }
function diffOverride(override, index) { function diffOverride(override, index) {
vm.oldText = override.old; vm.oldText = override.old;
vm.newText = override.new; vm.newText = override.new;
vm.legislativeOverride = override.override; vm.legislativeOverride = override.override;
getDiff(); getDiff();
vm.currentDemo = override; vm.currentDemo = override;
if (!vm.currentDemo.name) { if (!vm.currentDemo.name) {
vm.currentDemo.name = 'Override Demo ' + (index + 1); vm.currentDemo.name = 'Override Demo ' + (index + 1);
} }
vm.currentDemo.isOverride = true; vm.currentDemo.isOverride = true;
} }
function diffTableDemo(index) { function diffTableDemo(index) {
loadTableDiff(index) loadTableDiff(index)
.then(function(response) { .then(function(response) {
vm.oldText = response.data.old; vm.oldText = response.data.old;
vm.newText = response.data.new; vm.newText = response.data.new;
vm.legislativeOverride = null; vm.legislativeOverride = null;
getDiff(); getDiff();
vm.currentDemo = null; vm.currentDemo = null;
}) })
.catch(function(e) { .catch(function(e) {
console.log(e); console.log(e);
}); });
} }
function updateDemo() { function updateDemo() {
vm.currentDemo.old = vm.oldText; vm.currentDemo.old = vm.oldText;
vm.currentDemo.new = vm.newText; vm.currentDemo.new = vm.newText;
return $http.post('save_demo.php', vm.currentDemo) return $http.post('save_demo.php', vm.currentDemo)
.then(function (response) { .then(function (response) {
return response; return response;
}); });
} }
function saveNewDemo() { function saveNewDemo() {
var newIndex = vm.demos.length + 1; var newIndex = vm.demos.length + 1;
if (vm.diffName.length === 0) { if (vm.diffName.length === 0) {
vm.diffName = 'DEMO ' + newIndex; vm.diffName = 'DEMO ' + newIndex;
} }
var newDemo = {'old': vm.oldText, 'new': vm.newText, 'name': vm.diffName, 'legislativeOverride': vm.legislativeOverride}; var newDemo = {'old': vm.oldText, 'new': vm.newText, 'name': vm.diffName, 'legislativeOverride': vm.legislativeOverride};
vm.demos.push(newDemo); vm.demos.push(newDemo);
return $http.post('save_demo.php', newDemo) return $http.post('save_demo.php', newDemo)
.then(function (response) { .then(function (response) {
vm.currentDemo = newDemo; vm.currentDemo = newDemo;
return vm.currentDemo; return vm.currentDemo;
}); });
} }
function loadTableDiff(index) { function loadTableDiff(index) {
return $http({ return $http({
url: 'load_table_diff.php', url: 'load_table_diff.php',
method: 'POST', method: 'POST',
data: {index: index}, data: {index: index},
header: {'Content-Type': 'application/json; charset=UTF-8'} header: {'Content-Type': 'application/json; charset=UTF-8'}
}); });
} }
function getDiff() { function getDiff() {
vm.waiting = false; vm.waiting = false;
vm.loading = true; vm.loading = true;
vm.diff = null; vm.diff = null;
$http.post('index.php', { $http.post('index.php', {
oldText: vm.oldText, oldText: vm.oldText,
newText: vm.newText, newText: vm.newText,
matchThreshold: vm.matchThreshold, matchThreshold: vm.matchThreshold,
tableDiffing: vm.tableDiffing tableDiffing: vm.tableDiffing
}) })
.then(function (response) { .then(function (response) {
vm.diff = response.data.hasOwnProperty('diff') ? response.data.diff : response.data; vm.diff = response.data.hasOwnProperty('diff') ? response.data.diff : response.data;
vm.loading = false; vm.loading = false;
addDebugOutput(response.data.debug); addDebugOutput(response.data.debug);
}) })
.catch(function (response) { .catch(function (response) {
console.error('Gists error', response.status, response.data); console.error('Gists error', response.status, response.data);
}); });
} }
function loadDemos() { function loadDemos() {
$http.get('demos.json') $http.get('demos.json')
.success(function (data) { .success(function (data) {
vm.demos = data; vm.demos = data;
}); });
} }
function loadOverrides() { function loadOverrides() {
return $http.get('diff.json') return $http.get('diff.json')
.then(function (response) { .then(function (response) {
vm.overrides = response.data; vm.overrides = response.data;
return vm.overrides; return vm.overrides;
}); });
} }
function addDebugOutput(data) { function addDebugOutput(data) {
angular.forEach(data, function(value, key) { angular.forEach(data, function(value, key) {
data[key] = { data[key] = {
messages: value, messages: value,
isCollapsed: true isCollapsed: true
}; };
}); });
vm.debugOutput = data; vm.debugOutput = data;
} }
} }
})(); })();

@ -1,246 +1,246 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en" ng-app="demo"> <html lang="en" ng-app="demo">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="x-ua-compatible" content="ie=edge"> <meta http-equiv="x-ua-compatible" content="ie=edge">
<link rel="stylesheet" href="bower_components/tether/dist/css/tether.min.css"> <link rel="stylesheet" href="bower_components/tether/dist/css/tether.min.css">
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css"> <link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="bower_components/font-awesome/css/font-awesome.min.css"> <link rel="stylesheet" href="bower_components/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="bower_components/ng-ckeditor/ng-ckeditor.css"> <link rel="stylesheet" href="bower_components/ng-ckeditor/ng-ckeditor.css">
<link rel="stylesheet" href="bower_components/angular-ui/build/angular-ui.min.css"> <link rel="stylesheet" href="bower_components/angular-ui/build/angular-ui.min.css">
<link rel="stylesheet" href="bower_components/AngularJS-Toaster/toaster.min.css"> <link rel="stylesheet" href="bower_components/AngularJS-Toaster/toaster.min.css">
<link rel="stylesheet" href="bower_components/angular-bootstrap/ui-bootstrap-csp.css"> <link rel="stylesheet" href="bower_components/angular-bootstrap/ui-bootstrap-csp.css">
<link type="text/css" href="codes.css" rel="stylesheet"> <link type="text/css" href="codes.css" rel="stylesheet">
</head> </head>
<body ng-controller="DemoController as vm"> <body ng-controller="DemoController as vm">
<!-- Main Navigation --> <!-- Main Navigation -->
<nav class="navbar navbar-light bg-faded"> <nav class="navbar navbar-light bg-faded">
<a class="navbar-brand" href="#">caxy/php-htmldiff</a> <a class="navbar-brand" href="#">caxy/php-htmldiff</a>
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">
<li class="nav-item active"> <li class="nav-item active">
<a class="nav-link" href="#">Demo <span class="sr-only">(current)</span></a> <a class="nav-link" href="#">Demo <span class="sr-only">(current)</span></a>
</li> </li>
</ul> </ul>
</nav> </nav>
<!-- Main Content --> <!-- Main Content -->
<div class="container-fluid"> <div class="container-fluid">
<!-- diff controls and input --> <!-- diff controls and input -->
<div class="card"> <div class="card">
<div class="card-header"> <div class="card-header">
<button class="btn btn-secondary btn-sm" type="button" data-toggle="collapse" data-target="#diffControls"> <button class="btn btn-secondary btn-sm" type="button" data-toggle="collapse" data-target="#diffControls">
<i class="fa fa-compress"></i> <i class="fa fa-compress"></i>
</button> </button>
Diff Controls Diff Controls
<div class="pull-right"> <div class="pull-right">
<div ng-if="vm.currentDemo"> <div ng-if="vm.currentDemo">
<p> <p>
Current Demo: {{ vm.currentDemo.name }} Current Demo: {{ vm.currentDemo.name }}
<button ng-if="!vm.currentDemo.isOverride" type="button" class="btn btn-primary btn-sm" ng-click="vm.updateDemo()"> <button ng-if="!vm.currentDemo.isOverride" type="button" class="btn btn-primary btn-sm" ng-click="vm.updateDemo()">
Update Demo Update Demo
</button> </button>
</p> </p>
</div> </div>
</div> </div>
</div> </div>
<div class="card-block collapse in" id="diffControls"> <div class="card-block collapse in" id="diffControls">
<!-- Diff controls --> <!-- Diff controls -->
<div class="form-inline row"> <div class="form-inline row">
<!-- Reset button --> <!-- Reset button -->
<div class="btn-group" role="group"> <div class="btn-group" role="group">
<button type="button" class="btn btn-sm btn-danger-outline" ng-click="vm.reset()">RESET</button> <button type="button" class="btn btn-sm btn-danger-outline" ng-click="vm.reset()">RESET</button>
</div> </div>
<!-- Load demo buttons w/ dropdowns --> <!-- Load demo buttons w/ dropdowns -->
<div class="btn-group" role="group"> <div class="btn-group" role="group">
<div class="btn-group btn-group-sm"> <div class="btn-group btn-group-sm">
<button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Load Custom Demo Load Custom Demo
</button> </button>
<div class="dropdown-menu"> <div class="dropdown-menu">
<a href ng-repeat="demo in vm.demos" type="button" class="dropdown-item" ng-class="{active: demo == vm.currentDemo}" ng-click="vm.diffDemo($index)"> <a href ng-repeat="demo in vm.demos" type="button" class="dropdown-item" ng-class="{active: demo == vm.currentDemo}" ng-click="vm.diffDemo($index)">
{{ demo.name }} {{ demo.name }}
</a> </a>
</div> </div>
</div> </div>
<div class="btn-group btn-group-sm" role="group"> <div class="btn-group btn-group-sm" role="group">
<button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Load Diff Override Demo Load Diff Override Demo
</button> </button>
<div class="dropdown-menu"> <div class="dropdown-menu">
<a href class="dropdown-item" ng-repeat="override in vm.overrides" ng-class="{active: vm.currentDemo == override}" ng-click="vm.diffOverride(override, $index)"> <a href class="dropdown-item" ng-repeat="override in vm.overrides" ng-class="{active: vm.currentDemo == override}" ng-click="vm.diffOverride(override, $index)">
Override Demo {{ $index + 1 }} Override Demo {{ $index + 1 }}
</a> </a>
</div> </div>
</div> </div>
</div> </div>
<!-- Load table diff button and input --> <!-- Load table diff button and input -->
<div class="form-group"> <div class="form-group">
<div class="input-group input-group-sm" role="group"> <div class="input-group input-group-sm" role="group">
<span class="input-group-btn"> <span class="input-group-btn">
<button ng-click="vm.diffTableDemo(vm.tableDiffNumber)" type="button" class="btn btn-secondary">Load Table Diff</button> <button ng-click="vm.diffTableDemo(vm.tableDiffNumber)" type="button" class="btn btn-secondary">Load Table Diff</button>
</span> </span>
<input type="number" class="form-control" ng-model="vm.tableDiffNumber" /> <input type="number" class="form-control" ng-model="vm.tableDiffNumber" />
</div> </div>
</div> </div>
<!-- Match Threshold --> <!-- Match Threshold -->
<div class="form-group"> <div class="form-group">
<label for="matchThreshold">Match Threshold</label> <label for="matchThreshold">Match Threshold</label>
<input type="number" class="form-control form-control-sm" ng-model="vm.matchThreshold" id="matchThreshold" ng-change="vm.update()"> <input type="number" class="form-control form-control-sm" ng-model="vm.matchThreshold" id="matchThreshold" ng-change="vm.update()">
</div> </div>
<!-- Table Diffing Checkbox --> <!-- Table Diffing Checkbox -->
<div class="form-group"> <div class="form-group">
<label class="checkbox-inline" for="tableDiffing"> <label class="checkbox-inline" for="tableDiffing">
<input type="checkbox" ng-model="vm.tableDiffing" id="tableDiffing" ng-change="vm.update()"> Use Table Diffing <input type="checkbox" ng-model="vm.tableDiffing" id="tableDiffing" ng-change="vm.update()"> Use Table Diffing
</label> </label>
</div> </div>
<!-- Swap Text Button --> <!-- Swap Text Button -->
<button type="button" class="btn btn-secondary btn-sm" ng-click="vm.swapText()">Swap Text</button> <button type="button" class="btn btn-secondary btn-sm" ng-click="vm.swapText()">Swap Text</button>
<!-- Save as New Demo --> <!-- Save as New Demo -->
<div class="form-group"> <div class="form-group">
<div class="input-group input-group-sm"> <div class="input-group input-group-sm">
<input type="text" class="form-control" placeholder="Demo Name" ng-model="vm.diffName" /> <input type="text" class="form-control" placeholder="Demo Name" ng-model="vm.diffName" />
<span class="input-group-btn"> <span class="input-group-btn">
<button class="btn btn-secondary" type="button" ng-click="vm.saveNewDemo()">Save as New Demo</button> <button class="btn btn-secondary" type="button" ng-click="vm.saveNewDemo()">Save as New Demo</button>
</span> </span>
</div> </div>
</div> </div>
</div><!-- end of diff controls --> </div><!-- end of diff controls -->
<!-- Diff Inputs (Old Text / New Text) --> <!-- Diff Inputs (Old Text / New Text) -->
<div class="form-group row m-t-2"> <div class="form-group row m-t-2">
<div class="col-sm-6"> <div class="col-sm-6">
<label class="form-control-label" for="oldText"> <label class="form-control-label" for="oldText">
Old Text Old Text
<button type="button" class="btn btn-sm btn-secondary clipboard" data-clipboard-target="#oldText"> <button type="button" class="btn btn-sm btn-secondary clipboard" data-clipboard-target="#oldText">
<i class="fa fa-clipboard"></i> <i class="fa fa-clipboard"></i>
</button> </button>
<a ng-click="vm.toggleCkEditor()">Toggle CK</a> <a ng-click="vm.toggleCkEditor()">Toggle CK</a>
</label> </label>
<div ng-if="vm.ckEditorEnabled"> <div ng-if="vm.ckEditorEnabled">
<textarea ckeditor="vm.editorOptions" ng-model="vm.oldText" id="oldText" ng-change="vm.update()"></textarea> <textarea ckeditor="vm.editorOptions" ng-model="vm.oldText" id="oldText" ng-change="vm.update()"></textarea>
</div> </div>
<textarea ng-if="!vm.ckEditorEnabled" class="form-control" ng-model="vm.oldText" name="old_text" ng-change="vm.update()" rows="15"></textarea> <textarea ng-if="!vm.ckEditorEnabled" class="form-control" ng-model="vm.oldText" name="old_text" ng-change="vm.update()" rows="15"></textarea>
</div> </div>
<div class="col-sm-6"> <div class="col-sm-6">
<label class="form-control-label" for="newText"> <label class="form-control-label" for="newText">
New Text New Text
<button type="button" class="btn btn-sm btn-secondary clipboard" data-clipboard-target="#newText"> <button type="button" class="btn btn-sm btn-secondary clipboard" data-clipboard-target="#newText">
<i class="fa fa-clipboard"></i> <i class="fa fa-clipboard"></i>
</button> </button>
<a ng-click="vm.toggleCkEditor()">Toggle CK</a> <a ng-click="vm.toggleCkEditor()">Toggle CK</a>
</label> </label>
<div ng-if="vm.ckEditorEnabled"> <div ng-if="vm.ckEditorEnabled">
<textarea ckeditor="vm.editorOptions" ng-model="vm.newText" id="newText" ng-change="vm.update()"></textarea> <textarea ckeditor="vm.editorOptions" ng-model="vm.newText" id="newText" ng-change="vm.update()"></textarea>
</div> </div>
<textarea ng-if="!vm.ckEditorEnabled" class="form-control" ng-model="vm.newText" name="new_text" ng-change="vm.update()" rows="15"></textarea> <textarea ng-if="!vm.ckEditorEnabled" class="form-control" ng-model="vm.newText" name="new_text" ng-change="vm.update()" rows="15"></textarea>
</div> </div>
</div><!-- end of diff inputs --> </div><!-- end of diff inputs -->
</div><!-- end of diff controls card-block --> </div><!-- end of diff controls card-block -->
</div><!-- end of diff controls card --> </div><!-- end of diff controls card -->
<!-- Diff Output --> <!-- Diff Output -->
<div class="card"> <div class="card">
<div class="card-header"> <div class="card-header">
<div class="btn-group"> <div class="btn-group">
<button class="btn btn-secondary btn-sm" type="button" data-toggle="collapse" data-target="#diffBlock"> <button class="btn btn-secondary btn-sm" type="button" data-toggle="collapse" data-target="#diffBlock">
<i class="fa fa-compress"></i> <i class="fa fa-compress"></i>
</button> </button>
<button type="button" class="btn btn-sm btn-secondary clipboard" data-clipboard-target="#diffPreview"> <button type="button" class="btn btn-sm btn-secondary clipboard" data-clipboard-target="#diffPreview">
<i class="fa fa-clipboard"></i> <i class="fa fa-clipboard"></i>
</button> </button>
<button type="button" class="btn btn-sm btn-secondary" ng-click="vm.update()"> <button type="button" class="btn btn-sm btn-secondary" ng-click="vm.update()">
<i class="fa fa-refresh"></i> <i class="fa fa-refresh"></i>
</button> </button>
</div> </div>
Diff Output Diff Output
<span ng-show="vm.loading || vm.waiting">- {{ vm.loading ? 'Loading' : 'Waiting' }}...</span> <span ng-show="vm.loading || vm.waiting">- {{ vm.loading ? 'Loading' : 'Waiting' }}...</span>
</div> </div>
<div class="card-block collapse in" id="diffBlock"> <div class="card-block collapse in" id="diffBlock">
<div class="form-group row"> <div class="form-group row">
<div class="col-sm-12"> <div class="col-sm-12">
<div id="diffPreview" class="html-preview" ng-bind-html="vm.trustHtml(vm.diff)"></div> <div id="diffPreview" class="html-preview" ng-bind-html="vm.trustHtml(vm.diff)"></div>
</div> </div>
</div> </div>
</div> </div>
</div><!-- end of diff output --> </div><!-- end of diff output -->
<!-- Diff Output (HTML) --> <!-- Diff Output (HTML) -->
<div class="card"> <div class="card">
<div class="card-header"> <div class="card-header">
<button class="btn btn-secondary btn-sm" type="button" data-toggle="collapse" data-target="#rawDiffBlock"> <button class="btn btn-secondary btn-sm" type="button" data-toggle="collapse" data-target="#rawDiffBlock">
<i class="fa fa-compress"></i> <i class="fa fa-compress"></i>
</button> </button>
<label class="form-control-label" for="rawDiff"> <label class="form-control-label" for="rawDiff">
Diff Output (HTML) Diff Output (HTML)
<button type="button" class="btn btn-sm btn-secondary clipboard" data-clipboard-target="#rawDiff"> <button type="button" class="btn btn-sm btn-secondary clipboard" data-clipboard-target="#rawDiff">
<i class="fa fa-clipboard"></i> <i class="fa fa-clipboard"></i>
</button> </button>
</label> </label>
<span ng-show="vm.loading || vm.waiting">- {{ vm.loading ? 'Loading' : 'Waiting' }}...</span> <span ng-show="vm.loading || vm.waiting">- {{ vm.loading ? 'Loading' : 'Waiting' }}...</span>
</div> </div>
<div class="card-block collapse" id="rawDiffBlock"> <div class="card-block collapse" id="rawDiffBlock">
<div class="form-group row"> <div class="form-group row">
<div class="col-sm-12"> <div class="col-sm-12">
<textarea id="rawDiff" class="form-control" ng-model="vm.diff" name="diff" readonly ng-change="vm.update()" rows="15"></textarea> <textarea id="rawDiff" class="form-control" ng-model="vm.diff" name="diff" readonly ng-change="vm.update()" rows="15"></textarea>
</div> </div>
</div> </div>
</div> </div>
</div><!-- end of diff output (html) --> </div><!-- end of diff output (html) -->
<!-- Debug Output --> <!-- Debug Output -->
<div class="row"> <div class="row">
<div class="col-sm-6"> <div class="col-sm-6">
<h3>Debug Output</h3> <h3>Debug Output</h3>
<div class="card" ng-repeat="(category, categoryMessages) in vm.debugOutput track by category"> <div class="card" ng-repeat="(category, categoryMessages) in vm.debugOutput track by category">
<div class="card-header"> <div class="card-header">
<h5> <h5>
<a ng-click="categoryMessages.isCollapsed = !categoryMessages.isCollapsed"> <a ng-click="categoryMessages.isCollapsed = !categoryMessages.isCollapsed">
{{ category }} {{ category }}
</a> </a>
</h5> </h5>
</div> </div>
<div class="card-block" uib-collapse="categoryMessages.isCollapsed"> <div class="card-block" uib-collapse="categoryMessages.isCollapsed">
<pre ng-repeat="message in categoryMessages.messages track by $index"> <pre ng-repeat="message in categoryMessages.messages track by $index">
{{ message }} {{ message }}
</pre> </pre>
</div> </div>
</div> </div>
</div> </div>
<div class="col-sm-6" ng-show="vm.legislativeOverride"> <div class="col-sm-6" ng-show="vm.legislativeOverride">
<h3>Legislative Override</h3> <h3>Legislative Override</h3>
<div class="html-preview" ng-bind-html="vm.trustHtml(vm.legislativeOverride)"></div> <div class="html-preview" ng-bind-html="vm.trustHtml(vm.legislativeOverride)"></div>
</div> </div>
</div><!-- end of debug output --> </div><!-- end of debug output -->
</div><!-- end of outer container div --> </div><!-- end of outer container div -->
<script src="bower_components/jquery/dist/jquery.min.js"></script> <script src="bower_components/jquery/dist/jquery.min.js"></script>
<script src="bower_components/tether/dist/js/tether.min.js"></script> <script src="bower_components/tether/dist/js/tether.min.js"></script>
<script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script> <script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="bower_components/angular/angular.min.js"></script> <script src="bower_components/angular/angular.min.js"></script>
<script src="bower_components/angular-sanitize/angular-sanitize.min.js"></script> <script src="bower_components/angular-sanitize/angular-sanitize.min.js"></script>
<script src="bower_components/clipboard/dist/clipboard.min.js"></script> <script src="bower_components/clipboard/dist/clipboard.min.js"></script>
<script src="bower_components/ckeditor/ckeditor.js"></script> <script src="bower_components/ckeditor/ckeditor.js"></script>
<script src="bower_components/ng-ckeditor/ng-ckeditor.min.js"></script> <script src="bower_components/ng-ckeditor/ng-ckeditor.min.js"></script>
<script src="bower_components/angular-ui/build/angular-ui.min.js"></script> <script src="bower_components/angular-ui/build/angular-ui.min.js"></script>
<script src="bower_components/angular-animate/angular-animate.min.js"></script> <script src="bower_components/angular-animate/angular-animate.min.js"></script>
<script src="bower_components/AngularJS-Toaster/toaster.min.js"></script> <script src="bower_components/AngularJS-Toaster/toaster.min.js"></script>
<script src="bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js"></script> <script src="bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js"></script>
<script type="text/javascript" src="demo.module.js"></script> <script type="text/javascript" src="demo.module.js"></script>
<script type="text/javascript" src="demo.controller.js"></script> <script type="text/javascript" src="demo.controller.js"></script>
<script> <script>
new Clipboard('.clipboard'); new Clipboard('.clipboard');
</script> </script>
</body> </body>
</html> </html>

@ -1,9 +1,9 @@
(function() { (function() {
'use strict'; 'use strict';
angular.module('demo', [ angular.module('demo', [
'ngSanitize', 'ngSanitize',
'ngCkeditor', 'ngCkeditor',
'ui.bootstrap' 'ui.bootstrap'
]); ]);
})(); })();

@ -1,56 +1,56 @@
<?php <?php
use Caxy\HtmlDiff\HtmlDiff; use Caxy\HtmlDiff\HtmlDiff;
ini_set('display_errors', 1); ini_set('display_errors', 1);
error_reporting(E_ALL); error_reporting(E_ALL);
require __DIR__.'/../vendor/autoload.php'; require __DIR__.'/../vendor/autoload.php';
$debugOutput = array(); $debugOutput = array();
function addDebugOutput($value, $key = 'general') function addDebugOutput($value, $key = 'general')
{ {
global $debugOutput; global $debugOutput;
if (!is_string($value)) { if (!is_string($value)) {
$value = var_export($value, true); $value = var_export($value, true);
} }
if (!array_key_exists($key, $debugOutput)) { if (!array_key_exists($key, $debugOutput)) {
$debugOutput[$key] = array(); $debugOutput[$key] = array();
} }
$debugOutput[$key][] = $value; $debugOutput[$key][] = $value;
} }
$input = file_get_contents('php://input'); $input = file_get_contents('php://input');
if ($input) { if ($input) {
header('Content-Type: application/json'); header('Content-Type: application/json');
$data = json_decode($input, true); $data = json_decode($input, true);
$oldText = $data['oldText']; $oldText = $data['oldText'];
$newText = $data['newText']; $newText = $data['newText'];
$useTableDiffing = isset($data['tableDiffing']) ? $data['tableDiffing'] : true; $useTableDiffing = isset($data['tableDiffing']) ? $data['tableDiffing'] : true;
$diff = new HtmlDiff($oldText, $newText, 'UTF-8', array()); $diff = new HtmlDiff($oldText, $newText, 'UTF-8', array());
if (array_key_exists('matchThreshold', $data)) { if (array_key_exists('matchThreshold', $data)) {
$diff->setMatchThreshold($data['matchThreshold']); $diff->setMatchThreshold($data['matchThreshold']);
} }
$diff->setUseTableDiffing($useTableDiffing); $diff->setUseTableDiffing($useTableDiffing);
$diffOutput = $diff->build(); $diffOutput = $diff->build();
$diffOutput = mb_convert_encoding($diffOutput, 'UTF-8'); $diffOutput = mb_convert_encoding($diffOutput, 'UTF-8');
$jsonOutput = json_encode(array('diff' => $diffOutput, 'debug' => $debugOutput)); $jsonOutput = json_encode(array('diff' => $diffOutput, 'debug' => $debugOutput));
if (false === $jsonOutput) { if (false === $jsonOutput) {
throw new \Exception('Failed to encode JSON: '.json_last_error_msg()); throw new \Exception('Failed to encode JSON: '.json_last_error_msg());
} }
echo $jsonOutput; echo $jsonOutput;
} else { } else {
header('Content-Type: text/html'); header('Content-Type: text/html');
echo file_get_contents('demo.html'); echo file_get_contents('demo.html');
} }

@ -1,22 +1,22 @@
<?php <?php
$requestBody = file_get_contents('php://input'); $requestBody = file_get_contents('php://input');
$requestJson = json_decode($requestBody, true); $requestJson = json_decode($requestBody, true);
if (empty($requestJson['index'])) { if (empty($requestJson['index'])) {
throw new \Exception('index is required.'); throw new \Exception('index is required.');
} }
$jsonFile = __DIR__.'/tablediffs.json'; $jsonFile = __DIR__.'/tablediffs.json';
$demoStorage = json_decode(file_get_contents($jsonFile), true); $demoStorage = json_decode(file_get_contents($jsonFile), true);
if (!array_key_exists($requestJson['index'], $demoStorage)) { if (!array_key_exists($requestJson['index'], $demoStorage)) {
throw new \Exception('index not found.'); throw new \Exception('index not found.');
} }
$targetDemo = $demoStorage[$requestJson['index']]; $targetDemo = $demoStorage[$requestJson['index']];
header('Content-Type: application/json'); header('Content-Type: application/json');
echo json_encode($targetDemo); echo json_encode($targetDemo);

@ -1,46 +1,46 @@
<?php <?php
$requestBody = file_get_contents('php://input'); $requestBody = file_get_contents('php://input');
$requestJson = json_decode($requestBody, true); $requestJson = json_decode($requestBody, true);
if (empty($requestJson['old']) && empty($requestJson['new'])) { if (empty($requestJson['old']) && empty($requestJson['new'])) {
throw new \Exception('Old text or new text is required.'); throw new \Exception('Old text or new text is required.');
} }
$jsonFile = __DIR__.'/demos.json'; $jsonFile = __DIR__.'/demos.json';
$demoStorage = json_decode(file_get_contents($jsonFile), true); $demoStorage = json_decode(file_get_contents($jsonFile), true);
if (empty($requestJson['name'])) { if (empty($requestJson['name'])) {
$requestJson['name'] = 'DEMO '.count($demoStorage); $requestJson['name'] = 'DEMO '.count($demoStorage);
} }
$oldText = $requestJson['old']; $oldText = $requestJson['old'];
$newText = $requestJson['new']; $newText = $requestJson['new'];
$name = $requestJson['name']; $name = $requestJson['name'];
$legislativeOverride = !empty($requestJson['legislativeOverride']) ? $requestJson['legislativeOverride'] : null; $legislativeOverride = !empty($requestJson['legislativeOverride']) ? $requestJson['legislativeOverride'] : null;
$existingDemoIndex = null; $existingDemoIndex = null;
foreach ($demoStorage as $index => $demo) { foreach ($demoStorage as $index => $demo) {
if ($demo['name'] === $name) { if ($demo['name'] === $name) {
$existingDemoIndex = $index; $existingDemoIndex = $index;
break; break;
} }
} }
if ($existingDemoIndex !== null) { if ($existingDemoIndex !== null) {
$demoStorage[$existingDemoIndex]['old'] = $oldText; $demoStorage[$existingDemoIndex]['old'] = $oldText;
$demoStorage[$existingDemoIndex]['new'] = $newText; $demoStorage[$existingDemoIndex]['new'] = $newText;
} else { } else {
$demoStorage[] = array( $demoStorage[] = array(
'name' => $name, 'name' => $name,
'old' => $oldText, 'old' => $oldText,
'new' => $newText, 'new' => $newText,
'legislativeOverride' => $legislativeOverride, 'legislativeOverride' => $legislativeOverride,
); );
} }
if (false === file_put_contents($jsonFile, json_encode($demoStorage))) { if (false === file_put_contents($jsonFile, json_encode($demoStorage))) {
throw new \Exception("Unable to save to file: $jsonFile"); throw new \Exception("Unable to save to file: $jsonFile");
} }

@ -1,116 +1,116 @@
Differences from rashid2538/php-htmldiff Differences from rashid2538/php-htmldiff
======================================== ========================================
.. contents:: Table of Contents .. contents:: Table of Contents
Code Styling and Clean-up Code Styling and Clean-up
------------------------- -------------------------
* Added namespaces, split up classes to their own files, some code styling changes * Added namespaces, split up classes to their own files, some code styling changes
Enhancements Enhancements
------------ ------------
* Allow the specialCaseOpeningTags and specialCaseClosingTags properties to be modified by passing an array into the constructor or using set/add/remove functions * Allow the specialCaseOpeningTags and specialCaseClosingTags properties to be modified by passing an array into the constructor or using set/add/remove functions
* Updated the demo to accept input and diff via AJAX * Updated the demo to accept input and diff via AJAX
* Added static properties for the default config variables * Added static properties for the default config variables
Bug Fixes Bug Fixes
--------- ---------
* Fixed an index out of range bug (may have been fixed on the original repo since): c9ba1fa_ * Fixed an index out of range bug (may have been fixed on the original repo since): c9ba1fa_
* Check for empty oldText or newText before processing del or ins in processReplaceOperation function * Check for empty oldText or newText before processing del or ins in processReplaceOperation function
New Features New Features
------------ ------------
Isolated Diffing of certain HTML elements Isolated Diffing of certain HTML elements
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This is the one of the largest changes from the original repository. This is the one of the largest changes from the original repository.
For more information, see the release notes for tag `0.0.6`_ For more information, see the release notes for tag `0.0.6`_
List Diffing List Diffing
^^^^^^^^^^^^ ^^^^^^^^^^^^
Similar to the Isolated Diffing feature, but specifically for HTML lists. Similar to the Isolated Diffing feature, but specifically for HTML lists.
More information is to come on this, and there will definitely be some tweaks and configuration options added for this More information is to come on this, and there will definitely be some tweaks and configuration options added for this
feature. Currently there is no easy way to enable/disable the feature, so if you're having issues with it I suggest feature. Currently there is no easy way to enable/disable the feature, so if you're having issues with it I suggest
using the `0.0.6`_ or earlier release. using the `0.0.6`_ or earlier release.
Table Diffing Table Diffing
^^^^^^^^^^^^^ ^^^^^^^^^^^^^
Similar to the Isolated Diffing and List Diffing features, but specifically for HTML tables. Similar to the Isolated Diffing and List Diffing features, but specifically for HTML tables.
More information to come on this soon. More information to come on this soon.
New option to group together diffed words by not matching on whitespace-only. Option is enabled by default. New option to group together diffed words by not matching on whitespace-only. Option is enabled by default.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This was a specific requirement for an application we use this library for. The original library would replace This was a specific requirement for an application we use this library for. The original library would replace
single words at a time, but enabling this feature will group replacements instead. See example below. single words at a time, but enabling this feature will group replacements instead. See example below.
Old Text:: Old Text::
testing some text here and there testing some text here and there
New Text:: New Text::
testing other words here and there testing other words here and there
With $groupDiffs = false (original functionality):: With $groupDiffs = false (original functionality)::
testing <del>some</del><ins>other</ins> <del>text</del><ins>words</ins> here and there testing <del>some</del><ins>other</ins> <del>text</del><ins>words</ins> here and there
With $groupDiffs = true (new feature):: With $groupDiffs = true (new feature)::
testing <del>some text</del><ins>other words</ins> here and there testing <del>some text</del><ins>other words</ins> here and there
Change diffing to strike through entire words/numbers if they contain periods or commas within the word Change diffing to strike through entire words/numbers if they contain periods or commas within the word
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This change introduced a new property ``$specialCaseChars``, which defaults to the following characters: ``.`` ``,`` ``(`` ``)`` ``'`` This change introduced a new property ``$specialCaseChars``, which defaults to the following characters: ``.`` ``,`` ``(`` ``)`` ``'``
This feature can be "disabled" by simply setting the $specialCaseChars to an empty array i.e. ``$diff->setSpecialCaseChars(array())`` This feature can be "disabled" by simply setting the $specialCaseChars to an empty array i.e. ``$diff->setSpecialCaseChars(array())``
In the original library, special characters are treated as their own "words" even if they are in the middle of a word. In the original library, special characters are treated as their own "words" even if they are in the middle of a word.
This causes weird things to happen when diffing numbers that have a comma or a period in the middle of the number. This causes weird things to happen when diffing numbers that have a comma or a period in the middle of the number.
For example, diffing ``10,000.50`` against ``11,100.75`` gives you: For example, diffing ``10,000.50`` against ``11,100.75`` gives you:
Original Functionality:: Original Functionality::
<del class="diffmod">10</del><ins class="diffmod">11</ins>,<del class="diffmod">000</del><ins class="diffmod">100</ins>.<del class="diffmod">50</del><ins class="diffmod">75</ins> <del class="diffmod">10</del><ins class="diffmod">11</ins>,<del class="diffmod">000</del><ins class="diffmod">100</ins>.<del class="diffmod">50</del><ins class="diffmod">75</ins>
This is very difficult to read, so the new feature allows you to add ``.`` and ``,`` to the ``$specialCaseChars`` array in order This is very difficult to read, so the new feature allows you to add ``.`` and ``,`` to the ``$specialCaseChars`` array in order
to get output that looks like:: to get output that looks like::
<del class="diffmod">10,000.50</del><ins class="diffmod">11,100.75</ins> <del class="diffmod">10,000.50</del><ins class="diffmod">11,100.75</ins>
Note: It will *not* treat the specialCaseChars as part of the word if it is at the beginning or end of the word, Note: It will *not* treat the specialCaseChars as part of the word if it is at the beginning or end of the word,
so normal periods or commas at the end of words will still be diffed like the original. so normal periods or commas at the end of words will still be diffed like the original.
Added option to insert a space between ``<del>`` and ``<ins>`` tags. Disabled by default. Added option to insert a space between ``<del>`` and ``<ins>`` tags. Disabled by default.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This was a requirement for one our applications that uses this library. This was a requirement for one our applications that uses this library.
New property ``$insertSpaceInReplace`` was added, and setting it to true will simply add a space between New property ``$insertSpaceInReplace`` was added, and setting it to true will simply add a space between
the ``<del>`` and ``<ins>`` tags in replace operations, which was requested for easier reading. the ``<del>`` and ``<ins>`` tags in replace operations, which was requested for easier reading.
Enable it by calling ``$diff->setInsertSpaceInReplace(true);`` Enable it by calling ``$diff->setInsertSpaceInReplace(true);``
Original Functionality:: Original Functionality::
<del>Old</del><ins>New</ins> <del>Old</del><ins>New</ins>
New Functionality:: New Functionality::
<del>Old</del> <ins>New</ins> <del>Old</del> <ins>New</ins>
.. _c9ba1fa: https://github.com/caxy/php-htmldiff/commit/c9ba1fab6777cd47427477f8d747293bb01ef1e8 .. _c9ba1fa: https://github.com/caxy/php-htmldiff/commit/c9ba1fab6777cd47427477f8d747293bb01ef1e8
.. _0.0.6: https://github.com/caxy/php-htmldiff/releases/tag/0.0.6 .. _0.0.6: https://github.com/caxy/php-htmldiff/releases/tag/0.0.6

@ -1,490 +1,490 @@
<?php <?php
namespace Caxy\HtmlDiff; namespace Caxy\HtmlDiff;
/** /**
* Class AbstractDiff * Class AbstractDiff
* @package Caxy\HtmlDiff * @package Caxy\HtmlDiff
*/ */
abstract class AbstractDiff abstract class AbstractDiff
{ {
/** /**
* @var array * @var array
* *
* @deprecated since 0.1.0 * @deprecated since 0.1.0
*/ */
public static $defaultSpecialCaseTags = array('strong', 'b', 'i', 'big', 'small', 'u', 'sub', 'sup', 'strike', 's', 'p'); public static $defaultSpecialCaseTags = array('strong', 'b', 'i', 'big', 'small', 'u', 'sub', 'sup', 'strike', 's', 'p');
/** /**
* @var array * @var array
* *
* @deprecated since 0.1.0 * @deprecated since 0.1.0
*/ */
public static $defaultSpecialCaseChars = array('.', ',', '(', ')', '\''); public static $defaultSpecialCaseChars = array('.', ',', '(', ')', '\'');
/** /**
* @var bool * @var bool
* *
* @deprecated since 0.1.0 * @deprecated since 0.1.0
*/ */
public static $defaultGroupDiffs = true; public static $defaultGroupDiffs = true;
/** /**
* @var HtmlDiffConfig * @var HtmlDiffConfig
*/ */
protected $config; protected $config;
/** /**
* @var string * @var string
*/ */
protected $content; protected $content;
/** /**
* @var string * @var string
*/ */
protected $oldText; protected $oldText;
/** /**
* @var string * @var string
*/ */
protected $newText; protected $newText;
/** /**
* @var array * @var array
*/ */
protected $oldWords = array(); protected $oldWords = array();
/** /**
* @var array * @var array
*/ */
protected $newWords = array(); protected $newWords = array();
/** /**
* @var DiffCache[] * @var DiffCache[]
*/ */
private $diffCaches = array(); private $diffCaches = array();
/** /**
* AbstractDiff constructor. * AbstractDiff constructor.
* *
* @param string $oldText * @param string $oldText
* @param string $newText * @param string $newText
* @param string $encoding * @param string $encoding
* @param null|array $specialCaseTags * @param null|array $specialCaseTags
* @param null|bool $groupDiffs * @param null|bool $groupDiffs
*/ */
public function __construct($oldText, $newText, $encoding = 'UTF-8', $specialCaseTags = null, $groupDiffs = null) public function __construct($oldText, $newText, $encoding = 'UTF-8', $specialCaseTags = null, $groupDiffs = null)
{ {
mb_substitute_character(0x20); mb_substitute_character(0x20);
$this->config = HtmlDiffConfig::create()->setEncoding($encoding); $this->config = HtmlDiffConfig::create()->setEncoding($encoding);
if ($specialCaseTags !== null) { if ($specialCaseTags !== null) {
$this->config->setSpecialCaseTags($specialCaseTags); $this->config->setSpecialCaseTags($specialCaseTags);
} }
if ($groupDiffs !== null) { if ($groupDiffs !== null) {
$this->config->setGroupDiffs($groupDiffs); $this->config->setGroupDiffs($groupDiffs);
} }
$this->oldText = $this->purifyHtml(trim($oldText)); $this->oldText = $this->purifyHtml(trim($oldText));
$this->newText = $this->purifyHtml(trim($newText)); $this->newText = $this->purifyHtml(trim($newText));
$this->content = ''; $this->content = '';
} }
/** /**
* @return bool|string * @return bool|string
*/ */
abstract public function build(); abstract public function build();
/** /**
* @return DiffCache|null * @return DiffCache|null
*/ */
protected function getDiffCache() protected function getDiffCache()
{ {
if (!$this->hasDiffCache()) { if (!$this->hasDiffCache()) {
return null; return null;
} }
$hash = spl_object_hash($this->getConfig()->getCacheProvider()); $hash = spl_object_hash($this->getConfig()->getCacheProvider());
if (!array_key_exists($hash, $this->diffCaches)) { if (!array_key_exists($hash, $this->diffCaches)) {
$this->diffCaches[$hash] = new DiffCache($this->getConfig()->getCacheProvider()); $this->diffCaches[$hash] = new DiffCache($this->getConfig()->getCacheProvider());
} }
return $this->diffCaches[$hash]; return $this->diffCaches[$hash];
} }
/** /**
* @return bool * @return bool
*/ */
protected function hasDiffCache() protected function hasDiffCache()
{ {
return null !== $this->getConfig()->getCacheProvider(); return null !== $this->getConfig()->getCacheProvider();
} }
/** /**
* @return HtmlDiffConfig * @return HtmlDiffConfig
*/ */
public function getConfig() public function getConfig()
{ {
return $this->config; return $this->config;
} }
/** /**
* @param HtmlDiffConfig $config * @param HtmlDiffConfig $config
* *
* @return AbstractDiff * @return AbstractDiff
*/ */
public function setConfig(HtmlDiffConfig $config) public function setConfig(HtmlDiffConfig $config)
{ {
$this->config = $config; $this->config = $config;
return $this; return $this;
} }
/** /**
* @return int * @return int
* *
* @deprecated since 0.1.0 * @deprecated since 0.1.0
*/ */
public function getMatchThreshold() public function getMatchThreshold()
{ {
return $this->config->getMatchThreshold(); return $this->config->getMatchThreshold();
} }
/** /**
* @param int $matchThreshold * @param int $matchThreshold
* *
* @return AbstractDiff * @return AbstractDiff
* *
* @deprecated since 0.1.0 * @deprecated since 0.1.0
*/ */
public function setMatchThreshold($matchThreshold) public function setMatchThreshold($matchThreshold)
{ {
$this->config->setMatchThreshold($matchThreshold); $this->config->setMatchThreshold($matchThreshold);
return $this; return $this;
} }
/** /**
* @param array $chars * @param array $chars
* *
* @deprecated since 0.1.0 * @deprecated since 0.1.0
*/ */
public function setSpecialCaseChars(array $chars) public function setSpecialCaseChars(array $chars)
{ {
$this->config->setSpecialCaseChars($chars); $this->config->setSpecialCaseChars($chars);
} }
/** /**
* @return array|null * @return array|null
* *
* @deprecated since 0.1.0 * @deprecated since 0.1.0
*/ */
public function getSpecialCaseChars() public function getSpecialCaseChars()
{ {
return $this->config->getSpecialCaseChars(); return $this->config->getSpecialCaseChars();
} }
/** /**
* @param string $char * @param string $char
* *
* @deprecated since 0.1.0 * @deprecated since 0.1.0
*/ */
public function addSpecialCaseChar($char) public function addSpecialCaseChar($char)
{ {
$this->config->addSpecialCaseChar($char); $this->config->addSpecialCaseChar($char);
} }
/** /**
* @param string $char * @param string $char
* *
* @deprecated since 0.1.0 * @deprecated since 0.1.0
*/ */
public function removeSpecialCaseChar($char) public function removeSpecialCaseChar($char)
{ {
$this->config->removeSpecialCaseChar($char); $this->config->removeSpecialCaseChar($char);
} }
/** /**
* @param array $tags * @param array $tags
* *
* @deprecated since 0.1.0 * @deprecated since 0.1.0
*/ */
public function setSpecialCaseTags(array $tags = array()) public function setSpecialCaseTags(array $tags = array())
{ {
$this->config->setSpecialCaseChars($tags); $this->config->setSpecialCaseChars($tags);
} }
/** /**
* @param string $tag * @param string $tag
* *
* @deprecated since 0.1.0 * @deprecated since 0.1.0
*/ */
public function addSpecialCaseTag($tag) public function addSpecialCaseTag($tag)
{ {
$this->config->addSpecialCaseTag($tag); $this->config->addSpecialCaseTag($tag);
} }
/** /**
* @param string $tag * @param string $tag
* *
* @deprecated since 0.1.0 * @deprecated since 0.1.0
*/ */
public function removeSpecialCaseTag($tag) public function removeSpecialCaseTag($tag)
{ {
$this->config->removeSpecialCaseTag($tag); $this->config->removeSpecialCaseTag($tag);
} }
/** /**
* @return array|null * @return array|null
* *
* @deprecated since 0.1.0 * @deprecated since 0.1.0
*/ */
public function getSpecialCaseTags() public function getSpecialCaseTags()
{ {
return $this->config->getSpecialCaseTags(); return $this->config->getSpecialCaseTags();
} }
/** /**
* @return string * @return string
*/ */
public function getOldHtml() public function getOldHtml()
{ {
return $this->oldText; return $this->oldText;
} }
/** /**
* @return string * @return string
*/ */
public function getNewHtml() public function getNewHtml()
{ {
return $this->newText; return $this->newText;
} }
/** /**
* @return string * @return string
*/ */
public function getDifference() public function getDifference()
{ {
return $this->content; return $this->content;
} }
/** /**
* @param bool $boolean * @param bool $boolean
* *
* @return $this * @return $this
* *
* @deprecated since 0.1.0 * @deprecated since 0.1.0
*/ */
public function setGroupDiffs($boolean) public function setGroupDiffs($boolean)
{ {
$this->config->setGroupDiffs($boolean); $this->config->setGroupDiffs($boolean);
return $this; return $this;
} }
/** /**
* @return bool * @return bool
* *
* @deprecated since 0.1.0 * @deprecated since 0.1.0
*/ */
public function isGroupDiffs() public function isGroupDiffs()
{ {
return $this->config->isGroupDiffs(); return $this->config->isGroupDiffs();
} }
/** /**
* @param string $tag * @param string $tag
* *
* @return string * @return string
*/ */
protected function getOpeningTag($tag) protected function getOpeningTag($tag)
{ {
return "/<".$tag."[^>]*/i"; return "/<".$tag."[^>]*/i";
} }
/** /**
* @param string $tag * @param string $tag
* *
* @return string * @return string
*/ */
protected function getClosingTag($tag) protected function getClosingTag($tag)
{ {
return "</".$tag.">"; return "</".$tag.">";
} }
/** /**
* @param string $str * @param string $str
* @param string $start * @param string $start
* @param string $end * @param string $end
* *
* @return string * @return string
*/ */
protected function getStringBetween($str, $start, $end) protected function getStringBetween($str, $start, $end)
{ {
$expStr = explode( $start, $str, 2 ); $expStr = explode( $start, $str, 2 );
if ( count( $expStr ) > 1 ) { if ( count( $expStr ) > 1 ) {
$expStr = explode( $end, $expStr[ 1 ] ); $expStr = explode( $end, $expStr[ 1 ] );
if ( count( $expStr ) > 1 ) { if ( count( $expStr ) > 1 ) {
array_pop( $expStr ); array_pop( $expStr );
return implode( $end, $expStr ); return implode( $end, $expStr );
} }
} }
return ''; return '';
} }
/** /**
* @param string $html * @param string $html
* *
* @return string * @return string
*/ */
protected function purifyHtml($html) protected function purifyHtml($html)
{ {
if ( class_exists( 'Tidy' ) && false ) { if ( class_exists( 'Tidy' ) && false ) {
$config = array( 'output-xhtml' => true, 'indent' => false ); $config = array( 'output-xhtml' => true, 'indent' => false );
$tidy = new tidy(); $tidy = new tidy();
$tidy->parseString( $html, $config, 'utf8' ); $tidy->parseString( $html, $config, 'utf8' );
$html = (string) $tidy; $html = (string) $tidy;
return $this->getStringBetween( $html, '<body>' ); return $this->getStringBetween( $html, '<body>' );
} }
return $html; return $html;
} }
protected function splitInputsToWords() protected function splitInputsToWords()
{ {
$this->oldWords = $this->convertHtmlToListOfWords( $this->explode( $this->oldText ) ); $this->oldWords = $this->convertHtmlToListOfWords( $this->explode( $this->oldText ) );
$this->newWords = $this->convertHtmlToListOfWords( $this->explode( $this->newText ) ); $this->newWords = $this->convertHtmlToListOfWords( $this->explode( $this->newText ) );
} }
/** /**
* @param string $text * @param string $text
* *
* @return bool * @return bool
*/ */
protected function isPartOfWord($text) protected function isPartOfWord($text)
{ {
return ctype_alnum(str_replace($this->config->getSpecialCaseChars(), '', $text)); return ctype_alnum(str_replace($this->config->getSpecialCaseChars(), '', $text));
} }
/** /**
* @param array $characterString * @param array $characterString
* *
* @return array * @return array
*/ */
protected function convertHtmlToListOfWords($characterString) protected function convertHtmlToListOfWords($characterString)
{ {
$mode = 'character'; $mode = 'character';
$current_word = ''; $current_word = '';
$words = array(); $words = array();
foreach ($characterString as $i => $character) { foreach ($characterString as $i => $character) {
switch ($mode) { switch ($mode) {
case 'character': case 'character':
if ( $this->isStartOfTag( $character ) ) { if ( $this->isStartOfTag( $character ) ) {
if ($current_word != '') { if ($current_word != '') {
$words[] = $current_word; $words[] = $current_word;
} }
$current_word = "<"; $current_word = "<";
$mode = 'tag'; $mode = 'tag';
} elseif (preg_match("/\s/", $character)) { } elseif (preg_match("/\s/", $character)) {
if ($current_word !== '') { if ($current_word !== '') {
$words[] = $current_word; $words[] = $current_word;
} }
$current_word = preg_replace('/\s+/S', ' ', $character); $current_word = preg_replace('/\s+/S', ' ', $character);
$mode = 'whitespace'; $mode = 'whitespace';
} else { } else {
if ( if (
(ctype_alnum($character) && (strlen($current_word) == 0 || $this->isPartOfWord($current_word))) || (ctype_alnum($character) && (strlen($current_word) == 0 || $this->isPartOfWord($current_word))) ||
(in_array($character, $this->config->getSpecialCaseChars()) && isset($characterString[$i+1]) && $this->isPartOfWord($characterString[$i+1])) (in_array($character, $this->config->getSpecialCaseChars()) && isset($characterString[$i+1]) && $this->isPartOfWord($characterString[$i+1]))
) { ) {
$current_word .= $character; $current_word .= $character;
} else { } else {
$words[] = $current_word; $words[] = $current_word;
$current_word = $character; $current_word = $character;
} }
} }
break; break;
case 'tag' : case 'tag' :
if ( $this->isEndOfTag( $character ) ) { if ( $this->isEndOfTag( $character ) ) {
$current_word .= ">"; $current_word .= ">";
$words[] = $current_word; $words[] = $current_word;
$current_word = ""; $current_word = "";
if ( !preg_match('[^\s]', $character ) ) { if ( !preg_match('[^\s]', $character ) ) {
$mode = 'whitespace'; $mode = 'whitespace';
} else { } else {
$mode = 'character'; $mode = 'character';
} }
} else { } else {
$current_word .= $character; $current_word .= $character;
} }
break; break;
case 'whitespace': case 'whitespace':
if ( $this->isStartOfTag( $character ) ) { if ( $this->isStartOfTag( $character ) ) {
if ($current_word !== '') { if ($current_word !== '') {
$words[] = $current_word; $words[] = $current_word;
} }
$current_word = "<"; $current_word = "<";
$mode = 'tag'; $mode = 'tag';
} elseif ( preg_match( "/\s/", $character ) ) { } elseif ( preg_match( "/\s/", $character ) ) {
$current_word .= $character; $current_word .= $character;
$current_word = preg_replace('/\s+/S', ' ', $current_word); $current_word = preg_replace('/\s+/S', ' ', $current_word);
} else { } else {
if ($current_word != '') { if ($current_word != '') {
$words[] = $current_word; $words[] = $current_word;
} }
$current_word = $character; $current_word = $character;
$mode = 'character'; $mode = 'character';
} }
break; break;
default: default:
break; break;
} }
} }
if ($current_word != '') { if ($current_word != '') {
$words[] = $current_word; $words[] = $current_word;
} }
return $words; return $words;
} }
/** /**
* @param string $val * @param string $val
* *
* @return bool * @return bool
*/ */
protected function isStartOfTag($val) protected function isStartOfTag($val)
{ {
return $val == "<"; return $val == "<";
} }
/** /**
* @param string $val * @param string $val
* *
* @return bool * @return bool
*/ */
protected function isEndOfTag($val) protected function isEndOfTag($val)
{ {
return $val == ">"; return $val == ">";
} }
/** /**
* @param string $value * @param string $value
* *
* @return bool * @return bool
*/ */
protected function isWhiteSpace($value) protected function isWhiteSpace($value)
{ {
return !preg_match( '[^\s]', $value ); return !preg_match( '[^\s]', $value );
} }
/** /**
* @param string $value * @param string $value
* *
* @return array * @return array
*/ */
protected function explode($value) protected function explode($value)
{ {
// as suggested by @onassar // as suggested by @onassar
return preg_split( '//u', $value ); return preg_split( '//u', $value );
} }
} }

@ -1,112 +1,112 @@
<?php <?php
namespace Caxy\HtmlDiff; namespace Caxy\HtmlDiff;
use Doctrine\Common\Cache\Cache; use Doctrine\Common\Cache\Cache;
/** /**
* Class DiffCache * Class DiffCache
* @package Caxy\HtmlDiff * @package Caxy\HtmlDiff
*/ */
class DiffCache class DiffCache
{ {
/** /**
* @var Cache * @var Cache
*/ */
protected $cacheProvider; protected $cacheProvider;
/** /**
* DiffCache constructor. * DiffCache constructor.
* *
* @param Cache $cacheProvider * @param Cache $cacheProvider
*/ */
public function __construct(Cache $cacheProvider) public function __construct(Cache $cacheProvider)
{ {
$this->cacheProvider = $cacheProvider; $this->cacheProvider = $cacheProvider;
} }
/** /**
* @return Cache * @return Cache
*/ */
public function getCacheProvider() public function getCacheProvider()
{ {
return $this->cacheProvider; return $this->cacheProvider;
} }
/** /**
* @param Cache $cacheProvider * @param Cache $cacheProvider
* *
* @return DiffCache * @return DiffCache
*/ */
public function setCacheProvider($cacheProvider) public function setCacheProvider($cacheProvider)
{ {
$this->cacheProvider = $cacheProvider; $this->cacheProvider = $cacheProvider;
return $this; return $this;
} }
/** /**
* @param string $oldText * @param string $oldText
* @param string $newText * @param string $newText
* *
* @return bool * @return bool
*/ */
public function contains($oldText, $newText) public function contains($oldText, $newText)
{ {
return $this->cacheProvider->contains($this->getHashKey($oldText, $newText)); return $this->cacheProvider->contains($this->getHashKey($oldText, $newText));
} }
/** /**
* @param string $oldText * @param string $oldText
* @param string $newText * @param string $newText
* *
* @return string * @return string
*/ */
public function fetch($oldText, $newText) public function fetch($oldText, $newText)
{ {
return $this->cacheProvider->fetch($this->getHashKey($oldText, $newText)); return $this->cacheProvider->fetch($this->getHashKey($oldText, $newText));
} }
/** /**
* @param string $oldText * @param string $oldText
* @param string $newText * @param string $newText
* @param string $data * @param string $data
* @param int $lifeTime * @param int $lifeTime
* *
* @return bool * @return bool
*/ */
public function save($oldText, $newText, $data, $lifeTime = 0) public function save($oldText, $newText, $data, $lifeTime = 0)
{ {
return $this->cacheProvider->save($this->getHashKey($oldText, $newText), $data, $lifeTime); return $this->cacheProvider->save($this->getHashKey($oldText, $newText), $data, $lifeTime);
} }
/** /**
* @param string $oldText * @param string $oldText
* @param string $newText * @param string $newText
* *
* @return bool * @return bool
*/ */
public function delete($oldText, $newText) public function delete($oldText, $newText)
{ {
return $this->cacheProvider->delete($this->getHashKey($oldText, $newText)); return $this->cacheProvider->delete($this->getHashKey($oldText, $newText));
} }
/** /**
* @return array|null * @return array|null
*/ */
public function getStats() public function getStats()
{ {
return $this->cacheProvider->getStats(); return $this->cacheProvider->getStats();
} }
/** /**
* @param string $oldText * @param string $oldText
* @param string $newText * @param string $newText
* *
* @return string * @return string
*/ */
protected function getHashKey($oldText, $newText) protected function getHashKey($oldText, $newText)
{ {
return sprintf('%s_%s', md5($oldText), md5($newText)); return sprintf('%s_%s', md5($oldText), md5($newText));
} }
} }

File diff suppressed because it is too large Load Diff

@ -1,488 +1,488 @@
<?php <?php
namespace Caxy\HtmlDiff; namespace Caxy\HtmlDiff;
/** /**
* Class HtmlDiffConfig * Class HtmlDiffConfig
* @package Caxy\HtmlDiff * @package Caxy\HtmlDiff
*/ */
class HtmlDiffConfig class HtmlDiffConfig
{ {
/** /**
* @var array * @var array
*/ */
protected $specialCaseTags = array('strong', 'b', 'i', 'big', 'small', 'u', 'sub', 'sup', 'strike', 's', 'p'); protected $specialCaseTags = array('strong', 'b', 'i', 'big', 'small', 'u', 'sub', 'sup', 'strike', 's', 'p');
/** /**
* @var array * @var array
*/ */
protected $specialCaseChars = array('.', ',', '(', ')', '\''); protected $specialCaseChars = array('.', ',', '(', ')', '\'');
/** /**
* @var bool * @var bool
*/ */
protected $groupDiffs = true; protected $groupDiffs = true;
/** /**
* @var bool * @var bool
*/ */
protected $insertSpaceInReplace = false; protected $insertSpaceInReplace = false;
/** /**
* @var string * @var string
*/ */
protected $encoding = 'UTF-8'; protected $encoding = 'UTF-8';
/** /**
* @var array * @var array
*/ */
protected $isolatedDiffTags = array( protected $isolatedDiffTags = array(
'ol' => '[[REPLACE_ORDERED_LIST]]', 'ol' => '[[REPLACE_ORDERED_LIST]]',
'ul' => '[[REPLACE_UNORDERED_LIST]]', 'ul' => '[[REPLACE_UNORDERED_LIST]]',
'sub' => '[[REPLACE_SUB_SCRIPT]]', 'sub' => '[[REPLACE_SUB_SCRIPT]]',
'sup' => '[[REPLACE_SUPER_SCRIPT]]', 'sup' => '[[REPLACE_SUPER_SCRIPT]]',
'dl' => '[[REPLACE_DEFINITION_LIST]]', 'dl' => '[[REPLACE_DEFINITION_LIST]]',
'table' => '[[REPLACE_TABLE]]', 'table' => '[[REPLACE_TABLE]]',
'strong' => '[[REPLACE_STRONG]]', 'strong' => '[[REPLACE_STRONG]]',
'b' => '[[REPLACE_B]]', 'b' => '[[REPLACE_B]]',
'em' => '[[REPLACE_EM]]', 'em' => '[[REPLACE_EM]]',
'i' => '[[REPLACE_I]]', 'i' => '[[REPLACE_I]]',
'a' => '[[REPLACE_A]]', 'a' => '[[REPLACE_A]]',
); );
/** /**
* @var int * @var int
*/ */
protected $matchThreshold = 80; protected $matchThreshold = 80;
/** /**
* @var array * @var array
*/ */
protected $specialCaseOpeningTags = array(); protected $specialCaseOpeningTags = array();
/** /**
* @var array * @var array
*/ */
protected $specialCaseClosingTags = array(); protected $specialCaseClosingTags = array();
/** /**
* @var bool * @var bool
*/ */
protected $useTableDiffing = true; protected $useTableDiffing = true;
/** /**
* @var null|\Doctrine\Common\Cache\Cache * @var null|\Doctrine\Common\Cache\Cache
*/ */
protected $cacheProvider; protected $cacheProvider;
/** /**
* @var null|string * @var null|string
*/ */
protected $purifierCacheLocation = null; protected $purifierCacheLocation = null;
/** /**
* @return HtmlDiffConfig * @return HtmlDiffConfig
*/ */
public static function create() public static function create()
{ {
return new self(); return new self();
} }
/** /**
* HtmlDiffConfig constructor. * HtmlDiffConfig constructor.
*/ */
public function __construct() public function __construct()
{ {
$this->setSpecialCaseTags($this->specialCaseTags); $this->setSpecialCaseTags($this->specialCaseTags);
} }
/** /**
* @return int * @return int
*/ */
public function getMatchThreshold() public function getMatchThreshold()
{ {
return $this->matchThreshold; return $this->matchThreshold;
} }
/** /**
* @param int $matchThreshold * @param int $matchThreshold
* *
* @return AbstractDiff * @return AbstractDiff
*/ */
public function setMatchThreshold($matchThreshold) public function setMatchThreshold($matchThreshold)
{ {
$this->matchThreshold = $matchThreshold; $this->matchThreshold = $matchThreshold;
return $this; return $this;
} }
/** /**
* @param array $chars * @param array $chars
*/ */
public function setSpecialCaseChars(array $chars) public function setSpecialCaseChars(array $chars)
{ {
$this->specialCaseChars = $chars; $this->specialCaseChars = $chars;
} }
/** /**
* @return array|null * @return array|null
*/ */
public function getSpecialCaseChars() public function getSpecialCaseChars()
{ {
return $this->specialCaseChars; return $this->specialCaseChars;
} }
/** /**
* @param string $char * @param string $char
* *
* @return $this * @return $this
*/ */
public function addSpecialCaseChar($char) public function addSpecialCaseChar($char)
{ {
if (!in_array($char, $this->specialCaseChars)) { if (!in_array($char, $this->specialCaseChars)) {
$this->specialCaseChars[] = $char; $this->specialCaseChars[] = $char;
} }
return $this; return $this;
} }
/** /**
* @param string $char * @param string $char
* *
* @return $this * @return $this
*/ */
public function removeSpecialCaseChar($char) public function removeSpecialCaseChar($char)
{ {
$key = array_search($char, $this->specialCaseChars); $key = array_search($char, $this->specialCaseChars);
if ($key !== false) { if ($key !== false) {
unset($this->specialCaseChars[$key]); unset($this->specialCaseChars[$key]);
} }
return $this; return $this;
} }
/** /**
* @param array $tags * @param array $tags
* *
* @return $this * @return $this
*/ */
public function setSpecialCaseTags(array $tags = array()) public function setSpecialCaseTags(array $tags = array())
{ {
$this->specialCaseTags = $tags; $this->specialCaseTags = $tags;
$this->specialCaseOpeningTags = array(); $this->specialCaseOpeningTags = array();
$this->specialCaseClosingTags = array(); $this->specialCaseClosingTags = array();
foreach ($this->specialCaseTags as $tag) { foreach ($this->specialCaseTags as $tag) {
$this->addSpecialCaseTag($tag); $this->addSpecialCaseTag($tag);
} }
return $this; return $this;
} }
/** /**
* @param string $tag * @param string $tag
* *
* @return $this * @return $this
*/ */
public function addSpecialCaseTag($tag) public function addSpecialCaseTag($tag)
{ {
if (!in_array($tag, $this->specialCaseTags)) { if (!in_array($tag, $this->specialCaseTags)) {
$this->specialCaseTags[] = $tag; $this->specialCaseTags[] = $tag;
} }
$opening = $this->getOpeningTag($tag); $opening = $this->getOpeningTag($tag);
$closing = $this->getClosingTag($tag); $closing = $this->getClosingTag($tag);
if (!in_array($opening, $this->specialCaseOpeningTags)) { if (!in_array($opening, $this->specialCaseOpeningTags)) {
$this->specialCaseOpeningTags[] = $opening; $this->specialCaseOpeningTags[] = $opening;
} }
if (!in_array($closing, $this->specialCaseClosingTags)) { if (!in_array($closing, $this->specialCaseClosingTags)) {
$this->specialCaseClosingTags[] = $closing; $this->specialCaseClosingTags[] = $closing;
} }
return $this; return $this;
} }
/** /**
* @param string $tag * @param string $tag
* *
* @return $this * @return $this
*/ */
public function removeSpecialCaseTag($tag) public function removeSpecialCaseTag($tag)
{ {
if (($key = array_search($tag, $this->specialCaseTags)) !== false) { if (($key = array_search($tag, $this->specialCaseTags)) !== false) {
unset($this->specialCaseTags[$key]); unset($this->specialCaseTags[$key]);
$opening = $this->getOpeningTag($tag); $opening = $this->getOpeningTag($tag);
$closing = $this->getClosingTag($tag); $closing = $this->getClosingTag($tag);
if (($key = array_search($opening, $this->specialCaseOpeningTags)) !== false) { if (($key = array_search($opening, $this->specialCaseOpeningTags)) !== false) {
unset($this->specialCaseOpeningTags[$key]); unset($this->specialCaseOpeningTags[$key]);
} }
if (($key = array_search($closing, $this->specialCaseClosingTags)) !== false) { if (($key = array_search($closing, $this->specialCaseClosingTags)) !== false) {
unset($this->specialCaseClosingTags[$key]); unset($this->specialCaseClosingTags[$key]);
} }
} }
return $this; return $this;
} }
/** /**
* @return array|null * @return array|null
*/ */
public function getSpecialCaseTags() public function getSpecialCaseTags()
{ {
return $this->specialCaseTags; return $this->specialCaseTags;
} }
/** /**
* @return boolean * @return boolean
*/ */
public function isGroupDiffs() public function isGroupDiffs()
{ {
return $this->groupDiffs; return $this->groupDiffs;
} }
/** /**
* @param boolean $groupDiffs * @param boolean $groupDiffs
* *
* @return HtmlDiffConfig * @return HtmlDiffConfig
*/ */
public function setGroupDiffs($groupDiffs) public function setGroupDiffs($groupDiffs)
{ {
$this->groupDiffs = $groupDiffs; $this->groupDiffs = $groupDiffs;
return $this; return $this;
} }
/** /**
* @return string * @return string
*/ */
public function getEncoding() public function getEncoding()
{ {
return $this->encoding; return $this->encoding;
} }
/** /**
* @param string $encoding * @param string $encoding
* *
* @return HtmlDiffConfig * @return HtmlDiffConfig
*/ */
public function setEncoding($encoding) public function setEncoding($encoding)
{ {
$this->encoding = $encoding; $this->encoding = $encoding;
return $this; return $this;
} }
/** /**
* @return boolean * @return boolean
*/ */
public function isInsertSpaceInReplace() public function isInsertSpaceInReplace()
{ {
return $this->insertSpaceInReplace; return $this->insertSpaceInReplace;
} }
/** /**
* @param boolean $insertSpaceInReplace * @param boolean $insertSpaceInReplace
* *
* @return HtmlDiffConfig * @return HtmlDiffConfig
*/ */
public function setInsertSpaceInReplace($insertSpaceInReplace) public function setInsertSpaceInReplace($insertSpaceInReplace)
{ {
$this->insertSpaceInReplace = $insertSpaceInReplace; $this->insertSpaceInReplace = $insertSpaceInReplace;
return $this; return $this;
} }
/** /**
* @return array * @return array
*/ */
public function getIsolatedDiffTags() public function getIsolatedDiffTags()
{ {
return $this->isolatedDiffTags; return $this->isolatedDiffTags;
} }
/** /**
* @param array $isolatedDiffTags * @param array $isolatedDiffTags
* *
* @return HtmlDiffConfig * @return HtmlDiffConfig
*/ */
public function setIsolatedDiffTags($isolatedDiffTags) public function setIsolatedDiffTags($isolatedDiffTags)
{ {
$this->isolatedDiffTags = $isolatedDiffTags; $this->isolatedDiffTags = $isolatedDiffTags;
return $this; return $this;
} }
/** /**
* @param string $tag * @param string $tag
* @param null|string $placeholder * @param null|string $placeholder
* *
* @return $this * @return $this
*/ */
public function addIsolatedDiffTag($tag, $placeholder = null) public function addIsolatedDiffTag($tag, $placeholder = null)
{ {
if (null === $placeholder) { if (null === $placeholder) {
$placeholder = sprintf('[[REPLACE_%s]]', strtoupper($tag)); $placeholder = sprintf('[[REPLACE_%s]]', strtoupper($tag));
} }
if ($this->isIsolatedDiffTag($tag) && $this->isolatedDiffTags[$tag] !== $placeholder) { if ($this->isIsolatedDiffTag($tag) && $this->isolatedDiffTags[$tag] !== $placeholder) {
throw new \InvalidArgumentException( throw new \InvalidArgumentException(
sprintf('Isolated diff tag "%s" already exists using a different placeholder', $tag) sprintf('Isolated diff tag "%s" already exists using a different placeholder', $tag)
); );
} }
$matchingKey = array_search($placeholder, $this->isolatedDiffTags, true); $matchingKey = array_search($placeholder, $this->isolatedDiffTags, true);
if (false !== $matchingKey && $matchingKey !== $tag) { if (false !== $matchingKey && $matchingKey !== $tag) {
throw new \InvalidArgumentException( throw new \InvalidArgumentException(
sprintf('Placeholder already being used for a different tag "%s"', $tag) sprintf('Placeholder already being used for a different tag "%s"', $tag)
); );
} }
if (!array_key_exists($tag, $this->isolatedDiffTags)) { if (!array_key_exists($tag, $this->isolatedDiffTags)) {
$this->isolatedDiffTags[$tag] = $placeholder; $this->isolatedDiffTags[$tag] = $placeholder;
} }
return $this; return $this;
} }
/** /**
* @param string $tag * @param string $tag
* *
* @return $this * @return $this
*/ */
public function removeIsolatedDiffTag($tag) public function removeIsolatedDiffTag($tag)
{ {
if ($this->isIsolatedDiffTag($tag)) { if ($this->isIsolatedDiffTag($tag)) {
unset($this->isolatedDiffTags[$tag]); unset($this->isolatedDiffTags[$tag]);
} }
return $this; return $this;
} }
/** /**
* @param string $tag * @param string $tag
* *
* @return bool * @return bool
*/ */
public function isIsolatedDiffTag($tag) public function isIsolatedDiffTag($tag)
{ {
return array_key_exists($tag, $this->isolatedDiffTags); return array_key_exists($tag, $this->isolatedDiffTags);
} }
/** /**
* @param string $text * @param string $text
* *
* @return bool * @return bool
*/ */
public function isIsolatedDiffTagPlaceholder($text) public function isIsolatedDiffTagPlaceholder($text)
{ {
return in_array($text, $this->isolatedDiffTags, true); return in_array($text, $this->isolatedDiffTags, true);
} }
/** /**
* @param string $tag * @param string $tag
* *
* @return null|string * @return null|string
*/ */
public function getIsolatedDiffTagPlaceholder($tag) public function getIsolatedDiffTagPlaceholder($tag)
{ {
return $this->isIsolatedDiffTag($tag) ? $this->isolatedDiffTags[$tag] : null; return $this->isIsolatedDiffTag($tag) ? $this->isolatedDiffTags[$tag] : null;
} }
/** /**
* @return array * @return array
*/ */
public function getSpecialCaseOpeningTags() public function getSpecialCaseOpeningTags()
{ {
return $this->specialCaseOpeningTags; return $this->specialCaseOpeningTags;
} }
/** /**
* @return array * @return array
*/ */
public function getSpecialCaseClosingTags() public function getSpecialCaseClosingTags()
{ {
return $this->specialCaseClosingTags; return $this->specialCaseClosingTags;
} }
/** /**
* @return boolean * @return boolean
*/ */
public function isUseTableDiffing() public function isUseTableDiffing()
{ {
return $this->useTableDiffing; return $this->useTableDiffing;
} }
/** /**
* @param boolean $useTableDiffing * @param boolean $useTableDiffing
* *
* @return HtmlDiffConfig * @return HtmlDiffConfig
*/ */
public function setUseTableDiffing($useTableDiffing) public function setUseTableDiffing($useTableDiffing)
{ {
$this->useTableDiffing = $useTableDiffing; $this->useTableDiffing = $useTableDiffing;
return $this; return $this;
} }
/** /**
* @param null|\Doctrine\Common\Cache\Cache $cacheProvider * @param null|\Doctrine\Common\Cache\Cache $cacheProvider
* *
* @return $this * @return $this
*/ */
public function setCacheProvider(\Doctrine\Common\Cache\Cache $cacheProvider = null) public function setCacheProvider(\Doctrine\Common\Cache\Cache $cacheProvider = null)
{ {
$this->cacheProvider = $cacheProvider; $this->cacheProvider = $cacheProvider;
return $this; return $this;
} }
/** /**
* @return null|\Doctrine\Common\Cache\Cache * @return null|\Doctrine\Common\Cache\Cache
*/ */
public function getCacheProvider() public function getCacheProvider()
{ {
return $this->cacheProvider; return $this->cacheProvider;
} }
/** /**
* @param null|string * @param null|string
* *
* @return $this * @return $this
*/ */
public function setPurifierCacheLocation($purifierCacheLocation = null) public function setPurifierCacheLocation($purifierCacheLocation = null)
{ {
$this->purifierCacheLocation = $purifierCacheLocation; $this->purifierCacheLocation = $purifierCacheLocation;
return $this; return $this;
} }
/** /**
* @return null|string * @return null|string
*/ */
public function getPurifierCacheLocation() public function getPurifierCacheLocation()
{ {
return $this->purifierCacheLocation; return $this->purifierCacheLocation;
} }
/** /**
* @param string $tag * @param string $tag
* *
* @return string * @return string
*/ */
protected function getOpeningTag($tag) protected function getOpeningTag($tag)
{ {
return "/<".$tag."[^>]*/i"; return "/<".$tag."[^>]*/i";
} }
/** /**
* @param string $tag * @param string $tag
* *
* @return string * @return string
*/ */
protected function getClosingTag($tag) protected function getClosingTag($tag)
{ {
return "</".$tag.">"; return "</".$tag.">";
} }
} }

File diff suppressed because it is too large Load Diff

@ -1,102 +1,102 @@
<?php <?php
namespace Caxy\HtmlDiff\ListDiff; namespace Caxy\HtmlDiff\ListDiff;
class DiffList class DiffList
{ {
protected $listType; protected $listType;
protected $listItems = array(); protected $listItems = array();
protected $attributes = array(); protected $attributes = array();
protected $startTag; protected $startTag;
protected $endTag; protected $endTag;
public function __construct($listType, $startTag, $endTag, $listItems = array(), $attributes = array()) public function __construct($listType, $startTag, $endTag, $listItems = array(), $attributes = array())
{ {
$this->listType = $listType; $this->listType = $listType;
$this->startTag = $startTag; $this->startTag = $startTag;
$this->endTag = $endTag; $this->endTag = $endTag;
$this->listItems = $listItems; $this->listItems = $listItems;
$this->attributes = $attributes; $this->attributes = $attributes;
} }
/** /**
* @return mixed * @return mixed
*/ */
public function getListType() public function getListType()
{ {
return $this->listType; return $this->listType;
} }
/** /**
* @param mixed $listType * @param mixed $listType
* *
* @return DiffList * @return DiffList
*/ */
public function setListType($listType) public function setListType($listType)
{ {
$this->listType = $listType; $this->listType = $listType;
return $this; return $this;
} }
/** /**
* @return mixed * @return mixed
*/ */
public function getStartTag() public function getStartTag()
{ {
return $this->startTag; return $this->startTag;
} }
public function getStartTagWithDiffClass($class = 'diff-list') public function getStartTagWithDiffClass($class = 'diff-list')
{ {
return str_replace('>', ' class="'.$class.'">', $this->startTag); return str_replace('>', ' class="'.$class.'">', $this->startTag);
} }
/** /**
* @param mixed $startTag * @param mixed $startTag
*/ */
public function setStartTag($startTag) public function setStartTag($startTag)
{ {
$this->startTag = $startTag; $this->startTag = $startTag;
} }
/** /**
* @return mixed * @return mixed
*/ */
public function getEndTag() public function getEndTag()
{ {
return $this->endTag; return $this->endTag;
} }
/** /**
* @param mixed $endTag * @param mixed $endTag
*/ */
public function setEndTag($endTag) public function setEndTag($endTag)
{ {
$this->endTag = $endTag; $this->endTag = $endTag;
} }
/** /**
* @return mixed * @return mixed
*/ */
public function getListItems() public function getListItems()
{ {
return $this->listItems; return $this->listItems;
} }
/** /**
* @param mixed $listItems * @param mixed $listItems
* *
* @return DiffList * @return DiffList
*/ */
public function setListItems($listItems) public function setListItems($listItems)
{ {
$this->listItems = $listItems; $this->listItems = $listItems;
return $this; return $this;
} }
} }

@ -1,124 +1,124 @@
<?php <?php
namespace Caxy\HtmlDiff\ListDiff; namespace Caxy\HtmlDiff\ListDiff;
class DiffListItem class DiffListItem
{ {
protected $attributes = array(); protected $attributes = array();
protected $text; protected $text;
protected $startTag; protected $startTag;
protected $endTag; protected $endTag;
public function __construct($text, $attributes = array(), $startTag, $endTag) public function __construct($text, $attributes = array(), $startTag, $endTag)
{ {
$this->text = $text; $this->text = $text;
$this->attributes = $attributes; $this->attributes = $attributes;
$this->startTag = $startTag; $this->startTag = $startTag;
$this->endTag = $endTag; $this->endTag = $endTag;
} }
/** /**
* @return array * @return array
*/ */
public function getAttributes() public function getAttributes()
{ {
return $this->attributes; return $this->attributes;
} }
/** /**
* @param array $attributes * @param array $attributes
* *
* @return DiffListItem * @return DiffListItem
*/ */
public function setAttributes($attributes) public function setAttributes($attributes)
{ {
$this->attributes = $attributes; $this->attributes = $attributes;
return $this; return $this;
} }
/** /**
* @return mixed * @return mixed
*/ */
public function getText() public function getText()
{ {
return $this->text; return $this->text;
} }
/** /**
* @param mixed $text * @param mixed $text
* *
* @return DiffListItem * @return DiffListItem
*/ */
public function setText($text) public function setText($text)
{ {
$this->text = $text; $this->text = $text;
return $this; return $this;
} }
/** /**
* @return mixed * @return mixed
*/ */
public function getStartTag() public function getStartTag()
{ {
return $this->startTag; return $this->startTag;
} }
public function getStartTagWithDiffClass($class = 'normal') public function getStartTagWithDiffClass($class = 'normal')
{ {
return str_replace('>', ' class="'.$class.'">', $this->startTag); return str_replace('>', ' class="'.$class.'">', $this->startTag);
} }
/** /**
* @param mixed $startTag * @param mixed $startTag
* *
* @return DiffListItem * @return DiffListItem
*/ */
public function setStartTag($startTag) public function setStartTag($startTag)
{ {
$this->startTag = $startTag; $this->startTag = $startTag;
return $this; return $this;
} }
/** /**
* @return mixed * @return mixed
*/ */
public function getEndTag() public function getEndTag()
{ {
return $this->endTag; return $this->endTag;
} }
/** /**
* @param mixed $endTag * @param mixed $endTag
* *
* @return DiffListItem * @return DiffListItem
*/ */
public function setEndTag($endTag) public function setEndTag($endTag)
{ {
$this->endTag = $endTag; $this->endTag = $endTag;
return $this; return $this;
} }
public function getHtml($class = 'normal', $wrapTag = null) public function getHtml($class = 'normal', $wrapTag = null)
{ {
$startWrap = $wrapTag ? sprintf('<%s>', $wrapTag) : ''; $startWrap = $wrapTag ? sprintf('<%s>', $wrapTag) : '';
$endWrap = $wrapTag ? sprintf('</%s>', $wrapTag) : ''; $endWrap = $wrapTag ? sprintf('</%s>', $wrapTag) : '';
return sprintf('%s%s%s%s%s', $this->getStartTagWithDiffClass($class), $startWrap, $this->getInnerHtml(), $endWrap, $this->endTag); return sprintf('%s%s%s%s%s', $this->getStartTagWithDiffClass($class), $startWrap, $this->getInnerHtml(), $endWrap, $this->endTag);
} }
public function getInnerHtml() public function getInnerHtml()
{ {
return implode('', $this->text); return implode('', $this->text);
} }
public function __toString() public function __toString()
{ {
return $this->getHtml(); return $this->getHtml();
} }
} }

@ -1,280 +1,280 @@
<?php <?php
namespace Caxy\HtmlDiff; namespace Caxy\HtmlDiff;
use Caxy\HtmlDiff\ListDiff\DiffList; use Caxy\HtmlDiff\ListDiff\DiffList;
use Caxy\HtmlDiff\ListDiff\DiffListItem; use Caxy\HtmlDiff\ListDiff\DiffListItem;
class ListDiffNew extends AbstractDiff class ListDiffNew extends AbstractDiff
{ {
protected static $listTypes = array('ul', 'ol', 'dl'); protected static $listTypes = array('ul', 'ol', 'dl');
/** /**
* @param string $oldText * @param string $oldText
* @param string $newText * @param string $newText
* @param HtmlDiffConfig|null $config * @param HtmlDiffConfig|null $config
* *
* @return self * @return self
*/ */
public static function create($oldText, $newText, HtmlDiffConfig $config = null) public static function create($oldText, $newText, HtmlDiffConfig $config = null)
{ {
$diff = new self($oldText, $newText); $diff = new self($oldText, $newText);
if (null !== $config) { if (null !== $config) {
$diff->setConfig($config); $diff->setConfig($config);
} }
return $diff; return $diff;
} }
public function build() public function build()
{ {
if ($this->hasDiffCache() && $this->getDiffCache()->contains($this->oldText, $this->newText)) { if ($this->hasDiffCache() && $this->getDiffCache()->contains($this->oldText, $this->newText)) {
$this->content = $this->getDiffCache()->fetch($this->oldText, $this->newText); $this->content = $this->getDiffCache()->fetch($this->oldText, $this->newText);
return $this->content; return $this->content;
} }
$this->splitInputsToWords(); $this->splitInputsToWords();
$this->content = $this->diffLists( $this->content = $this->diffLists(
$this->buildDiffList($this->oldWords), $this->buildDiffList($this->oldWords),
$this->buildDiffList($this->newWords) $this->buildDiffList($this->newWords)
); );
if ($this->hasDiffCache()) { if ($this->hasDiffCache()) {
$this->getDiffCache()->save($this->oldText, $this->newText, $this->content); $this->getDiffCache()->save($this->oldText, $this->newText, $this->content);
} }
return $this->content; return $this->content;
} }
protected function diffLists(DiffList $oldList, DiffList $newList) protected function diffLists(DiffList $oldList, DiffList $newList)
{ {
$oldMatchData = array(); $oldMatchData = array();
$newMatchData = array(); $newMatchData = array();
$oldListIndices = array(); $oldListIndices = array();
$newListIndices = array(); $newListIndices = array();
$oldListItems = array(); $oldListItems = array();
$newListItems = array(); $newListItems = array();
foreach ($oldList->getListItems() as $oldIndex => $oldListItem) { foreach ($oldList->getListItems() as $oldIndex => $oldListItem) {
if ($oldListItem instanceof DiffListItem) { if ($oldListItem instanceof DiffListItem) {
$oldListItems[$oldIndex] = $oldListItem; $oldListItems[$oldIndex] = $oldListItem;
$oldListIndices[] = $oldIndex; $oldListIndices[] = $oldIndex;
$oldMatchData[$oldIndex] = array(); $oldMatchData[$oldIndex] = array();
// Get match percentages // Get match percentages
foreach ($newList->getListItems() as $newIndex => $newListItem) { foreach ($newList->getListItems() as $newIndex => $newListItem) {
if ($newListItem instanceof DiffListItem) { if ($newListItem instanceof DiffListItem) {
if (!in_array($newListItem, $newListItems)) { if (!in_array($newListItem, $newListItems)) {
$newListItems[$newIndex] = $newListItem; $newListItems[$newIndex] = $newListItem;
} }
if (!in_array($newIndex, $newListIndices)) { if (!in_array($newIndex, $newListIndices)) {
$newListIndices[] = $newIndex; $newListIndices[] = $newIndex;
} }
if (!array_key_exists($newIndex, $newMatchData)) { if (!array_key_exists($newIndex, $newMatchData)) {
$newMatchData[$newIndex] = array(); $newMatchData[$newIndex] = array();
} }
$oldText = implode('', $oldListItem->getText()); $oldText = implode('', $oldListItem->getText());
$newText = implode('', $newListItem->getText()); $newText = implode('', $newListItem->getText());
// similar_text // similar_text
$percentage = null; $percentage = null;
similar_text($oldText, $newText, $percentage); similar_text($oldText, $newText, $percentage);
$oldMatchData[$oldIndex][$newIndex] = $percentage; $oldMatchData[$oldIndex][$newIndex] = $percentage;
$newMatchData[$newIndex][$oldIndex] = $percentage; $newMatchData[$newIndex][$oldIndex] = $percentage;
} }
} }
} }
} }
$currentIndexInOld = 0; $currentIndexInOld = 0;
$currentIndexInNew = 0; $currentIndexInNew = 0;
$oldCount = count($oldListIndices); $oldCount = count($oldListIndices);
$newCount = count($newListIndices); $newCount = count($newListIndices);
$difference = max($oldCount, $newCount) - min($oldCount, $newCount); $difference = max($oldCount, $newCount) - min($oldCount, $newCount);
$diffOutput = ''; $diffOutput = '';
foreach ($newList->getListItems() as $newIndex => $newListItem) { foreach ($newList->getListItems() as $newIndex => $newListItem) {
if ($newListItem instanceof DiffListItem) { if ($newListItem instanceof DiffListItem) {
$operation = null; $operation = null;
$oldListIndex = array_key_exists($currentIndexInOld, $oldListIndices) ? $oldListIndices[$currentIndexInOld] : null; $oldListIndex = array_key_exists($currentIndexInOld, $oldListIndices) ? $oldListIndices[$currentIndexInOld] : null;
$class = 'normal'; $class = 'normal';
if (null !== $oldListIndex && array_key_exists($oldListIndex, $oldMatchData)) { if (null !== $oldListIndex && array_key_exists($oldListIndex, $oldMatchData)) {
// Check percentage matches of upcoming list items in old. // Check percentage matches of upcoming list items in old.
$matchPercentage = $oldMatchData[$oldListIndex][$newIndex]; $matchPercentage = $oldMatchData[$oldListIndex][$newIndex];
// does the old list item match better? // does the old list item match better?
$otherMatchBetter = false; $otherMatchBetter = false;
foreach ($oldMatchData[$oldListIndex] as $index => $percentage) { foreach ($oldMatchData[$oldListIndex] as $index => $percentage) {
if ($index > $newIndex && $percentage > $matchPercentage) { if ($index > $newIndex && $percentage > $matchPercentage) {
$otherMatchBetter = $index; $otherMatchBetter = $index;
} }
} }
if (false !== $otherMatchBetter && $newCount > $oldCount && $difference > 0) { if (false !== $otherMatchBetter && $newCount > $oldCount && $difference > 0) {
$diffOutput .= sprintf('%s', $newListItem->getHtml('normal new', 'ins')); $diffOutput .= sprintf('%s', $newListItem->getHtml('normal new', 'ins'));
$currentIndexInNew++; $currentIndexInNew++;
$difference--; $difference--;
continue; continue;
} }
$nextOldListIndex = array_key_exists($currentIndexInOld + 1, $oldListIndices) ? $oldListIndices[$currentIndexInOld + 1] : null; $nextOldListIndex = array_key_exists($currentIndexInOld + 1, $oldListIndices) ? $oldListIndices[$currentIndexInOld + 1] : null;
$replacement = false; $replacement = false;
if ($nextOldListIndex !== null && $oldMatchData[$nextOldListIndex][$newIndex] > $matchPercentage && $oldMatchData[$nextOldListIndex][$newIndex] > $this->config->getMatchThreshold()) { if ($nextOldListIndex !== null && $oldMatchData[$nextOldListIndex][$newIndex] > $matchPercentage && $oldMatchData[$nextOldListIndex][$newIndex] > $this->config->getMatchThreshold()) {
// Following list item in old is better match, use that. // Following list item in old is better match, use that.
$diffOutput .= sprintf('%s', $oldListItems[$oldListIndex]->getHtml('removed', 'del')); $diffOutput .= sprintf('%s', $oldListItems[$oldListIndex]->getHtml('removed', 'del'));
$currentIndexInOld++; $currentIndexInOld++;
$oldListIndex = $nextOldListIndex; $oldListIndex = $nextOldListIndex;
$matchPercentage = $oldMatchData[$oldListIndex]; $matchPercentage = $oldMatchData[$oldListIndex];
$replacement = true; $replacement = true;
} }
if ($matchPercentage > $this->config->getMatchThreshold() || $currentIndexInNew === $currentIndexInOld) { if ($matchPercentage > $this->config->getMatchThreshold() || $currentIndexInNew === $currentIndexInOld) {
// Diff the two lists. // Diff the two lists.
$htmlDiff = HtmlDiff::create( $htmlDiff = HtmlDiff::create(
$oldListItems[$oldListIndex]->getInnerHtml(), $oldListItems[$oldListIndex]->getInnerHtml(),
$newListItem->getInnerHtml(), $newListItem->getInnerHtml(),
$this->config $this->config
); );
$diffContent = $htmlDiff->build(); $diffContent = $htmlDiff->build();
$diffOutput .= sprintf('%s%s%s', $newListItem->getStartTagWithDiffClass($replacement ? 'replacement' : 'normal'), $diffContent, $newListItem->getEndTag()); $diffOutput .= sprintf('%s%s%s', $newListItem->getStartTagWithDiffClass($replacement ? 'replacement' : 'normal'), $diffContent, $newListItem->getEndTag());
} else { } else {
$diffOutput .= sprintf('%s', $oldListItems[$oldListIndex]->getHtml('removed', 'del')); $diffOutput .= sprintf('%s', $oldListItems[$oldListIndex]->getHtml('removed', 'del'));
$diffOutput .= sprintf('%s', $newListItem->getHtml('replacement', 'ins')); $diffOutput .= sprintf('%s', $newListItem->getHtml('replacement', 'ins'));
} }
$currentIndexInOld++; $currentIndexInOld++;
} else { } else {
$diffOutput .= sprintf('%s', $newListItem->getHtml('normal new', 'ins')); $diffOutput .= sprintf('%s', $newListItem->getHtml('normal new', 'ins'));
} }
$currentIndexInNew++; $currentIndexInNew++;
} }
} }
// Output any additional list items // Output any additional list items
while (array_key_exists($currentIndexInOld, $oldListIndices)) { while (array_key_exists($currentIndexInOld, $oldListIndices)) {
$oldListIndex = $oldListIndices[$currentIndexInOld]; $oldListIndex = $oldListIndices[$currentIndexInOld];
$diffOutput .= sprintf('%s', $oldListItems[$oldListIndex]->getHtml('removed', 'del')); $diffOutput .= sprintf('%s', $oldListItems[$oldListIndex]->getHtml('removed', 'del'));
$currentIndexInOld++; $currentIndexInOld++;
} }
return sprintf('%s%s%s', $newList->getStartTagWithDiffClass(), $diffOutput, $newList->getEndTag()); return sprintf('%s%s%s', $newList->getStartTagWithDiffClass(), $diffOutput, $newList->getEndTag());
} }
protected function buildDiffList($words) protected function buildDiffList($words)
{ {
$listType = null; $listType = null;
$listStartTag = null; $listStartTag = null;
$listEndTag = null; $listEndTag = null;
$attributes = array(); $attributes = array();
$openLists = 0; $openLists = 0;
$openListItems = 0; $openListItems = 0;
$list = array(); $list = array();
$currentListItem = null; $currentListItem = null;
$listItemType = null; $listItemType = null;
$listItemStart = null; $listItemStart = null;
$listItemEnd = null; $listItemEnd = null;
foreach ($words as $i => $word) { foreach ($words as $i => $word) {
if ($this->isOpeningListTag($word, $listType)) { if ($this->isOpeningListTag($word, $listType)) {
if ($openLists > 0) { if ($openLists > 0) {
if ($openListItems > 0) { if ($openListItems > 0) {
$currentListItem[] = $word; $currentListItem[] = $word;
} else { } else {
$list[] = $word; $list[] = $word;
} }
} else { } else {
$listType = substr($word, 1, 2); $listType = substr($word, 1, 2);
$listStartTag = $word; $listStartTag = $word;
} }
$openLists++; $openLists++;
} elseif ($this->isClosingListTag($word, $listType)) { } elseif ($this->isClosingListTag($word, $listType)) {
if ($openLists > 1) { if ($openLists > 1) {
if ($openListItems > 0) { if ($openListItems > 0) {
$currentListItem[] = $word; $currentListItem[] = $word;
} else { } else {
$list[] = $word; $list[] = $word;
} }
} else { } else {
$listEndTag = $word; $listEndTag = $word;
} }
$openLists--; $openLists--;
} elseif ($this->isOpeningListItemTag($word, $listItemType)) { } elseif ($this->isOpeningListItemTag($word, $listItemType)) {
if ($openListItems === 0) { if ($openListItems === 0) {
// New top-level list item // New top-level list item
$currentListItem = array(); $currentListItem = array();
$listItemType = substr($word, 1, 2); $listItemType = substr($word, 1, 2);
$listItemStart = $word; $listItemStart = $word;
} else { } else {
$currentListItem[] = $word; $currentListItem[] = $word;
} }
$openListItems++; $openListItems++;
} elseif ($this->isClosingListItemTag($word, $listItemType)) { } elseif ($this->isClosingListItemTag($word, $listItemType)) {
if ($openListItems === 1) { if ($openListItems === 1) {
$listItemEnd = $word; $listItemEnd = $word;
$listItem = new DiffListItem($currentListItem, array(), $listItemStart, $listItemEnd); $listItem = new DiffListItem($currentListItem, array(), $listItemStart, $listItemEnd);
$list[] = $listItem; $list[] = $listItem;
$currentListItem = null; $currentListItem = null;
} else { } else {
$currentListItem[] = $word; $currentListItem[] = $word;
} }
$openListItems--; $openListItems--;
} else { } else {
if ($openListItems > 0) { if ($openListItems > 0) {
$currentListItem[] = $word; $currentListItem[] = $word;
} else { } else {
$list[] = $word; $list[] = $word;
} }
} }
} }
$diffList = new DiffList($listType, $listStartTag, $listEndTag, $list, $attributes); $diffList = new DiffList($listType, $listStartTag, $listEndTag, $list, $attributes);
return $diffList; return $diffList;
} }
protected function isOpeningListTag($word, $type = null) protected function isOpeningListTag($word, $type = null)
{ {
$filter = $type !== null ? array('<' . $type) : array('<ul', '<ol', '<dl'); $filter = $type !== null ? array('<' . $type) : array('<ul', '<ol', '<dl');
return in_array(substr($word, 0, 3), $filter); return in_array(substr($word, 0, 3), $filter);
} }
protected function isClosingListTag($word, $type = null) protected function isClosingListTag($word, $type = null)
{ {
$filter = $type !== null ? array('</' . $type) : array('</ul', '</ol', '</dl'); $filter = $type !== null ? array('</' . $type) : array('</ul', '</ol', '</dl');
return in_array(substr($word, 0, 4), $filter); return in_array(substr($word, 0, 4), $filter);
} }
protected function isOpeningListItemTag($word, $type = null) protected function isOpeningListItemTag($word, $type = null)
{ {
$filter = $type !== null ? array('<' . $type) : array('<li', '<dd', '<dt'); $filter = $type !== null ? array('<' . $type) : array('<li', '<dd', '<dt');
return in_array(substr($word, 0, 3), $filter); return in_array(substr($word, 0, 3), $filter);
} }
protected function isClosingListItemTag($word, $type = null) protected function isClosingListItemTag($word, $type = null)
{ {
$filter = $type !== null ? array('</' . $type) : array('</li', '</dd', '</dt'); $filter = $type !== null ? array('</' . $type) : array('</li', '</dd', '</dt');
return in_array(substr($word, 0, 4), $filter); return in_array(substr($word, 0, 4), $filter);
} }
} }

@ -1,27 +1,27 @@
<?php <?php
namespace Caxy\HtmlDiff; namespace Caxy\HtmlDiff;
class Match class Match
{ {
public $startInOld; public $startInOld;
public $startInNew; public $startInNew;
public $size; public $size;
public function __construct($startInOld, $startInNew, $size) public function __construct($startInOld, $startInNew, $size)
{ {
$this->startInOld = $startInOld; $this->startInOld = $startInOld;
$this->startInNew = $startInNew; $this->startInNew = $startInNew;
$this->size = $size; $this->size = $size;
} }
public function endInOld() public function endInOld()
{ {
return $this->startInOld + $this->size; return $this->startInOld + $this->size;
} }
public function endInNew() public function endInNew()
{ {
return $this->startInNew + $this->size; return $this->startInNew + $this->size;
} }
} }

@ -1,21 +1,21 @@
<?php <?php
namespace Caxy\HtmlDiff; namespace Caxy\HtmlDiff;
class Operation class Operation
{ {
public $action; public $action;
public $startInOld; public $startInOld;
public $endInOld; public $endInOld;
public $startInNew; public $startInNew;
public $endInNew; public $endInNew;
public function __construct($action, $startInOld, $endInOld, $startInNew, $endInNew) public function __construct($action, $startInOld, $endInOld, $startInNew, $endInNew)
{ {
$this->action = $action; $this->action = $action;
$this->startInOld = $startInOld; $this->startInOld = $startInOld;
$this->endInOld = $endInOld; $this->endInOld = $endInOld;
$this->startInNew = $startInNew; $this->startInNew = $startInNew;
$this->endInNew = $endInNew; $this->endInNew = $endInNew;
} }
} }

@ -1,94 +1,94 @@
<?php <?php
namespace Caxy\HtmlDiff\Table; namespace Caxy\HtmlDiff\Table;
/** /**
* Class AbstractTableElement * Class AbstractTableElement
* @package Caxy\HtmlDiff\Table * @package Caxy\HtmlDiff\Table
*/ */
abstract class AbstractTableElement abstract class AbstractTableElement
{ {
/** /**
* @var \DOMElement * @var \DOMElement
*/ */
protected $domNode; protected $domNode;
/** /**
* AbstractTableElement constructor. * AbstractTableElement constructor.
* *
* @param \DOMElement|null $domNode * @param \DOMElement|null $domNode
*/ */
public function __construct(\DOMElement $domNode = null) public function __construct(\DOMElement $domNode = null)
{ {
$this->domNode = $domNode; $this->domNode = $domNode;
} }
/** /**
* @return \DOMElement * @return \DOMElement
*/ */
public function getDomNode() public function getDomNode()
{ {
return $this->domNode; return $this->domNode;
} }
/** /**
* @param \DOMElement $domNode * @param \DOMElement $domNode
* *
* @return $this * @return $this
*/ */
public function setDomNode(\DOMElement $domNode) public function setDomNode(\DOMElement $domNode)
{ {
$this->domNode = $domNode; $this->domNode = $domNode;
return $this; return $this;
} }
/** /**
* @return string * @return string
*/ */
public function getInnerHtml() public function getInnerHtml()
{ {
$innerHtml = ''; $innerHtml = '';
if ($this->domNode) { if ($this->domNode) {
foreach ($this->domNode->childNodes as $child) { foreach ($this->domNode->childNodes as $child) {
$innerHtml .= static::htmlFromNode($child); $innerHtml .= static::htmlFromNode($child);
} }
} }
return $innerHtml; return $innerHtml;
} }
/** /**
* @param string $name * @param string $name
* *
* @return string * @return string
*/ */
public function getAttribute($name) public function getAttribute($name)
{ {
return $this->domNode->getAttribute($name); return $this->domNode->getAttribute($name);
} }
/** /**
* @param \DOMDocument $domDocument * @param \DOMDocument $domDocument
* *
* @return \DOMElement * @return \DOMElement
*/ */
public function cloneNode(\DOMDocument $domDocument) public function cloneNode(\DOMDocument $domDocument)
{ {
return $domDocument->importNode($this->getDomNode()->cloneNode(false), false); return $domDocument->importNode($this->getDomNode()->cloneNode(false), false);
} }
/** /**
* @param \DOMElement $node * @param \DOMElement $node
* *
* @return string * @return string
*/ */
public static function htmlFromNode($node) public static function htmlFromNode($node)
{ {
$domDocument = new \DOMDocument(); $domDocument = new \DOMDocument();
$newNode = $domDocument->importNode($node, true); $newNode = $domDocument->importNode($node, true);
$domDocument->appendChild($newNode); $domDocument->appendChild($newNode);
return trim($domDocument->saveHTML()); return trim($domDocument->saveHTML());
} }
} }

@ -1,268 +1,268 @@
<?php <?php
namespace Caxy\HtmlDiff\Table; namespace Caxy\HtmlDiff\Table;
/** /**
* Class DiffRowPosition * Class DiffRowPosition
* @package Caxy\HtmlDiff\Table * @package Caxy\HtmlDiff\Table
*/ */
class DiffRowPosition class DiffRowPosition
{ {
/** /**
* @var int * @var int
*/ */
protected $indexInOld; protected $indexInOld;
/** /**
* @var int * @var int
*/ */
protected $indexInNew; protected $indexInNew;
/** /**
* @var int * @var int
*/ */
protected $columnInOld; protected $columnInOld;
/** /**
* @var int * @var int
*/ */
protected $columnInNew; protected $columnInNew;
/** /**
* DiffRowPosition constructor. * DiffRowPosition constructor.
* *
* @param int $indexInOld * @param int $indexInOld
* @param int $indexInNew * @param int $indexInNew
* @param int $columnInOld * @param int $columnInOld
* @param int $columnInNew * @param int $columnInNew
*/ */
public function __construct($indexInOld = 0, $indexInNew = 0, $columnInOld = 0, $columnInNew = 0) public function __construct($indexInOld = 0, $indexInNew = 0, $columnInOld = 0, $columnInNew = 0)
{ {
$this->indexInOld = $indexInOld; $this->indexInOld = $indexInOld;
$this->indexInNew = $indexInNew; $this->indexInNew = $indexInNew;
$this->columnInOld = $columnInOld; $this->columnInOld = $columnInOld;
$this->columnInNew = $columnInNew; $this->columnInNew = $columnInNew;
} }
/** /**
* @return int * @return int
*/ */
public function getIndexInOld() public function getIndexInOld()
{ {
return $this->indexInOld; return $this->indexInOld;
} }
/** /**
* @param int $indexInOld * @param int $indexInOld
* *
* @return DiffRowPosition * @return DiffRowPosition
*/ */
public function setIndexInOld($indexInOld) public function setIndexInOld($indexInOld)
{ {
$this->indexInOld = $indexInOld; $this->indexInOld = $indexInOld;
return $this; return $this;
} }
/** /**
* @return int * @return int
*/ */
public function getIndexInNew() public function getIndexInNew()
{ {
return $this->indexInNew; return $this->indexInNew;
} }
/** /**
* @param int $indexInNew * @param int $indexInNew
* *
* @return DiffRowPosition * @return DiffRowPosition
*/ */
public function setIndexInNew($indexInNew) public function setIndexInNew($indexInNew)
{ {
$this->indexInNew = $indexInNew; $this->indexInNew = $indexInNew;
return $this; return $this;
} }
/** /**
* @return int * @return int
*/ */
public function getColumnInOld() public function getColumnInOld()
{ {
return $this->columnInOld; return $this->columnInOld;
} }
/** /**
* @param int $columnInOld * @param int $columnInOld
* *
* @return DiffRowPosition * @return DiffRowPosition
*/ */
public function setColumnInOld($columnInOld) public function setColumnInOld($columnInOld)
{ {
$this->columnInOld = $columnInOld; $this->columnInOld = $columnInOld;
return $this; return $this;
} }
/** /**
* @return int * @return int
*/ */
public function getColumnInNew() public function getColumnInNew()
{ {
return $this->columnInNew; return $this->columnInNew;
} }
/** /**
* @param int $columnInNew * @param int $columnInNew
* *
* @return DiffRowPosition * @return DiffRowPosition
*/ */
public function setColumnInNew($columnInNew) public function setColumnInNew($columnInNew)
{ {
$this->columnInNew = $columnInNew; $this->columnInNew = $columnInNew;
return $this; return $this;
} }
/** /**
* @param int $increment * @param int $increment
* *
* @return int * @return int
*/ */
public function incrementColumnInNew($increment = 1) public function incrementColumnInNew($increment = 1)
{ {
$this->columnInNew += $increment; $this->columnInNew += $increment;
return $this->columnInNew; return $this->columnInNew;
} }
/** /**
* @param int $increment * @param int $increment
* *
* @return int * @return int
*/ */
public function incrementColumnInOld($increment = 1) public function incrementColumnInOld($increment = 1)
{ {
$this->columnInOld += $increment; $this->columnInOld += $increment;
return $this->columnInOld; return $this->columnInOld;
} }
/** /**
* @param int $increment * @param int $increment
* *
* @return int * @return int
*/ */
public function incrementIndexInNew($increment = 1) public function incrementIndexInNew($increment = 1)
{ {
$this->indexInNew += $increment; $this->indexInNew += $increment;
return $this->indexInNew; return $this->indexInNew;
} }
/** /**
* @param int $increment * @param int $increment
* *
* @return int * @return int
*/ */
public function incrementIndexInOld($increment = 1) public function incrementIndexInOld($increment = 1)
{ {
$this->indexInOld += $increment; $this->indexInOld += $increment;
return $this->indexInOld; return $this->indexInOld;
} }
/** /**
* @param string $type * @param string $type
* @param int $increment * @param int $increment
* *
* @return int * @return int
*/ */
public function incrementIndex($type, $increment = 1) public function incrementIndex($type, $increment = 1)
{ {
if ($type === 'new') { if ($type === 'new') {
return $this->incrementIndexInNew($increment); return $this->incrementIndexInNew($increment);
} }
return $this->incrementIndexInOld($increment); return $this->incrementIndexInOld($increment);
} }
/** /**
* @param string $type * @param string $type
* @param int $increment * @param int $increment
* *
* @return int * @return int
*/ */
public function incrementColumn($type, $increment = 1) public function incrementColumn($type, $increment = 1)
{ {
if ($type === 'new') { if ($type === 'new') {
return $this->incrementColumnInNew($increment); return $this->incrementColumnInNew($increment);
} }
return $this->incrementColumnInOld($increment); return $this->incrementColumnInOld($increment);
} }
/** /**
* @param string $type * @param string $type
* *
* @return bool * @return bool
*/ */
public function isColumnLessThanOther($type) public function isColumnLessThanOther($type)
{ {
if ($type === 'new') { if ($type === 'new') {
return $this->getColumnInNew() < $this->getColumnInOld(); return $this->getColumnInNew() < $this->getColumnInOld();
} }
return $this->getColumnInOld() < $this->getColumnInNew(); return $this->getColumnInOld() < $this->getColumnInNew();
} }
/** /**
* @param string $type * @param string $type
* *
* @return int * @return int
*/ */
public function getColumn($type) public function getColumn($type)
{ {
if ($type === 'new') { if ($type === 'new') {
return $this->getColumnInNew(); return $this->getColumnInNew();
} }
return $this->getColumnInOld(); return $this->getColumnInOld();
} }
/** /**
* @param string $type * @param string $type
* *
* @return int * @return int
*/ */
public function getIndex($type) public function getIndex($type)
{ {
if ($type === 'new') { if ($type === 'new') {
return $this->getIndexInNew(); return $this->getIndexInNew();
} }
return $this->getIndexInOld(); return $this->getIndexInOld();
} }
/** /**
* @return bool * @return bool
*/ */
public function areColumnsEqual() public function areColumnsEqual()
{ {
return $this->getColumnInOld() === $this->getColumnInNew(); return $this->getColumnInOld() === $this->getColumnInNew();
} }
/** /**
* @return null|string * @return null|string
*/ */
public function getLesserColumnType() public function getLesserColumnType()
{ {
if ($this->isColumnLessThanOther('new')) { if ($this->isColumnLessThanOther('new')) {
return 'new'; return 'new';
} elseif ($this->isColumnLessThanOther('old')) { } elseif ($this->isColumnLessThanOther('old')) {
return 'old'; return 'old';
} }
return null; return null;
} }
} }

@ -1,133 +1,133 @@
<?php <?php
namespace Caxy\HtmlDiff\Table; namespace Caxy\HtmlDiff\Table;
/** /**
* Class RowMatch * Class RowMatch
* @package Caxy\HtmlDiff\Table * @package Caxy\HtmlDiff\Table
*/ */
class RowMatch class RowMatch
{ {
/** /**
* @var int * @var int
*/ */
protected $startInNew; protected $startInNew;
/** /**
* @var int * @var int
*/ */
protected $startInOld; protected $startInOld;
/** /**
* @var int * @var int
*/ */
protected $endInNew; protected $endInNew;
/** /**
* @var int * @var int
*/ */
protected $endInOld; protected $endInOld;
/** /**
* @var float|null * @var float|null
*/ */
protected $percentage; protected $percentage;
/** /**
* RowMatch constructor. * RowMatch constructor.
* *
* @param int $startInNew * @param int $startInNew
* @param int $startInOld * @param int $startInOld
* @param int $endInNew * @param int $endInNew
* @param int $endInOld * @param int $endInOld
* @param float|null $percentage * @param float|null $percentage
*/ */
public function __construct($startInNew = 0, $startInOld = 0, $endInNew = 0, $endInOld = 0, $percentage = null) public function __construct($startInNew = 0, $startInOld = 0, $endInNew = 0, $endInOld = 0, $percentage = null)
{ {
$this->startInNew = $startInNew; $this->startInNew = $startInNew;
$this->startInOld = $startInOld; $this->startInOld = $startInOld;
$this->endInNew = $endInNew; $this->endInNew = $endInNew;
$this->endInOld = $endInOld; $this->endInOld = $endInOld;
$this->percentage = $percentage; $this->percentage = $percentage;
} }
/** /**
* @return int * @return int
*/ */
public function getStartInNew() public function getStartInNew()
{ {
return $this->startInNew; return $this->startInNew;
} }
/** /**
* @param int $startInNew * @param int $startInNew
* *
* @return RowMatch * @return RowMatch
*/ */
public function setStartInNew($startInNew) public function setStartInNew($startInNew)
{ {
$this->startInNew = $startInNew; $this->startInNew = $startInNew;
return $this; return $this;
} }
/** /**
* @return int * @return int
*/ */
public function getStartInOld() public function getStartInOld()
{ {
return $this->startInOld; return $this->startInOld;
} }
/** /**
* @param int $startInOld * @param int $startInOld
* *
* @return RowMatch * @return RowMatch
*/ */
public function setStartInOld($startInOld) public function setStartInOld($startInOld)
{ {
$this->startInOld = $startInOld; $this->startInOld = $startInOld;
return $this; return $this;
} }
/** /**
* @return int * @return int
*/ */
public function getEndInNew() public function getEndInNew()
{ {
return $this->endInNew; return $this->endInNew;
} }
/** /**
* @param int $endInNew * @param int $endInNew
* *
* @return RowMatch * @return RowMatch
*/ */
public function setEndInNew($endInNew) public function setEndInNew($endInNew)
{ {
$this->endInNew = $endInNew; $this->endInNew = $endInNew;
return $this; return $this;
} }
/** /**
* @return int * @return int
*/ */
public function getEndInOld() public function getEndInOld()
{ {
return $this->endInOld; return $this->endInOld;
} }
/** /**
* @param int $endInOld * @param int $endInOld
* *
* @return RowMatch * @return RowMatch
*/ */
public function setEndInOld($endInOld) public function setEndInOld($endInOld)
{ {
$this->endInOld = $endInOld; $this->endInOld = $endInOld;
return $this; return $this;
} }
} }

@ -1,161 +1,161 @@
<?php <?php
namespace Caxy\HtmlDiff\Table; namespace Caxy\HtmlDiff\Table;
/** /**
* Class Table * Class Table
* @package Caxy\HtmlDiff\Table * @package Caxy\HtmlDiff\Table
*/ */
class Table extends AbstractTableElement class Table extends AbstractTableElement
{ {
/** /**
* @var TableRow[] * @var TableRow[]
*/ */
protected $rows = array(); protected $rows = array();
/** /**
* @return TableRow[] * @return TableRow[]
*/ */
public function getRows() public function getRows()
{ {
return $this->rows; return $this->rows;
} }
/** /**
* @param TableRow $row * @param TableRow $row
*/ */
public function addRow(TableRow $row) public function addRow(TableRow $row)
{ {
$this->rows[] = $row; $this->rows[] = $row;
if (!$row->getTable()) { if (!$row->getTable()) {
$row->setTable($this); $row->setTable($this);
} }
} }
/** /**
* @param TableRow $row * @param TableRow $row
*/ */
public function removeRow(TableRow $row) public function removeRow(TableRow $row)
{ {
$key = array_search($row, $this->rows, true); $key = array_search($row, $this->rows, true);
if ($key !== false) { if ($key !== false) {
unset($this->rows[$key]); unset($this->rows[$key]);
if ($row->getTable()) { if ($row->getTable()) {
$row->setTable(null); $row->setTable(null);
} }
} }
} }
/** /**
* @param int $index * @param int $index
* *
* @return null|TableRow * @return null|TableRow
*/ */
public function getRow($index) public function getRow($index)
{ {
return isset($this->rows[$index]) ? $this->rows[$index] : null; return isset($this->rows[$index]) ? $this->rows[$index] : null;
} }
/** /**
* @param TableRow[] $rows * @param TableRow[] $rows
* @param null|int $position * @param null|int $position
*/ */
public function insertRows($rows, $position = null) public function insertRows($rows, $position = null)
{ {
if ($position === null) { if ($position === null) {
$this->rows = array_merge($this->rows, $rows); $this->rows = array_merge($this->rows, $rows);
} else { } else {
array_splice($this->rows, $position, 0, $rows); array_splice($this->rows, $position, 0, $rows);
} }
} }
/** /**
* @param TablePosition $position * @param TablePosition $position
* *
* @return null|TableCell * @return null|TableCell
*/ */
public function getCellByPosition(TablePosition $position) public function getCellByPosition(TablePosition $position)
{ {
$row = $this->getRow($position->getRow()); $row = $this->getRow($position->getRow());
return $row ? $row->getCell($position->getCell()) : null; return $row ? $row->getCell($position->getCell()) : null;
} }
/** /**
* @param TablePosition $position * @param TablePosition $position
* @param int $offset * @param int $offset
* *
* @return TablePosition|null * @return TablePosition|null
*/ */
public function getPositionBefore(TablePosition $position, $offset = 1) public function getPositionBefore(TablePosition $position, $offset = 1)
{ {
if ($position->getCell() > ($offset - 1)) { if ($position->getCell() > ($offset - 1)) {
$newRow = $position->getRow(); $newRow = $position->getRow();
$newCell = $position->getCell() - $offset; $newCell = $position->getCell() - $offset;
} elseif ($position->getRow() > 0) { } elseif ($position->getRow() > 0) {
$cellsToMove = $offset; $cellsToMove = $offset;
$newRow = $position->getRow(); $newRow = $position->getRow();
$newCell = $position->getCell(); $newCell = $position->getCell();
while ($cellsToMove > 0 && $newRow >= 0) { while ($cellsToMove > 0 && $newRow >= 0) {
if ($cellsToMove > $newCell) { if ($cellsToMove > $newCell) {
$newRow--; $newRow--;
if ($newRow < 0) { if ($newRow < 0) {
return null; return null;
} }
$cellsToMove = $cellsToMove - ($newCell + 1); $cellsToMove = $cellsToMove - ($newCell + 1);
$cellCount = count($this->getRow($newRow)->getCells()); $cellCount = count($this->getRow($newRow)->getCells());
$newCell = $cellCount - 1; $newCell = $cellCount - 1;
} else { } else {
$newCell = $newCell - $cellsToMove; $newCell = $newCell - $cellsToMove;
$cellsToMove -= $newCell; $cellsToMove -= $newCell;
} }
} }
} else { } else {
return null; return null;
} }
if ($newRow >= 0 && $newCell >= 0) { if ($newRow >= 0 && $newCell >= 0) {
return new TablePosition($newRow, $newCell); return new TablePosition($newRow, $newCell);
} }
return null; return null;
} }
/** /**
* @param TablePosition $position * @param TablePosition $position
* @param int $offset * @param int $offset
* *
* @return TablePosition|null * @return TablePosition|null
*/ */
public function getPositionAfter(TablePosition $position, $offset = 1) public function getPositionAfter(TablePosition $position, $offset = 1)
{ {
$cellsToMove = $offset; $cellsToMove = $offset;
$newRow = $position->getRow(); $newRow = $position->getRow();
$newCell = $position->getCell(); $newCell = $position->getCell();
while ($cellsToMove > 0 && $newRow < count($this->rows)) { while ($cellsToMove > 0 && $newRow < count($this->rows)) {
$cellCount = count($this->getRow($newRow)->getCells()); $cellCount = count($this->getRow($newRow)->getCells());
$cellsLeft = $cellCount - $newCell - 1; $cellsLeft = $cellCount - $newCell - 1;
if ($cellsToMove > $cellsLeft) { if ($cellsToMove > $cellsLeft) {
$newRow++; $newRow++;
$cellsToMove -= $cellsLeft - 1; $cellsToMove -= $cellsLeft - 1;
$newCell = 0; $newCell = 0;
} else { } else {
$newCell = $newCell + $cellsToMove; $newCell = $newCell + $cellsToMove;
$cellsToMove -= $cellsLeft; $cellsToMove -= $cellsLeft;
} }
} }
if ($newRow >= 0 && $newCell >= 0) { if ($newRow >= 0 && $newCell >= 0) {
return new TablePosition($newRow, $newCell); return new TablePosition($newRow, $newCell);
} }
return null; return null;
} }
} }

@ -1,55 +1,55 @@
<?php <?php
namespace Caxy\HtmlDiff\Table; namespace Caxy\HtmlDiff\Table;
/** /**
* Class TableCell * Class TableCell
* @package Caxy\HtmlDiff\Table * @package Caxy\HtmlDiff\Table
*/ */
class TableCell extends AbstractTableElement class TableCell extends AbstractTableElement
{ {
/** /**
* @var TableRow * @var TableRow
*/ */
protected $row; protected $row;
/** /**
* @return TableRow * @return TableRow
*/ */
public function getRow() public function getRow()
{ {
return $this->row; return $this->row;
} }
/** /**
* @param TableRow|null $row * @param TableRow|null $row
* *
* @return $this * @return $this
*/ */
public function setRow(TableRow $row = null) public function setRow(TableRow $row = null)
{ {
$this->row = $row; $this->row = $row;
if (null !== $row && !in_array($this, $row->getCells())) { if (null !== $row && !in_array($this, $row->getCells())) {
$row->addCell($this); $row->addCell($this);
} }
return $this; return $this;
} }
/** /**
* @return int * @return int
*/ */
public function getColspan() public function getColspan()
{ {
return (int)$this->getAttribute('colspan') ?: 1; return (int)$this->getAttribute('colspan') ?: 1;
} }
/** /**
* @return int * @return int
*/ */
public function getRowspan() public function getRowspan()
{ {
return (int)$this->getAttribute('rowspan') ?: 1; return (int)$this->getAttribute('rowspan') ?: 1;
} }
} }

File diff suppressed because it is too large Load Diff

@ -1,75 +1,75 @@
<?php <?php
namespace Caxy\HtmlDiff\Table; namespace Caxy\HtmlDiff\Table;
/** /**
* Class TableMatch * Class TableMatch
* @package Caxy\HtmlDiff\Table * @package Caxy\HtmlDiff\Table
*/ */
class TableMatch class TableMatch
{ {
/** /**
* @var int * @var int
*/ */
public $startInOld; public $startInOld;
/** /**
* @var int * @var int
*/ */
public $startInNew; public $startInNew;
/** /**
* @var int * @var int
*/ */
public $endInOld; public $endInOld;
/** /**
* @var int * @var int
*/ */
public $endInNew; public $endInNew;
/** /**
* TableMatch constructor. * TableMatch constructor.
* *
* @param int $startInOld * @param int $startInOld
* @param int $startInNew * @param int $startInNew
* @param int $endInOld * @param int $endInOld
* @param int $endInNew * @param int $endInNew
*/ */
public function __construct($startInOld, $startInNew, $endInOld, $endInNew) public function __construct($startInOld, $startInNew, $endInOld, $endInNew)
{ {
$this->startInOld = $startInOld; $this->startInOld = $startInOld;
$this->startInNew = $startInNew; $this->startInNew = $startInNew;
$this->endInOld = $endInOld; $this->endInOld = $endInOld;
$this->endInNew = $endInNew; $this->endInNew = $endInNew;
} }
/** /**
* @return int * @return int
*/ */
public function getStartInOld() public function getStartInOld()
{ {
return $this->startInOld; return $this->startInOld;
} }
/** /**
* @return int * @return int
*/ */
public function getStartInNew() public function getStartInNew()
{ {
return $this->startInNew; return $this->startInNew;
} }
/** /**
* @return int * @return int
*/ */
public function getEndInOld() public function getEndInOld()
{ {
return $this->endInOld; return $this->endInOld;
} }
/** /**
* @return int * @return int
*/ */
public function getEndInNew() public function getEndInNew()
{ {
return $this->endInNew; return $this->endInNew;
} }
} }

@ -1,70 +1,70 @@
<?php <?php
namespace Caxy\HtmlDiff\Table; namespace Caxy\HtmlDiff\Table;
/** /**
* Class TablePosition * Class TablePosition
* @package Caxy\HtmlDiff\Table * @package Caxy\HtmlDiff\Table
*/ */
class TablePosition class TablePosition
{ {
/** /**
* @var int * @var int
*/ */
public $row; public $row;
/** /**
* @var int * @var int
*/ */
public $cell; public $cell;
/** /**
* TablePosition constructor. * TablePosition constructor.
* *
* @param int $row * @param int $row
* @param int $cell * @param int $cell
*/ */
public function __construct($row, $cell) public function __construct($row, $cell)
{ {
$this->row = $row; $this->row = $row;
$this->cell = $cell; $this->cell = $cell;
} }
/** /**
* @return int * @return int
*/ */
public function getRow() public function getRow()
{ {
return $this->row; return $this->row;
} }
/** /**
* @return int * @return int
*/ */
public function getCell() public function getCell()
{ {
return $this->cell; return $this->cell;
} }
/** /**
* @return string * @return string
*/ */
public function __toString() public function __toString()
{ {
return $this->row.':'.$this->cell; return $this->row.':'.$this->cell;
} }
/** /**
* @param TablePosition $a * @param TablePosition $a
* @param TablePosition $b * @param TablePosition $b
* *
* @return int * @return int
*/ */
public static function compare($a, $b) public static function compare($a, $b)
{ {
if ($a->getRow() == $b->getRow()) { if ($a->getRow() == $b->getRow()) {
return $a->getCell() - $b->getCell(); return $a->getCell() - $b->getCell();
} }
return $a->getRow() - $b->getRow(); return $a->getRow() - $b->getRow();
} }
} }

@ -1,106 +1,106 @@
<?php <?php
namespace Caxy\HtmlDiff\Table; namespace Caxy\HtmlDiff\Table;
/** /**
* Class TableRow * Class TableRow
* @package Caxy\HtmlDiff\Table * @package Caxy\HtmlDiff\Table
*/ */
class TableRow extends AbstractTableElement class TableRow extends AbstractTableElement
{ {
/** /**
* @var Table * @var Table
*/ */
protected $table; protected $table;
/** /**
* @var TableCell[] * @var TableCell[]
*/ */
protected $cells = array(); protected $cells = array();
/** /**
* @return Table * @return Table
*/ */
public function getTable() public function getTable()
{ {
return $this->table; return $this->table;
} }
/** /**
* @param Table|null $table * @param Table|null $table
* *
* @return $this * @return $this
*/ */
public function setTable(Table $table = null) public function setTable(Table $table = null)
{ {
$this->table = $table; $this->table = $table;
if ($table && !in_array($this, $table->getRows())) { if ($table && !in_array($this, $table->getRows())) {
$table->addRow($this); $table->addRow($this);
} }
return $this; return $this;
} }
/** /**
* @return TableCell[] * @return TableCell[]
*/ */
public function getCells() public function getCells()
{ {
return $this->cells; return $this->cells;
} }
/** /**
* @param TableCell $cell * @param TableCell $cell
* *
* @return $this * @return $this
*/ */
public function addCell(TableCell $cell) public function addCell(TableCell $cell)
{ {
$this->cells[] = $cell; $this->cells[] = $cell;
if (!$cell->getRow()) { if (!$cell->getRow()) {
$cell->setRow($this); $cell->setRow($this);
} }
return $this; return $this;
} }
/** /**
* @param TableCell $cell * @param TableCell $cell
*/ */
public function removeCell(TableCell $cell) public function removeCell(TableCell $cell)
{ {
$key = array_search($cell, $this->cells, true); $key = array_search($cell, $this->cells, true);
if ($key !== false) { if ($key !== false) {
unset($this->cells[$key]); unset($this->cells[$key]);
if ($cell->getRow()) { if ($cell->getRow()) {
$cell->setRow(null); $cell->setRow(null);
} }
} }
} }
/** /**
* @param int $index * @param int $index
* *
* @return TableCell|null * @return TableCell|null
*/ */
public function getCell($index) public function getCell($index)
{ {
return isset($this->cells[$index]) ? $this->cells[$index] : null; return isset($this->cells[$index]) ? $this->cells[$index] : null;
} }
/** /**
* @param TableCell[] $cells * @param TableCell[] $cells
* @param null|int $position * @param null|int $position
*/ */
public function insertCells($cells, $position = null) public function insertCells($cells, $position = null)
{ {
if ($position === null) { if ($position === null) {
$this->cells = array_merge($this->cells, $cells); $this->cells = array_merge($this->cells, $cells);
} else { } else {
array_splice($this->cells, $position, 0, $cells); array_splice($this->cells, $position, 0, $cells);
} }
} }
} }

@ -1,26 +1,26 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<phpunit backupGlobals="false" <phpunit backupGlobals="false"
backupStaticAttributes="false" backupStaticAttributes="false"
colors="true" colors="true"
convertErrorsToExceptions="true" convertErrorsToExceptions="true"
convertNoticesToExceptions="true" convertNoticesToExceptions="true"
convertWarningsToExceptions="true" convertWarningsToExceptions="true"
processIsolation="false" processIsolation="false"
stopOnFailure="false" stopOnFailure="false"
syntaxCheck="false" syntaxCheck="false"
bootstrap="./tests/Caxy/Tests/TestInit.php" bootstrap="./tests/Caxy/Tests/TestInit.php"
> >
<testsuites> <testsuites>
<testsuite name="php-htmldiff Test Suite"> <testsuite name="php-htmldiff Test Suite">
<directory>./tests/Caxy/Tests/HtmlDiff</directory> <directory>./tests/Caxy/Tests/HtmlDiff</directory>
</testsuite> </testsuite>
</testsuites> </testsuites>
<filter> <filter>
<whitelist processUncoveredFilesFromWhitelist="true"> <whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./lib</directory> <directory suffix=".php">./lib</directory>
</whitelist> </whitelist>
</filter> </filter>
</phpunit> </phpunit>

@ -1,40 +1,40 @@
<?php <?php
namespace Caxy\Tests\HtmlDiff\Functional; namespace Caxy\Tests\HtmlDiff\Functional;
use Caxy\HtmlDiff\HtmlDiff; use Caxy\HtmlDiff\HtmlDiff;
use Caxy\Tests\HtmlDiff\HtmlFileIterator; use Caxy\Tests\HtmlDiff\HtmlFileIterator;
class HtmlDiffFunctionalTest extends \PHPUnit_Framework_TestCase class HtmlDiffFunctionalTest extends \PHPUnit_Framework_TestCase
{ {
/** /**
* @dataProvider diffContentProvider * @dataProvider diffContentProvider
* *
* @param $oldText * @param $oldText
* @param $newText * @param $newText
* @param $expected * @param $expected
*/ */
public function testHtmlDiff($oldText, $newText, $expected) public function testHtmlDiff($oldText, $newText, $expected)
{ {
$diff = new HtmlDiff(trim($oldText), trim($newText), 'UTF-8', array()); $diff = new HtmlDiff(trim($oldText), trim($newText), 'UTF-8', array());
$output = $diff->build(); $output = $diff->build();
static::assertEquals($this->stripExtraWhitespaceAndNewLines($expected), $this->stripExtraWhitespaceAndNewLines($output)); static::assertEquals($this->stripExtraWhitespaceAndNewLines($expected), $this->stripExtraWhitespaceAndNewLines($output));
} }
public function diffContentProvider() public function diffContentProvider()
{ {
return new HtmlFileIterator(__DIR__.'/../../../../fixtures/HtmlDiff'); return new HtmlFileIterator(__DIR__.'/../../../../fixtures/HtmlDiff');
} }
protected function stripExtraWhitespaceAndNewLines($text) protected function stripExtraWhitespaceAndNewLines($text)
{ {
return trim( return trim(
preg_replace( preg_replace(
'/>\s+</', '/>\s+</',
'><', '><',
preg_replace('/\s+/S', " ", preg_replace("/[\n\r]/", '', $text)) preg_replace('/\s+/S', " ", preg_replace("/[\n\r]/", '', $text))
) )
); );
} }
} }

@ -1,103 +1,103 @@
<?php <?php
namespace Caxy\Tests\HtmlDiff; namespace Caxy\Tests\HtmlDiff;
class HtmlFileIterator implements \Iterator class HtmlFileIterator implements \Iterator
{ {
protected $files = array(); protected $files = array();
protected $key = 0; protected $key = 0;
protected $loadedDiffs = array(); protected $loadedDiffs = array();
public function __construct($directory) public function __construct($directory)
{ {
$this->files = glob($directory.DIRECTORY_SEPARATOR."*.html"); $this->files = glob($directory.DIRECTORY_SEPARATOR."*.html");
} }
/** /**
* Return the current element * Return the current element
* @link http://php.net/manual/en/iterator.current.php * @link http://php.net/manual/en/iterator.current.php
* @return mixed Can return any type. * @return mixed Can return any type.
* @since 5.0.0 * @since 5.0.0
*/ */
public function current() public function current()
{ {
return $this->loadHtmlFile($this->key); return $this->loadHtmlFile($this->key);
} }
/** /**
* Move forward to next element * Move forward to next element
* @link http://php.net/manual/en/iterator.next.php * @link http://php.net/manual/en/iterator.next.php
* @return void Any returned value is ignored. * @return void Any returned value is ignored.
* @since 5.0.0 * @since 5.0.0
*/ */
public function next() public function next()
{ {
$this->key++; $this->key++;
} }
/** /**
* Return the key of the current element * Return the key of the current element
* @link http://php.net/manual/en/iterator.key.php * @link http://php.net/manual/en/iterator.key.php
* @return mixed scalar on success, or null on failure. * @return mixed scalar on success, or null on failure.
* @since 5.0.0 * @since 5.0.0
*/ */
public function key() public function key()
{ {
return basename($this->files[$this->key]); return basename($this->files[$this->key]);
} }
/** /**
* Checks if current position is valid * Checks if current position is valid
* @link http://php.net/manual/en/iterator.valid.php * @link http://php.net/manual/en/iterator.valid.php
* @return boolean The return value will be casted to boolean and then evaluated. * @return boolean The return value will be casted to boolean and then evaluated.
* Returns true on success or false on failure. * Returns true on success or false on failure.
* @since 5.0.0 * @since 5.0.0
*/ */
public function valid() public function valid()
{ {
return isset($this->files[$this->key]); return isset($this->files[$this->key]);
} }
/** /**
* Rewind the Iterator to the first element * Rewind the Iterator to the first element
* @link http://php.net/manual/en/iterator.rewind.php * @link http://php.net/manual/en/iterator.rewind.php
* @return void Any returned value is ignored. * @return void Any returned value is ignored.
* @since 5.0.0 * @since 5.0.0
*/ */
public function rewind() public function rewind()
{ {
$this->key = 0; $this->key = 0;
} }
protected function loadHtmlFile($key) protected function loadHtmlFile($key)
{ {
$filename = $this->files[$key]; $filename = $this->files[$key];
if (!isset($this->loadedDiffs[$filename])) { if (!isset($this->loadedDiffs[$filename])) {
$html = file_get_contents($filename); $html = file_get_contents($filename);
$oldText = $this->parseTagContent('oldText', $html); $oldText = $this->parseTagContent('oldText', $html);
$newText = $this->parseTagContent('newText', $html); $newText = $this->parseTagContent('newText', $html);
$expected = $this->parseTagContent('expected', $html); $expected = $this->parseTagContent('expected', $html);
if (null === $expected) { if (null === $expected) {
throw new \Exception('HTML fixture content should have an <expected> tag.'); throw new \Exception('HTML fixture content should have an <expected> tag.');
} }
$this->loadedDiffs[$filename] = array($oldText, $newText, $expected); $this->loadedDiffs[$filename] = array($oldText, $newText, $expected);
} }
return $this->loadedDiffs[$filename]; return $this->loadedDiffs[$filename];
} }
protected function parseTagContent($tagName, $html) protected function parseTagContent($tagName, $html)
{ {
$matches = array(); $matches = array();
if (preg_match(sprintf('/<%s\s*[^>]*>(.*)<\/%s\s*>/is', $tagName, $tagName), $html, $matches)) { if (preg_match(sprintf('/<%s\s*[^>]*>(.*)<\/%s\s*>/is', $tagName, $tagName), $html, $matches)) {
return $matches[1]; return $matches[1];
} }
return null; return null;
} }
} }

@ -1,14 +1,14 @@
<?php <?php
/* /*
* This file bootstraps the test environment. * This file bootstraps the test environment.
*/ */
namespace Caxy\Tests; namespace Caxy\Tests;
error_reporting(E_ALL | E_STRICT); error_reporting(E_ALL | E_STRICT);
date_default_timezone_set('UTC'); date_default_timezone_set('UTC');
if (!file_exists(__DIR__ . '/../../../vendor/autoload.php')) { if (!file_exists(__DIR__ . '/../../../vendor/autoload.php')) {
throw new \Exception('Can\'t find autoload.php. Did you install dependencies via composer?'); throw new \Exception('Can\'t find autoload.php. Did you install dependencies via composer?');
} }
require __DIR__ . '/../../../vendor/autoload.php'; require __DIR__ . '/../../../vendor/autoload.php';

@ -1,13 +1,13 @@
<oldText> <oldText>
Compliance with this section requires that the provisions identified in Sections R401 through R404 labeled as "mandatory" and Section R403.5.3 be met. The building thermal envelope shall be greater than or equal to levels of efficiency and Solar Heat Gain Coefficient in Table 402.1.1 or 402.1.3 of the 2009 <em>International Energy Conservation Code</em>.<ul class="exception"><li><strong>Exception:</strong> Supply and return ducts not completely inside the building thermal envelope shall be insulated to a minimum of R-6.</li></ul> Compliance with this section requires that the provisions identified in Sections R401 through R404 labeled as "mandatory" and Section R403.5.3 be met. The building thermal envelope shall be greater than or equal to levels of efficiency and Solar Heat Gain Coefficient in Table 402.1.1 or 402.1.3 of the 2009 <em>International Energy Conservation Code</em>.<ul class="exception"><li><strong>Exception:</strong> Supply and return ducts not completely inside the building thermal envelope shall be insulated to a minimum of R-6.</li></ul>
</oldText> </oldText>
<newText> <newText>
<p>Compliance with this section requires that the provisions identified in Sections R401 through R404 labeled as "mandatory" and Section R403.5.3 shall be met. Fenestration U-factor and SHGC shall not exceed the maximum values for the climate zone set forth in Table R402.1.2. The remaining components of the building thermal envelope shall comply with either the minimum R-values or maximum U-factors for the climate zones specified in Table R402.1.2 and R402.1.4.</p> <p>Compliance with this section requires that the provisions identified in Sections R401 through R404 labeled as "mandatory" and Section R403.5.3 shall be met. Fenestration U-factor and SHGC shall not exceed the maximum values for the climate zone set forth in Table R402.1.2. The remaining components of the building thermal envelope shall comply with either the minimum R-values or maximum U-factors for the climate zones specified in Table R402.1.2 and R402.1.4.</p>
<ul class="exception"><li><strong>Exception:</strong> Supply and return ducts not completely inside the building thermal envelope shall be insulated to a minimum of R-6.</li> <ul class="exception"><li><strong>Exception:</strong> Supply and return ducts not completely inside the building thermal envelope shall be insulated to a minimum of R-6.</li>
</ul> </ul>
</newText> </newText>
<expected> <expected>
<p class="diffmod">Compliance with this section requires that the provisions identified in Sections R401 through R404 labeled as "mandatory" and Section R403.5.3 <ins class="diffins">shall </ins>be met. <ins class="diffins">Fenestration U-factor and SHGC shall not exceed the maximum values for the climate zone set forth in Table R402.1.2. </ins>The<ins class="diffins"> remaining components of the</ins> building thermal envelope shall <del class="diffmod">be greater than</del><ins class="diffmod">comply with either the minimum R-values</ins> or <del class="diffmod">equal to levels of efficiency and Solar Heat Gain Coefficient</del><ins class="diffmod">maximum U-factors for the climate zones specified</ins> in Table <del class="diffmod">402.1.1 or 402.1.3 of the 2009 </del><em class="diffmod"><del class="diffmod">International Energy Conservation Code</del></em><ins class="diffmod">R402.1.2 and R402.1.4</ins>.</p><ins class="diffins"> </ins><ul class="exception" class="diff-list"><li class="normal"><strong>Exception:</strong> Supply and return ducts not completely inside the building thermal envelope shall be insulated to a minimum of R-6.</li></ul> <p class="diffmod">Compliance with this section requires that the provisions identified in Sections R401 through R404 labeled as "mandatory" and Section R403.5.3 <ins class="diffins">shall </ins>be met. <ins class="diffins">Fenestration U-factor and SHGC shall not exceed the maximum values for the climate zone set forth in Table R402.1.2. </ins>The<ins class="diffins"> remaining components of the</ins> building thermal envelope shall <del class="diffmod">be greater than</del><ins class="diffmod">comply with either the minimum R-values</ins> or <del class="diffmod">equal to levels of efficiency and Solar Heat Gain Coefficient</del><ins class="diffmod">maximum U-factors for the climate zones specified</ins> in Table <del class="diffmod">402.1.1 or 402.1.3 of the 2009 </del><em class="diffmod"><del class="diffmod">International Energy Conservation Code</del></em><ins class="diffmod">R402.1.2 and R402.1.4</ins>.</p><ins class="diffins"> </ins><ul class="exception" class="diff-list"><li class="normal"><strong>Exception:</strong> Supply and return ducts not completely inside the building thermal envelope shall be insulated to a minimum of R-6.</li></ul>
</expected> </expected>

@ -1,39 +1,39 @@
<oldText> <oldText>
<ol> <ol>
<li> <li>
Etiam feugiat lorem non metus. Nullam accumsan lorem in dui. Etiam feugiat lorem non metus. Nullam accumsan lorem in dui.
</li> </li>
<li> <li>
Praesent ac sem eget est egestas volutpat. Nulla neque dolor, sagittis eget, iaculis quis, molestie non, velit. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Integer ante arcu, accumsan a, consectetuer eget, posuere ut, mauris. Aenean massa. Praesent ac sem eget est egestas volutpat. Nulla neque dolor, sagittis eget, iaculis quis, molestie non, velit. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Integer ante arcu, accumsan a, consectetuer eget, posuere ut, mauris. Aenean massa.
</li> </li>
<li> <li>
Vestibulum suscipit nulla quis orci. Integer ante arcu, accumsan a, consectetuer eget, posuere ut, mauris. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Vestibulum suscipit nulla quis orci. Integer ante arcu, accumsan a, consectetuer eget, posuere ut, mauris. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos.
</li> </li>
<li> <li>
Suspendisse non nisl sit amet velit hendrerit rutrum. Aenean massa. Curabitur ullamcorper ultricies nisi. Praesent vestibulum dapibus nibh. In dui magna, posuere eget, vestibulum et, tempor auctor, justo. Suspendisse non nisl sit amet velit hendrerit rutrum. Aenean massa. Curabitur ullamcorper ultricies nisi. Praesent vestibulum dapibus nibh. In dui magna, posuere eget, vestibulum et, tempor auctor, justo.
</li> </li>
</ol> </ol>
</oldText> </oldText>
<newText> <newText>
<ol> <ol>
<li> <li>
Suspendisse non nisl sit amet velit hendrerit rutrum. Aenean massa. Curabitur ullamcorper ultricies nisi. Praesent vestibulum dapibus nibh. In dui magna, posuere eget, vestibulum et, tempor auctor, justo. Suspendisse non nisl sit amet velit hendrerit rutrum. Aenean massa. Curabitur ullamcorper ultricies nisi. Praesent vestibulum dapibus nibh. In dui magna, posuere eget, vestibulum et, tempor auctor, justo.
</li> </li>
<li> <li>
Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu.
</li> </li>
<li> <li>
Duis lobortis massa imperdiet quam. Donec sodales sagittis magna. Nam ipsum risus, rutrum vitae, vestibulum eu, molestie vel, lacus. Suspendisse eu ligula. Morbi nec metus. Duis lobortis massa imperdiet quam. Donec sodales sagittis magna. Nam ipsum risus, rutrum vitae, vestibulum eu, molestie vel, lacus. Suspendisse eu ligula. Morbi nec metus.
</li> </li>
</ol> </ol>
</newText> </newText>
<expected> <expected>
<ol class="diff-list"><li class="normal"><del class="diffmod">Etiam feugiat lorem</del><ins class="diffmod">Suspendisse</ins> non <del class="diffmod">metus</del><ins class="diffmod">nisl sit amet velit hendrerit rutrum</ins>. <del class="diffmod">Nullam accumsan lorem in</del><ins class="diffmod">Aenean massa. Curabitur ullamcorper ultricies nisi. Praesent vestibulum dapibus nibh. In</ins> dui<ins class="diffins"> magna, posuere eget, vestibulum et, tempor auctor, justo</ins>.</li><li class="normal"><del class="diffmod">Praesent ac sem eget est egestas volutpat. Nulla neque dolor</del><ins class="diffmod">Donec pede justo</ins>, <del class="diffmod">sagittis</del><ins class="diffmod">fringilla vel, aliquet nec, vulputate</ins> eget, <del class="diffmod">iaculis quis, molestie non, velit</del><ins class="diffmod">arcu</ins>.<del class="diffdel"> Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Integer ante arcu, accumsan a, consectetuer eget, posuere ut, mauris. Aenean massa.</del></li><li class="normal"><del class="diffmod">Vestibulum suscipit nulla quis orci</del><ins class="diffmod">Duis lobortis massa imperdiet quam</ins>. <del class="diffmod">Integer ante arcu</del><ins class="diffmod">Donec sodales sagittis magna. Nam ipsum risus</ins>, <del class="diffmod">accumsan a</del><ins class="diffmod">rutrum vitae</ins>, <del class="diffmod">consectetuer eget</del><ins class="diffmod">vestibulum eu</ins>, <del class="diffmod">posuere ut</del><ins class="diffmod">molestie vel</ins>, <del class="diffmod">mauris</del><ins class="diffmod">lacus</ins>. <del class="diffmod">Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos</del><ins class="diffmod">Suspendisse eu ligula</ins>.<ins class="diffins"> Morbi nec metus.</ins></li><li class="removed"><del> Suspendisse non nisl sit amet velit hendrerit rutrum. Aenean massa. Curabitur ullamcorper ultricies nisi. Praesent vestibulum dapibus nibh. In dui magna, posuere eget, vestibulum et, tempor auctor, justo. </del></li></ol> <ol class="diff-list"><li class="normal"><del class="diffmod">Etiam feugiat lorem</del><ins class="diffmod">Suspendisse</ins> non <del class="diffmod">metus</del><ins class="diffmod">nisl sit amet velit hendrerit rutrum</ins>. <del class="diffmod">Nullam accumsan lorem in</del><ins class="diffmod">Aenean massa. Curabitur ullamcorper ultricies nisi. Praesent vestibulum dapibus nibh. In</ins> dui<ins class="diffins"> magna, posuere eget, vestibulum et, tempor auctor, justo</ins>.</li><li class="normal"><del class="diffmod">Praesent ac sem eget est egestas volutpat. Nulla neque dolor</del><ins class="diffmod">Donec pede justo</ins>, <del class="diffmod">sagittis</del><ins class="diffmod">fringilla vel, aliquet nec, vulputate</ins> eget, <del class="diffmod">iaculis quis, molestie non, velit</del><ins class="diffmod">arcu</ins>.<del class="diffdel"> Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Integer ante arcu, accumsan a, consectetuer eget, posuere ut, mauris. Aenean massa.</del></li><li class="normal"><del class="diffmod">Vestibulum suscipit nulla quis orci</del><ins class="diffmod">Duis lobortis massa imperdiet quam</ins>. <del class="diffmod">Integer ante arcu</del><ins class="diffmod">Donec sodales sagittis magna. Nam ipsum risus</ins>, <del class="diffmod">accumsan a</del><ins class="diffmod">rutrum vitae</ins>, <del class="diffmod">consectetuer eget</del><ins class="diffmod">vestibulum eu</ins>, <del class="diffmod">posuere ut</del><ins class="diffmod">molestie vel</ins>, <del class="diffmod">mauris</del><ins class="diffmod">lacus</ins>. <del class="diffmod">Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos</del><ins class="diffmod">Suspendisse eu ligula</ins>.<ins class="diffins"> Morbi nec metus.</ins></li><li class="removed"><del> Suspendisse non nisl sit amet velit hendrerit rutrum. Aenean massa. Curabitur ullamcorper ultricies nisi. Praesent vestibulum dapibus nibh. In dui magna, posuere eget, vestibulum et, tempor auctor, justo. </del></li></ol>
</expected> </expected>

@ -1,15 +1,15 @@
<oldText> <oldText>
Testing <a href="http://google.com">Link Changes</a> Testing <a href="http://google.com">Link Changes</a>
And when the link <a href="http://samelink.com">stays the same</a> And when the link <a href="http://samelink.com">stays the same</a>
</oldText> </oldText>
<newText> <newText>
Testing <a href="http://caxy.com">Link Changes</a> Testing <a href="http://caxy.com">Link Changes</a>
And when the link <a href="http://samelink.com">stays the same</a> And when the link <a href="http://samelink.com">stays the same</a>
</newText> </newText>
<expected> <expected>
Testing <del class="diffmod diff-href"><a href="http://google.com">Link Changes</a></del><ins class="diffmod diff-href"><a href="http://caxy.com">Link Changes</a></ins> Testing <del class="diffmod diff-href"><a href="http://google.com">Link Changes</a></del><ins class="diffmod diff-href"><a href="http://caxy.com">Link Changes</a></ins>
And when the link <a href="http://samelink.com">stays the same</a> And when the link <a href="http://samelink.com">stays the same</a>
</expected> </expected>

File diff suppressed because one or more lines are too long

@ -1,18 +1,18 @@
<oldText> <oldText>
<p>Air handling equipment and HVAC equipment shall be designed and installed to limit the amount of airflow that bypasses the air filters and shall comply with the following: </p> <p>Air handling equipment and HVAC equipment shall be designed and installed to limit the amount of airflow that bypasses the air filters and shall comply with the following: </p>
<ol><li>Channels, racks and other filter retaining constructions that do not seal tightly to the filter frame by means of a friction fit shall be provided with a means to seal the filter frame to the filter retaining construction.</li> <ol><li>Channels, racks and other filter retaining constructions that do not seal tightly to the filter frame by means of a friction fit shall be provided with a means to seal the filter frame to the filter retaining construction.</li>
<li>Where standard size filters are installed in banks of multiple filters, gaskets shall seal the gap between the frames of adjacent filters. As an alternative to gaskets, the frames of adjacent filters shall be compressed by means of spring elements that are built into the filter retaining construction.</li> <li>Where standard size filters are installed in banks of multiple filters, gaskets shall seal the gap between the frames of adjacent filters. As an alternative to gaskets, the frames of adjacent filters shall be compressed by means of spring elements that are built into the filter retaining construction.</li>
<li>Channels, racks and other filter retaining constructions shall be sealed to the duct or housing of the HVAC equipment served by the filters.</li> <li>Channels, racks and other filter retaining constructions shall be sealed to the duct or housing of the HVAC equipment served by the filters.</li>
<li>Filter access doors in ducts and HVAC equipment shall be designed to limit the amount of airflow that bypasses the filters.</li> <li>Filter access doors in ducts and HVAC equipment shall be designed to limit the amount of airflow that bypasses the filters.</li>
<li>Field or shop fabricated spacers shall not be installed for the purpose of replacing the intended size filter with a smaller size filter.</li> <li>Field or shop fabricated spacers shall not be installed for the purpose of replacing the intended size filter with a smaller size filter.</li>
<li>Gaskets and seals shall be provided with access for repair, maintenance and replacement.</li> <li>Gaskets and seals shall be provided with access for repair, maintenance and replacement.</li>
</ol> </ol>
</oldText> </oldText>
<newText> <newText>
<p>Air handling equipment and HVAC equipment shall be designed and installed to limit the amount of airflow that bypasses the air filters. Filter access doors in ducts and HVAC equipment shall be designed to limit the amount of airflow that bypasses the filters. Channels, racks and other filter retaining constructions shall be sealed to the duct or housing of the HVAC equipment served by the filters. Field or shop fabricated spacers shall not be installed for the purpose of replacing the intended size filter with a smaller size filter.</p> <p>Air handling equipment and HVAC equipment shall be designed and installed to limit the amount of airflow that bypasses the air filters. Filter access doors in ducts and HVAC equipment shall be designed to limit the amount of airflow that bypasses the filters. Channels, racks and other filter retaining constructions shall be sealed to the duct or housing of the HVAC equipment served by the filters. Field or shop fabricated spacers shall not be installed for the purpose of replacing the intended size filter with a smaller size filter.</p>
</newText> </newText>
<expected> <expected>
<p>Air handling equipment and HVAC equipment shall be designed and installed to limit the amount of airflow that bypasses the air filters<ins class="diffins">. Filter access doors in ducts</ins> and <ins class="diffins">HVAC equipment </ins>shall <del class="diffmod">comply</del><ins class="diffmod">be designed to limit the amount of airflow that bypasses the filters. Channels, racks and other filter retaining constructions shall be sealed to the duct or housing of the HVAC equipment served by the filters. Field or shop fabricated spacers shall not be installed for the purpose of replacing the intended size filter</ins> with <del class="diffmod">the following: </del><ins class="diffmod">a smaller size filter.</ins></p><del class="diffdel"> </del><ol class="diffmod"><li><del class="diffdel">Channels, racks and other filter retaining constructions that do not seal tightly to the filter frame by means of a friction fit shall be provided with a means to seal the filter frame to the filter retaining construction.</del></li><del class="diffdel"> </del><li class="diffmod"><del class="diffdel">Where standard size filters are installed in banks of multiple filters, gaskets shall seal the gap between the frames of adjacent filters. As an alternative to gaskets, the frames of adjacent filters shall be compressed by means of spring elements that are built into the filter retaining construction.</del></li><del class="diffdel"> </del><li class="diffmod"><del class="diffdel">Channels, racks and other filter retaining constructions shall be sealed to the duct or housing of the HVAC equipment served by the filters.</del></li><del class="diffdel"> </del><li class="diffmod"><del class="diffdel">Filter access doors in ducts and HVAC equipment shall be designed to limit the amount of airflow that bypasses the filters.</del></li><del class="diffdel"> </del><li class="diffmod"><del class="diffdel">Field or shop fabricated spacers shall not be installed for the purpose of replacing the intended size filter with a smaller size filter.</del></li><del class="diffdel"> </del><li class="diffmod"><del class="diffdel">Gaskets and seals shall be provided with access for repair, maintenance and replacement.</del></li><del class="diffdel"> </del></ol> <p>Air handling equipment and HVAC equipment shall be designed and installed to limit the amount of airflow that bypasses the air filters<ins class="diffins">. Filter access doors in ducts</ins> and <ins class="diffins">HVAC equipment </ins>shall <del class="diffmod">comply</del><ins class="diffmod">be designed to limit the amount of airflow that bypasses the filters. Channels, racks and other filter retaining constructions shall be sealed to the duct or housing of the HVAC equipment served by the filters. Field or shop fabricated spacers shall not be installed for the purpose of replacing the intended size filter</ins> with <del class="diffmod">the following: </del><ins class="diffmod">a smaller size filter.</ins></p><del class="diffdel"> </del><ol class="diffmod"><li><del class="diffdel">Channels, racks and other filter retaining constructions that do not seal tightly to the filter frame by means of a friction fit shall be provided with a means to seal the filter frame to the filter retaining construction.</del></li><del class="diffdel"> </del><li class="diffmod"><del class="diffdel">Where standard size filters are installed in banks of multiple filters, gaskets shall seal the gap between the frames of adjacent filters. As an alternative to gaskets, the frames of adjacent filters shall be compressed by means of spring elements that are built into the filter retaining construction.</del></li><del class="diffdel"> </del><li class="diffmod"><del class="diffdel">Channels, racks and other filter retaining constructions shall be sealed to the duct or housing of the HVAC equipment served by the filters.</del></li><del class="diffdel"> </del><li class="diffmod"><del class="diffdel">Filter access doors in ducts and HVAC equipment shall be designed to limit the amount of airflow that bypasses the filters.</del></li><del class="diffdel"> </del><li class="diffmod"><del class="diffdel">Field or shop fabricated spacers shall not be installed for the purpose of replacing the intended size filter with a smaller size filter.</del></li><del class="diffdel"> </del><li class="diffmod"><del class="diffdel">Gaskets and seals shall be provided with access for repair, maintenance and replacement.</del></li><del class="diffdel"> </del></ol>
</expected> </expected>

@ -1,29 +1,29 @@
<oldText> <oldText>
<div>The path of egress travel to an exit shall not pass through more than one adjacent story.</div> <div>The path of egress travel to an exit shall not pass through more than one adjacent story.</div>
<div> </div> <div> </div>
<div style="padding-left:30px;"><strong>Exception:</strong> The path of egress travel to an exit shall be permitted to pass through more than one adjacent story in any of the following:</div> <div style="padding-left:30px;"><strong>Exception:</strong> The path of egress travel to an exit shall be permitted to pass through more than one adjacent story in any of the following:</div>
<ol><li>In Group R-1, R-2 or R-3 occupancies, exit access stairways and ramps connecting four stories or less serving and contained within an individual dwelling unit or sleeping unit or live/work unit.</li> <ol><li>In Group R-1, R-2 or R-3 occupancies, exit access stairways and ramps connecting four stories or less serving and contained within an individual dwelling unit or sleeping unit or live/work unit.</li>
<li>Exit access stairways serving and contained within a Group R-3 congregate residence or a Group R-4 facility.</li> <li>Exit access stairways serving and contained within a Group R-3 congregate residence or a Group R-4 facility.</li>
<li>Exit access stairways and ramps in open parking garages that serve only the parking garage.</li> <li>Exit access stairways and ramps in open parking garages that serve only the parking garage.</li>
<li>Exit access stairways and ramps serving open-air assembly seating complying with the exit access travel distance requirements of Section 1029.7.</li> <li>Exit access stairways and ramps serving open-air assembly seating complying with the exit access travel distance requirements of Section 1029.7.</li>
<li>Exit access stairways and ramps between the balcony, gallery or press box and the main assembly floor in occupancies such as theaters, places of religious worship, auditoriums and sports facilities.</li> <li>Exit access stairways and ramps between the balcony, gallery or press box and the main assembly floor in occupancies such as theaters, places of religious worship, auditoriums and sports facilities.</li>
</ol><div> </div> </ol><div> </div>
</oldText> </oldText>
<newText> <newText>
<div>The path of egress travel to an exit shall not pass through more than one adjacent story.</div> <div>The path of egress travel to an exit shall not pass through more than one adjacent story.</div>
<div> </div> <div> </div>
<div style="padding-left:30px;"><strong>Exception:</strong> The path of egress travel to an exit shall be permitted to pass through more than one adjacent story in any of the following:</div> <div style="padding-left:30px;"><strong>Exception:</strong> The path of egress travel to an exit shall be permitted to pass through more than one adjacent story in any of the following:</div>
<ol><li>In Group R-1, R-2 or R-3 occupancies, exit access stairways and ramps connecting four stories or less serving and contained within an individual dwelling unit or sleeping unit or live/work unit.</li> <ol><li>In Group R-1, R-2 or R-3 occupancies, exit access stairways and ramps connecting four stories or less serving and contained within an individual dwelling unit or sleeping unit or live/work unit.</li>
<li>Exit access stairways serving and contained within a Group R-3 congregate residence or a Group R-4 facility.</li> <li>Exit access stairways serving and contained within a Group R-3 congregate residence or a Group R-4 facility.</li>
<li>Exit access stairways and ramps in open parking garages that serve only the parking garage.</li> <li>Exit access stairways and ramps in open parking garages that serve only the parking garage.</li>
<li>Exit access stairways and ramps in buildings equipped throughout with an automatic sprinkler system in accordance with Section 903.3.1.1, where the area of the vertical opening between stories does not exceed twice the horizontal projected area of the stairway or ramp and the opening is protected by a draft curtain and closely spaced sprinklers in accordance with NFPA 13. In other than Group B and M occupancies, this provision is limited to openings that do not connect more than four stories.</li> <li>Exit access stairways and ramps in buildings equipped throughout with an automatic sprinkler system in accordance with Section 903.3.1.1, where the area of the vertical opening between stories does not exceed twice the horizontal projected area of the stairway or ramp and the opening is protected by a draft curtain and closely spaced sprinklers in accordance with NFPA 13. In other than Group B and M occupancies, this provision is limited to openings that do not connect more than four stories.</li>
<li>Exit access stairways and ramps within an atrium complying with the provisions of Section 404.</li> <li>Exit access stairways and ramps within an atrium complying with the provisions of Section 404.</li>
<li>Exit access stairways and ramps serving open-air assembly seating complying with the exit access travel distance requirements of Section 1029.7.</li> <li>Exit access stairways and ramps serving open-air assembly seating complying with the exit access travel distance requirements of Section 1029.7.</li>
<li>Exit access stairways and ramps between the balcony, gallery or press box and the main assembly floor in occupancies such as theaters, places of religious worship, auditoriums and sports facilities.</li> <li>Exit access stairways and ramps between the balcony, gallery or press box and the main assembly floor in occupancies such as theaters, places of religious worship, auditoriums and sports facilities.</li>
</ol><div> </div> </ol><div> </div>
</newText> </newText>
<expected> <expected>
<div>The path of egress travel to an exit shall not pass through more than one adjacent story.</div> <div> </div> <div style="padding-left:30px;"><strong>Exception:</strong> The path of egress travel to an exit shall be permitted to pass through more than one adjacent story in any of the following:</div> <ol class="diff-list"><li class="normal">In Group R-1, R-2 or R-3 occupancies, exit access stairways and ramps connecting four stories or less serving and contained within an individual dwelling unit or sleeping unit or live/work unit.</li><li class="normal">Exit access stairways serving and contained within a Group R-3 congregate residence or a Group R-4 facility.</li><li class="normal">Exit access stairways and ramps in open parking garages that serve only the parking garage.</li><li class="normal new"><ins>Exit access stairways and ramps in buildings equipped throughout with an automatic sprinkler system in accordance with Section 903.3.1.1, where the area of the vertical opening between stories does not exceed twice the horizontal projected area of the stairway or ramp and the opening is protected by a draft curtain and closely spaced sprinklers in accordance with NFPA 13. In other than Group B and M occupancies, this provision is limited to openings that do not connect more than four stories.</ins></li><li class="normal new"><ins>Exit access stairways and ramps within an atrium complying with the provisions of Section 404.</ins></li><li class="normal">Exit access stairways and ramps serving open-air assembly seating complying with the exit access travel distance requirements of Section 1029.7.</li><li class="normal">Exit access stairways and ramps between the balcony, gallery or press box and the main assembly floor in occupancies such as theaters, places of religious worship, auditoriums and sports facilities.</li></ol><div> </div> <div>The path of egress travel to an exit shall not pass through more than one adjacent story.</div> <div> </div> <div style="padding-left:30px;"><strong>Exception:</strong> The path of egress travel to an exit shall be permitted to pass through more than one adjacent story in any of the following:</div> <ol class="diff-list"><li class="normal">In Group R-1, R-2 or R-3 occupancies, exit access stairways and ramps connecting four stories or less serving and contained within an individual dwelling unit or sleeping unit or live/work unit.</li><li class="normal">Exit access stairways serving and contained within a Group R-3 congregate residence or a Group R-4 facility.</li><li class="normal">Exit access stairways and ramps in open parking garages that serve only the parking garage.</li><li class="normal new"><ins>Exit access stairways and ramps in buildings equipped throughout with an automatic sprinkler system in accordance with Section 903.3.1.1, where the area of the vertical opening between stories does not exceed twice the horizontal projected area of the stairway or ramp and the opening is protected by a draft curtain and closely spaced sprinklers in accordance with NFPA 13. In other than Group B and M occupancies, this provision is limited to openings that do not connect more than four stories.</ins></li><li class="normal new"><ins>Exit access stairways and ramps within an atrium complying with the provisions of Section 404.</ins></li><li class="normal">Exit access stairways and ramps serving open-air assembly seating complying with the exit access travel distance requirements of Section 1029.7.</li><li class="normal">Exit access stairways and ramps between the balcony, gallery or press box and the main assembly floor in occupancies such as theaters, places of religious worship, auditoriums and sports facilities.</li></ol><div> </div>
</expected> </expected>

@ -1,28 +1,28 @@
<oldText> <oldText>
<em>Corridors</em> shall be fire-resistance rated in accordance with Table 1020.1. The <em>corridor</em> walls required to be fire-resistance rated shall comply with Section 708 for <em>fire partitions</em>.<br /><br />In addition, corridors in buildings of Types IIB, IIIB, and VB construction and assigned Risk Categories III and IV in Table 1604.5, other than Group I, shall have a fire resistance rating of not less than 1 hour where such buildings are any of the following:<br /><br /><ol><li>Assigned a Seismic Design Category C or D in Table 1613.3.5(1).</li> <em>Corridors</em> shall be fire-resistance rated in accordance with Table 1020.1. The <em>corridor</em> walls required to be fire-resistance rated shall comply with Section 708 for <em>fire partitions</em>.<br /><br />In addition, corridors in buildings of Types IIB, IIIB, and VB construction and assigned Risk Categories III and IV in Table 1604.5, other than Group I, shall have a fire resistance rating of not less than 1 hour where such buildings are any of the following:<br /><br /><ol><li>Assigned a Seismic Design Category C or D in Table 1613.3.5(1).</li>
<li>Located in a flood hazard area established in accordance with Section 1612.3.</li> <li>Located in a flood hazard area established in accordance with Section 1612.3.</li>
<li>Located in a <em>hurricane-prone regions</em>.</li> <li>Located in a <em>hurricane-prone regions</em>.</li>
</ol><ul class="exception"><li><strong>Exceptions:</strong><ol><li>A <em>fire-resistance rating</em> is not required for <em>corridors</em> in an occupancy in Group E where each room that is used for instruction has not less than one door opening directly to the exterior and rooms for assembly purposes have not less than one-half of the required <em>means of egress</em> doors opening directly to the exterior. Exterior doors specified in this exception are required to be at ground level.</li> </ol><ul class="exception"><li><strong>Exceptions:</strong><ol><li>A <em>fire-resistance rating</em> is not required for <em>corridors</em> in an occupancy in Group E where each room that is used for instruction has not less than one door opening directly to the exterior and rooms for assembly purposes have not less than one-half of the required <em>means of egress</em> doors opening directly to the exterior. Exterior doors specified in this exception are required to be at ground level.</li>
<li>A <em>fire-resistance rating</em> is not required for <em>corridors</em> contained within a <em>dwelling unit</em> or <em>sleeping unit</em> in an occupancy in Groups I-1 and R.</li> <li>A <em>fire-resistance rating</em> is not required for <em>corridors</em> contained within a <em>dwelling unit</em> or <em>sleeping unit</em> in an occupancy in Groups I-1 and R.</li>
<li>A <em>fire-resistance rating</em> is not required for <em>corridors</em> in <em>open parking garages</em>.</li> <li>A <em>fire-resistance rating</em> is not required for <em>corridors</em> in <em>open parking garages</em>.</li>
<li>A <em>fire-resistance rating</em> is not required for <em>corridors</em> in an occupancy in Group B that is a space requiring only a single <em>means of egress</em> complying with Section 1006.2.</li> <li>A <em>fire-resistance rating</em> is not required for <em>corridors</em> in an occupancy in Group B that is a space requiring only a single <em>means of egress</em> complying with Section 1006.2.</li>
<li><em>Corridors</em> adjacent to the <em>exterior walls</em> of buildings shall be permitted to have unprotected openings on unrated <em>exterior walls</em> where unrated walls are permitted by Table 602 and unprotected openings are permitted by Table 705.8.</li> <li><em>Corridors</em> adjacent to the <em>exterior walls</em> of buildings shall be permitted to have unprotected openings on unrated <em>exterior walls</em> where unrated walls are permitted by Table 602 and unprotected openings are permitted by Table 705.8.</li>
</ol></li> </ol></li>
</ul> </ul>
</oldText> </oldText>
<newText> <newText>
<em>Corridors</em> shall be fire-resistance rated in accordance with Table 1020.1 and where applicable in Section 1020.1.1. The <em>corridor</em> walls required to be fire-resistance rated shall comply with Section 708 for <em>fire partitions</em>.<br /><ul class="exception"><li><strong>Exceptions:</strong></li> <em>Corridors</em> shall be fire-resistance rated in accordance with Table 1020.1 and where applicable in Section 1020.1.1. The <em>corridor</em> walls required to be fire-resistance rated shall comply with Section 708 for <em>fire partitions</em>.<br /><ul class="exception"><li><strong>Exceptions:</strong></li>
<li> <li>
<ol><li>A <em>fire-resistance rating</em> is not required for <em>corridors</em> in an occupancy in Group E where each room that is used for instruction has not less than one door opening directly to the exterior and rooms for assembly purposes have not less than one-half of the required <em>means of egress</em> doors opening directly to the exterior. Exterior doors specified in this exception are required to be at ground level.</li> <ol><li>A <em>fire-resistance rating</em> is not required for <em>corridors</em> in an occupancy in Group E where each room that is used for instruction has not less than one door opening directly to the exterior and rooms for assembly purposes have not less than one-half of the required <em>means of egress</em> doors opening directly to the exterior. Exterior doors specified in this exception are required to be at ground level.</li>
<li>A <em>fire-resistance rating</em> is not required for <em>corridors</em> contained within a <em>dwelling unit</em> or <em>sleeping unit</em> in an occupancy in Groups I-1 and R.</li> <li>A <em>fire-resistance rating</em> is not required for <em>corridors</em> contained within a <em>dwelling unit</em> or <em>sleeping unit</em> in an occupancy in Groups I-1 and R.</li>
<li>A <em>fire-resistance rating</em> is not required for <em>corridors</em> in <em>open parking garages</em>.</li> <li>A <em>fire-resistance rating</em> is not required for <em>corridors</em> in <em>open parking garages</em>.</li>
<li>A <em>fire-resistance rating</em> is not required for <em>corridors</em> in an occupancy in Group B that is a space requiring only a single <em>means of egress</em> complying with Section 1006.2.</li> <li>A <em>fire-resistance rating</em> is not required for <em>corridors</em> in an occupancy in Group B that is a space requiring only a single <em>means of egress</em> complying with Section 1006.2.</li>
<li><em>Corridors</em> adjacent to the <em>exterior walls</em> of buildings shall be permitted to have unprotected openings on unrated <em>exterior walls</em> where unrated walls are permitted by Table 602 and unprotected openings are permitted by Table 705.8.</li> <li><em>Corridors</em> adjacent to the <em>exterior walls</em> of buildings shall be permitted to have unprotected openings on unrated <em>exterior walls</em> where unrated walls are permitted by Table 602 and unprotected openings are permitted by Table 705.8.</li>
</ol></li> </ol></li>
</ul> </ul>
</newText> </newText>
<expected> <expected>
<em>Corridors</em> shall be fire-resistance rated in accordance with Table 1020.1<ins class="diffins"> and where applicable in Section 1020.1.1</ins>. The <em>corridor</em> walls required to be fire-resistance rated shall comply with Section 708 for <em>fire partitions</em>.<br /><br / class="diffmod"><del class="diffdel">In addition, corridors in buildings of Types IIB, IIIB, and VB construction and assigned Risk Categories III and IV in Table 1604.5, other than Group I, shall have a fire resistance rating of not less than 1 hour where such buildings are any of the following:</del><br / class="diffmod"><br /><ol><li><del class="diffdel">Assigned a Seismic Design Category C or D in Table 1613.3.5(1).</del></li><del class="diffdel"> </del><li class="diffmod"><del class="diffdel">Located in a flood hazard area established in accordance with Section 1612.3.</del></li><del class="diffdel"> </del><li class="diffmod"><del class="diffdel">Located in a </del><em class="diffmod"><del class="diffdel">hurricane-prone regions</del></em><del class="diffdel">.</del></li><del class="diffdel"> </del></ol><ul class="exception"><li><strong>Exceptions:</strong></li><ins class="diffins"> </ins><li class="diffmod"><ins class="diffins"> </ins><ol><li>A <em>fire-resistance rating</em> is not required for <em>corridors</em> in an occupancy in Group E where each room that is used for instruction has not less than one door opening directly to the exterior and rooms for assembly purposes have not less than one-half of the required <em>means of egress</em> doors opening directly to the exterior. Exterior doors specified in this exception are required to be at ground level.</li> <li>A <em>fire-resistance rating</em> is not required for <em>corridors</em> contained within a <em>dwelling unit</em> or <em>sleeping unit</em> in an occupancy in Groups I-1 and R.</li> <li>A <em>fire-resistance rating</em> is not required for <em>corridors</em> in <em>open parking garages</em>.</li> <li>A <em>fire-resistance rating</em> is not required for <em>corridors</em> in an occupancy in Group B that is a space requiring only a single <em>means of egress</em> complying with Section 1006.2.</li> <li><em>Corridors</em> adjacent to the <em>exterior walls</em> of buildings shall be permitted to have unprotected openings on unrated <em>exterior walls</em> where unrated walls are permitted by Table 602 and unprotected openings are permitted by Table 705.8.</li> </ol></li> </ul> <em>Corridors</em> shall be fire-resistance rated in accordance with Table 1020.1<ins class="diffins"> and where applicable in Section 1020.1.1</ins>. The <em>corridor</em> walls required to be fire-resistance rated shall comply with Section 708 for <em>fire partitions</em>.<br /><br / class="diffmod"><del class="diffdel">In addition, corridors in buildings of Types IIB, IIIB, and VB construction and assigned Risk Categories III and IV in Table 1604.5, other than Group I, shall have a fire resistance rating of not less than 1 hour where such buildings are any of the following:</del><br / class="diffmod"><br /><ol><li><del class="diffdel">Assigned a Seismic Design Category C or D in Table 1613.3.5(1).</del></li><del class="diffdel"> </del><li class="diffmod"><del class="diffdel">Located in a flood hazard area established in accordance with Section 1612.3.</del></li><del class="diffdel"> </del><li class="diffmod"><del class="diffdel">Located in a </del><em class="diffmod"><del class="diffdel">hurricane-prone regions</del></em><del class="diffdel">.</del></li><del class="diffdel"> </del></ol><ul class="exception"><li><strong>Exceptions:</strong></li><ins class="diffins"> </ins><li class="diffmod"><ins class="diffins"> </ins><ol><li>A <em>fire-resistance rating</em> is not required for <em>corridors</em> in an occupancy in Group E where each room that is used for instruction has not less than one door opening directly to the exterior and rooms for assembly purposes have not less than one-half of the required <em>means of egress</em> doors opening directly to the exterior. Exterior doors specified in this exception are required to be at ground level.</li> <li>A <em>fire-resistance rating</em> is not required for <em>corridors</em> contained within a <em>dwelling unit</em> or <em>sleeping unit</em> in an occupancy in Groups I-1 and R.</li> <li>A <em>fire-resistance rating</em> is not required for <em>corridors</em> in <em>open parking garages</em>.</li> <li>A <em>fire-resistance rating</em> is not required for <em>corridors</em> in an occupancy in Group B that is a space requiring only a single <em>means of egress</em> complying with Section 1006.2.</li> <li><em>Corridors</em> adjacent to the <em>exterior walls</em> of buildings shall be permitted to have unprotected openings on unrated <em>exterior walls</em> where unrated walls are permitted by Table 602 and unprotected openings are permitted by Table 705.8.</li> </ol></li> </ul>
</expected> </expected>

File diff suppressed because one or more lines are too long

@ -1,42 +1,42 @@
<oldText> <oldText>
<p>Return air openings for heating, ventilation and air-conditioning systems shall comply with all of the following:</p> <p>Return air openings for heating, ventilation and air-conditioning systems shall comply with all of the following:</p>
<ol><li>Openings shall not be located less than 10 feet (3048 mm) measured in any direction from an open combustion chamber or draft hood of another appliance located in the same room or space.</li> <ol><li>Openings shall not be located less than 10 feet (3048 mm) measured in any direction from an open combustion chamber or draft hood of another appliance located in the same room or space.</li>
<li>Return air shall not be taken from a hazardous or insanitary location or a refrigeration room as defined in this code.</li> <li>Return air shall not be taken from a hazardous or insanitary location or a refrigeration room as defined in this code.</li>
<li>The amount of return air taken from any room or space shall be not greater than the flow rate of supply air delivered to such room or space.</li> <li>The amount of return air taken from any room or space shall be not greater than the flow rate of supply air delivered to such room or space.</li>
<li>Return and transfer openings shall be sized in accordance with the appliance or equipment manufacturer's installation instructions, ACCA Manual D or the design of the registered design professional.</li> <li>Return and transfer openings shall be sized in accordance with the appliance or equipment manufacturer's installation instructions, ACCA Manual D or the design of the registered design professional.</li>
<li>Return air taken from one dwelling unit shall not be discharged into another dwelling unit.</li> <li>Return air taken from one dwelling unit shall not be discharged into another dwelling unit.</li>
<li>Taking return air from a crawl space shall not be accomplished through a direct connection to the return side of a forced air furnace. Transfer openings in the crawl space enclosure shall not be prohibited.</li> <li>Taking return air from a crawl space shall not be accomplished through a direct connection to the return side of a forced air furnace. Transfer openings in the crawl space enclosure shall not be prohibited.</li>
<li>Return air shall not be taken from a closet, bathroom, toilet room, kitchen, garage, boiler room, furnace room or unconditioned attic. <li>Return air shall not be taken from a closet, bathroom, toilet room, kitchen, garage, boiler room, furnace room or unconditioned attic.
<ul class="exception"><li><strong>Exceptions:</strong> <ul class="exception"><li><strong>Exceptions:</strong>
<ol><li>Taking return air from a kitchen is not prohibited where such return air openings serve the kitchen and are located not less than 10 feet (3048 mm) from the cooking appliances.</li> <ol><li>Taking return air from a kitchen is not prohibited where such return air openings serve the kitchen and are located not less than 10 feet (3048 mm) from the cooking appliances.</li>
<li>Dedicated forced air systems serving only the garage shall not be prohibited from obtaining return air from the garage</li> <li>Dedicated forced air systems serving only the garage shall not be prohibited from obtaining return air from the garage</li>
</ol></li> </ol></li>
</ul></li> </ul></li>
<li>Return air shall not be taken from indoor swimming pool enclosures and associated deck areas. <li>Return air shall not be taken from indoor swimming pool enclosures and associated deck areas.
<ul class="exception"><li><strong>Exceptions:</strong> <ul class="exception"><li><strong>Exceptions:</strong>
<ol><li>Where the air from such spaces is dehumidified in accordance with Sections 403.2.1 Item #2.</li> <ol><li>Where the air from such spaces is dehumidified in accordance with Sections 403.2.1 Item #2.</li>
<li>Dedicated HVAC systems serving only such spaces.</li> <li>Dedicated HVAC systems serving only such spaces.</li>
</ol></li> </ol></li>
</ul></li> </ul></li>
</ol> </ol>
</oldText> </oldText>
<newText> <newText>
<p>Return air openings for heating, ventilation and air-conditioning systems shall comply with all of the following:</p> <p>Return air openings for heating, ventilation and air-conditioning systems shall comply with all of the following:</p>
<ol><li>Openings shall not be located less than 10 feet (3048 mm) measured in any direction from an open combustion chamber or draft hood of another appliance located in the same room or space.</li> <ol><li>Openings shall not be located less than 10 feet (3048 mm) measured in any direction from an open combustion chamber or draft hood of another appliance located in the same room or space.</li>
<li>Return air shall not be taken from a hazardous or insanitary location or a refrigeration room as defined in this code.</li> <li>Return air shall not be taken from a hazardous or insanitary location or a refrigeration room as defined in this code.</li>
<li>The amount of return air taken from any room or space shall be not greater than the flow rate of supply air delivered to such room or space.</li> <li>The amount of return air taken from any room or space shall be not greater than the flow rate of supply air delivered to such room or space.</li>
<li>Return and transfer openings shall be sized in accordance with the appliance or equipment manufacturer's installation instructions, ACCA Manual D or the design of the registered design professional.</li> <li>Return and transfer openings shall be sized in accordance with the appliance or equipment manufacturer's installation instructions, ACCA Manual D or the design of the registered design professional.</li>
<li>Return air taken from one dwelling unit shall not be discharged into another dwelling unit.</li> <li>Return air taken from one dwelling unit shall not be discharged into another dwelling unit.</li>
<li>Taking return air from a crawl space shall not be accomplished through a direct connection to the return side of a forced air furnace. Transfer openings in the crawl space enclosure shall not be prohibited.</li> <li>Taking return air from a crawl space shall not be accomplished through a direct connection to the return side of a forced air furnace. Transfer openings in the crawl space enclosure shall not be prohibited.</li>
<li>Return air shall not be taken from a closet, bathroom, toilet room, kitchen, garage, boiler room, furnace room, indoor swimming pool enclosure and associated deck area, or unconditioned attic.</li> <li>Return air shall not be taken from a closet, bathroom, toilet room, kitchen, garage, boiler room, furnace room, indoor swimming pool enclosure and associated deck area, or unconditioned attic.</li>
</ol><ul class="exception"><li><strong>Exceptions:</strong></li> </ol><ul class="exception"><li><strong>Exceptions:</strong></li>
</ul><ol><li>Taking return air from a kitchen is not prohibited where such return air openings serve the kitchen and are located not less than 10 feet (3048 mm) from the cooking appliances.</li> </ul><ol><li>Taking return air from a kitchen is not prohibited where such return air openings serve the kitchen and are located not less than 10 feet (3048 mm) from the cooking appliances.</li>
<li>Dedicated forced air systems serving only the garage shall not be prohibited from obtaining return air from the garage</li> <li>Dedicated forced air systems serving only the garage shall not be prohibited from obtaining return air from the garage</li>
<li>Dedicated HVAC systems serving indoor swimming pool enclosures and associated deck areas shall not be prohibited from obtaining return air from such swimming pool enclosures and associated deck areas</li> <li>Dedicated HVAC systems serving indoor swimming pool enclosures and associated deck areas shall not be prohibited from obtaining return air from such swimming pool enclosures and associated deck areas</li>
</ol> </ol>
</newText> </newText>
<expected> <expected>
<p>Return air openings for heating, ventilation and air-conditioning systems shall comply with all of the following:</p> <ol class="diff-list"><li class="normal">Openings shall not be located less than 10 feet (3048 mm) measured in any direction from an open combustion chamber or draft hood of another appliance located in the same room or space.</li><li class="normal">Return air shall not be taken from a hazardous or insanitary location or a refrigeration room as defined in this code.</li><li class="normal">The amount of return air taken from any room or space shall be not greater than the flow rate of supply air delivered to such room or space.</li><li class="normal">Return and transfer openings shall be sized in accordance with the appliance or equipment manufacturer's installation instructions, ACCA Manual D or the design of the registered design professional.</li><li class="normal">Return air taken from one dwelling unit shall not be discharged into another dwelling unit.</li><li class="normal">Taking return air from a crawl space shall not be accomplished through a direct connection to the return side of a forced air furnace. Transfer openings in the crawl space enclosure shall not be prohibited.</li><li class="normal">Return air shall not be taken from a closet, bathroom, toilet room, kitchen, garage, boiler room, furnace room<ins class="diffins">, indoor swimming pool enclosure and associated deck area,</ins> or unconditioned attic.<del class="diffdel"> </del><ul class="diffmod exception"><li><strong><del class="diffdel">Exceptions:</del></strong><del class="diffdel"> </del><ol class="diffmod"><li><del class="diffdel">Taking return air from a kitchen is not prohibited where such return air openings serve the kitchen and are located not less than 10 feet (3048 mm) from the cooking appliances.</del></li><del class="diffdel"> </del><li class="diffmod"><del class="diffdel">Dedicated forced air systems serving only the garage shall not be prohibited from obtaining return air from the garage</del></li><del class="diffdel"> </del></ol></li><del class="diffdel"> </del></ul></li><li class="removed"><del>Return air shall not be taken from indoor swimming pool enclosures and associated deck areas. <ul class="exception"><li><strong>Exceptions:</strong> <ol><li>Where the air from such spaces is dehumidified in accordance with Sections 403.2.1 Item #2.</li> <li>Dedicated HVAC systems serving only such spaces.</li> </ol></li> </ul></del></li></ol><ul class="diffmod exception"><li><strong><ins class="diffins">Exceptions:</ins></strong></li><ins class="diffins"> </ins></ul><ol><li><ins class="diffins">Taking return air from a kitchen is not prohibited where such return air openings serve the kitchen and are located not less than 10 feet (3048 mm) from the cooking appliances.</ins></li><ins class="diffins"> </ins><li class="diffmod"><ins class="diffins">Dedicated forced air systems serving only the garage shall not be prohibited from obtaining return air from the garage</ins></li><ins class="diffins"> </ins><li class="diffmod"><ins class="diffins">Dedicated HVAC systems serving indoor swimming pool enclosures and associated deck areas shall not be prohibited from obtaining return air from such swimming pool enclosures and associated deck areas</ins></li><ins class="diffins"> </ins></ol> <p>Return air openings for heating, ventilation and air-conditioning systems shall comply with all of the following:</p> <ol class="diff-list"><li class="normal">Openings shall not be located less than 10 feet (3048 mm) measured in any direction from an open combustion chamber or draft hood of another appliance located in the same room or space.</li><li class="normal">Return air shall not be taken from a hazardous or insanitary location or a refrigeration room as defined in this code.</li><li class="normal">The amount of return air taken from any room or space shall be not greater than the flow rate of supply air delivered to such room or space.</li><li class="normal">Return and transfer openings shall be sized in accordance with the appliance or equipment manufacturer's installation instructions, ACCA Manual D or the design of the registered design professional.</li><li class="normal">Return air taken from one dwelling unit shall not be discharged into another dwelling unit.</li><li class="normal">Taking return air from a crawl space shall not be accomplished through a direct connection to the return side of a forced air furnace. Transfer openings in the crawl space enclosure shall not be prohibited.</li><li class="normal">Return air shall not be taken from a closet, bathroom, toilet room, kitchen, garage, boiler room, furnace room<ins class="diffins">, indoor swimming pool enclosure and associated deck area,</ins> or unconditioned attic.<del class="diffdel"> </del><ul class="diffmod exception"><li><strong><del class="diffdel">Exceptions:</del></strong><del class="diffdel"> </del><ol class="diffmod"><li><del class="diffdel">Taking return air from a kitchen is not prohibited where such return air openings serve the kitchen and are located not less than 10 feet (3048 mm) from the cooking appliances.</del></li><del class="diffdel"> </del><li class="diffmod"><del class="diffdel">Dedicated forced air systems serving only the garage shall not be prohibited from obtaining return air from the garage</del></li><del class="diffdel"> </del></ol></li><del class="diffdel"> </del></ul></li><li class="removed"><del>Return air shall not be taken from indoor swimming pool enclosures and associated deck areas. <ul class="exception"><li><strong>Exceptions:</strong> <ol><li>Where the air from such spaces is dehumidified in accordance with Sections 403.2.1 Item #2.</li> <li>Dedicated HVAC systems serving only such spaces.</li> </ol></li> </ul></del></li></ol><ul class="diffmod exception"><li><strong><ins class="diffins">Exceptions:</ins></strong></li><ins class="diffins"> </ins></ul><ol><li><ins class="diffins">Taking return air from a kitchen is not prohibited where such return air openings serve the kitchen and are located not less than 10 feet (3048 mm) from the cooking appliances.</ins></li><ins class="diffins"> </ins><li class="diffmod"><ins class="diffins">Dedicated forced air systems serving only the garage shall not be prohibited from obtaining return air from the garage</ins></li><ins class="diffins"> </ins><li class="diffmod"><ins class="diffins">Dedicated HVAC systems serving indoor swimming pool enclosures and associated deck areas shall not be prohibited from obtaining return air from such swimming pool enclosures and associated deck areas</ins></li><ins class="diffins"> </ins></ol>
</expected> </expected>

@ -1,11 +1,11 @@
<oldText> <oldText>
<p>The manufacturer of PEX tubing shall have marked the outside of the tubing with the thermoplastic material designation code in accordance with ASTM F876. The designation code shall consist of the abbreviation "PEX" followed by four digits. The first digit shall represent a chlorine resistance rating as established by testing in accordance with ASTM F876.</p> <p>The manufacturer of PEX tubing shall have marked the outside of the tubing with the thermoplastic material designation code in accordance with ASTM F876. The designation code shall consist of the abbreviation "PEX" followed by four digits. The first digit shall represent a chlorine resistance rating as established by testing in accordance with ASTM F876.</p>
</oldText> </oldText>
<newText> <newText>
<p>For PEX tubing complying with ASTM F876, the first digit folllowing "PEX" as marked on the tubing exterior shall be an indicator of the maximum service temperatures for which the PEX tubing can be used. The maximum service temperatures shall be as follows:<br /><br />1. Digit “0”: 73⁰F (23⁰C). <br /><br />2. Digit “1”: For not more that 25% of the time, greater than 73⁰F (23⁰C) and not exceeding140⁰F (60⁰C). For the remainder of the time, not greater than 73⁰F (23⁰C). <br /><br />3. Digit “3”: For not more that 50% of the time, greater than 73⁰F (23⁰C) and not exceeding 140⁰F (60⁰C). For the remainder of the time, not greater than 73⁰F (23⁰C). <br /><br />4. Digit “5”: 140⁰F (60⁰C). <br /><br /><br /></p> <p>For PEX tubing complying with ASTM F876, the first digit folllowing "PEX" as marked on the tubing exterior shall be an indicator of the maximum service temperatures for which the PEX tubing can be used. The maximum service temperatures shall be as follows:<br /><br />1. Digit “0”: 73⁰F (23⁰C). <br /><br />2. Digit “1”: For not more that 25% of the time, greater than 73⁰F (23⁰C) and not exceeding140⁰F (60⁰C). For the remainder of the time, not greater than 73⁰F (23⁰C). <br /><br />3. Digit “3”: For not more that 50% of the time, greater than 73⁰F (23⁰C) and not exceeding 140⁰F (60⁰C). For the remainder of the time, not greater than 73⁰F (23⁰C). <br /><br />4. Digit “5”: 140⁰F (60⁰C). <br /><br /><br /></p>
</newText> </newText>
<expected> <expected>
<p><del class="diffmod">The manufacturer of</del><ins class="diffmod">For</ins> PEX tubing <del class="diffmod">shall have marked the outside of the tubing with the thermoplastic material designation code in accordance</del><ins class="diffmod">complying</ins> with ASTM F876<del class="diffmod">. The designation code</del><ins class="diffmod">, the first digit folllowing "PEX" as marked on the tubing exterior</ins> shall <del class="diffmod">consist</del><ins class="diffmod">be an indicator</ins> of the <del class="diffmod">abbreviation "</del><ins class="diffmod">maximum service temperatures for which the </ins>PEX<del class="diffmod">" followed by four digits</del><ins class="diffmod"> tubing can be used</ins>. The <del class="diffmod">first digit</del><ins class="diffmod">maximum service temperatures</ins> shall <del class="diffmod">represent a chlorine resistance rating</del><ins class="diffmod">be</ins> as <del class="diffmod">established by testing in accordance with ASTM F876</del><ins class="diffmod">follows:</ins><br / class="diffmod"><br /><ins class="diffmod">1</ins>.<ins class="diffins"> Digit “0”: 73⁰F (23⁰C). </ins><br / class="diffmod"><br /><ins class="diffins">2. Digit “1”: For not more that 25% of the time, greater than 73⁰F (23⁰C) and not exceeding140⁰F (60⁰C). For the remainder of the time, not greater than 73⁰F (23⁰C). </ins><br / class="diffmod"><br /><ins class="diffins">3. Digit “3”: For not more that 50% of the time, greater than 73⁰F (23⁰C) and not exceeding 140⁰F (60⁰C). For the remainder of the time, not greater than 73⁰F (23⁰C). </ins><br / class="diffmod"><br /><ins class="diffins">4. Digit “5”: 140⁰F (60⁰C). </ins><br / class="diffmod"><br /><br /></p> <p><del class="diffmod">The manufacturer of</del><ins class="diffmod">For</ins> PEX tubing <del class="diffmod">shall have marked the outside of the tubing with the thermoplastic material designation code in accordance</del><ins class="diffmod">complying</ins> with ASTM F876<del class="diffmod">. The designation code</del><ins class="diffmod">, the first digit folllowing "PEX" as marked on the tubing exterior</ins> shall <del class="diffmod">consist</del><ins class="diffmod">be an indicator</ins> of the <del class="diffmod">abbreviation "</del><ins class="diffmod">maximum service temperatures for which the </ins>PEX<del class="diffmod">" followed by four digits</del><ins class="diffmod"> tubing can be used</ins>. The <del class="diffmod">first digit</del><ins class="diffmod">maximum service temperatures</ins> shall <del class="diffmod">represent a chlorine resistance rating</del><ins class="diffmod">be</ins> as <del class="diffmod">established by testing in accordance with ASTM F876</del><ins class="diffmod">follows:</ins><br / class="diffmod"><br /><ins class="diffmod">1</ins>.<ins class="diffins"> Digit “0”: 73⁰F (23⁰C). </ins><br / class="diffmod"><br /><ins class="diffins">2. Digit “1”: For not more that 25% of the time, greater than 73⁰F (23⁰C) and not exceeding140⁰F (60⁰C). For the remainder of the time, not greater than 73⁰F (23⁰C). </ins><br / class="diffmod"><br /><ins class="diffins">3. Digit “3”: For not more that 50% of the time, greater than 73⁰F (23⁰C) and not exceeding 140⁰F (60⁰C). For the remainder of the time, not greater than 73⁰F (23⁰C). </ins><br / class="diffmod"><br /><ins class="diffins">4. Digit “5”: 140⁰F (60⁰C). </ins><br / class="diffmod"><br /><br /></p>
</expected> </expected>

@ -1,11 +1,11 @@
<oldText> <oldText>
<i>Existing buildings </i>that undergo a change of group or occupancy shall comply with this section.<ul class="exception"><li><b>Exception: </b>Type B dwelling or sleeping units required by Section 1107 of the <i>International Building Code </i>are not required to be provided in <i>existing buildings </i>and facilities undergoing a <i>change of occupancy </i>in conjunction with <i>alterations </i>where the <i>work area </i>is 50 percent or less of the aggregate area of the building.</li></ul> <i>Existing buildings </i>that undergo a change of group or occupancy shall comply with this section.<ul class="exception"><li><b>Exception: </b>Type B dwelling or sleeping units required by Section 1107 of the <i>International Building Code </i>are not required to be provided in <i>existing buildings </i>and facilities undergoing a <i>change of occupancy </i>in conjunction with <i>alterations </i>where the <i>work area </i>is 50 percent or less of the aggregate area of the building.</li></ul>
</oldText> </oldText>
<newText> <newText>
<em>Where existing buildings </em>undergo a change of group or occupancy any alterations shall comply with Sections 410.6, 410.7 and 410.8 as applicable. <em>Where existing buildings </em>undergo a change of group or occupancy any alterations shall comply with Sections 410.6, 410.7 and 410.8 as applicable.
</newText> </newText>
<expected> <expected>
<i class="diffmod"><del class="diffmod">Existing buildings </del></i><del class="diffmod">that </del><em class="diffmod"><ins class="diffmod">Where existing buildings </ins></em>undergo a change of group or occupancy <ins class="diffins">any alterations </ins>shall comply with <del class="diffmod">this section</del><ins class="diffmod">Sections 410.6, 410.7 and 410.8 as applicable</ins>.<ul class="diffmod exception"><li><b><del class="diffdel">Exception: </del></b><del class="diffdel">Type B dwelling or sleeping units required by Section 1107 of the </del><i class="diffmod"><del class="diffdel">International Building Code </del></i><del class="diffdel">are not required to be provided in </del><i class="diffmod"><del class="diffdel">existing buildings </del></i><del class="diffdel">and facilities undergoing a </del><i class="diffmod"><del class="diffdel">change of occupancy </del></i><del class="diffdel">in conjunction with </del><i class="diffmod"><del class="diffdel">alterations </del></i><del class="diffdel">where the </del><i class="diffmod"><del class="diffdel">work area </del></i><del class="diffdel">is 50 percent or less of the aggregate area of the building.</del></li></ul> <i class="diffmod"><del class="diffmod">Existing buildings </del></i><del class="diffmod">that </del><em class="diffmod"><ins class="diffmod">Where existing buildings </ins></em>undergo a change of group or occupancy <ins class="diffins">any alterations </ins>shall comply with <del class="diffmod">this section</del><ins class="diffmod">Sections 410.6, 410.7 and 410.8 as applicable</ins>.<ul class="diffmod exception"><li><b><del class="diffdel">Exception: </del></b><del class="diffdel">Type B dwelling or sleeping units required by Section 1107 of the </del><i class="diffmod"><del class="diffdel">International Building Code </del></i><del class="diffdel">are not required to be provided in </del><i class="diffmod"><del class="diffdel">existing buildings </del></i><del class="diffdel">and facilities undergoing a </del><i class="diffmod"><del class="diffdel">change of occupancy </del></i><del class="diffdel">in conjunction with </del><i class="diffmod"><del class="diffdel">alterations </del></i><del class="diffdel">where the </del><i class="diffmod"><del class="diffdel">work area </del></i><del class="diffdel">is 50 percent or less of the aggregate area of the building.</del></li></ul>
</expected> </expected>

@ -1,9 +1,9 @@
CREDITS CREDITS
Almost everything written by Edward Z. Yang (Ambush Commander). Lots of thanks Almost everything written by Edward Z. Yang (Ambush Commander). Lots of thanks
to the DevNetwork Community for their help (see docs/ref-devnetwork.html for to the DevNetwork Community for their help (see docs/ref-devnetwork.html for
more details), Feyd especially (namely IPv6 and optimization). Thanks to RSnake more details), Feyd especially (namely IPv6 and optimization). Thanks to RSnake
for letting me package his fantastic XSS cheatsheet for a smoketest. for letting me package his fantastic XSS cheatsheet for a smoketest.
vim: et sw=4 sts=4 vim: et sw=4 sts=4

@ -1,374 +1,374 @@
Install Install
How to install HTML Purifier How to install HTML Purifier
HTML Purifier is designed to run out of the box, so actually using the 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 library is extremely easy. (Although... if you were looking for a
step-by-step installation GUI, you've downloaded the wrong software!) step-by-step installation GUI, you've downloaded the wrong software!)
While the impatient can get going immediately with some of the sample While the impatient can get going immediately with some of the sample
code at the bottom of this library, it's well worth reading this entire code at the bottom of this library, it's well worth reading this entire
document--most of the other documentation assumes that you are familiar document--most of the other documentation assumes that you are familiar
with these contents. with these contents.
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
1. Compatibility 1. Compatibility
HTML Purifier is PHP 5 only, and is actively tested from PHP 5.0.5 and 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 up. It has no core dependencies with other libraries. PHP
4 support was deprecated on December 31, 2007 with HTML Purifier 3.0.0. 4 support was deprecated on December 31, 2007 with HTML Purifier 3.0.0.
HTML Purifier is not compatible with zend.ze1_compatibility_mode. HTML Purifier is not compatible with zend.ze1_compatibility_mode.
These optional extensions can enhance the capabilities of HTML Purifier: These optional extensions can enhance the capabilities of HTML Purifier:
* iconv : Converts text to and from non-UTF-8 encodings * iconv : Converts text to and from non-UTF-8 encodings
* bcmath : Used for unit conversion and imagecrash protection * bcmath : Used for unit conversion and imagecrash protection
* tidy : Used for pretty-printing HTML * tidy : Used for pretty-printing HTML
These optional libraries can enhance the capabilities of HTML Purifier: These optional libraries can enhance the capabilities of HTML Purifier:
* CSSTidy : Clean CSS stylesheets using %Core.ExtractStyleBlocks * CSSTidy : Clean CSS stylesheets using %Core.ExtractStyleBlocks
* Net_IDNA2 (PEAR) : IRI support using %Core.EnableIDNA * Net_IDNA2 (PEAR) : IRI support using %Core.EnableIDNA
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
2. Reconnaissance 2. Reconnaissance
A big plus of HTML Purifier is its inerrant support of standards, so A big plus of HTML Purifier is its inerrant support of standards, so
your web-pages should be standards-compliant. (They should also use your web-pages should be standards-compliant. (They should also use
semantic markup, but that's another issue altogether, one HTML Purifier semantic markup, but that's another issue altogether, one HTML Purifier
cannot fix without reading your mind.) cannot fix without reading your mind.)
HTML Purifier can process these doctypes: HTML Purifier can process these doctypes:
* XHTML 1.0 Transitional (default) * XHTML 1.0 Transitional (default)
* XHTML 1.0 Strict * XHTML 1.0 Strict
* HTML 4.01 Transitional * HTML 4.01 Transitional
* HTML 4.01 Strict * HTML 4.01 Strict
* XHTML 1.1 * XHTML 1.1
...and these character encodings: ...and these character encodings:
* UTF-8 (default) * UTF-8 (default)
* Any encoding iconv supports (with crippled internationalization support) * Any encoding iconv supports (with crippled internationalization support)
These defaults reflect what my choices would be if I were authoring an These defaults reflect what my choices would be if I were authoring an
HTML document, however, what you choose depends on the nature of your HTML document, however, what you choose depends on the nature of your
codebase. If you don't know what doctype you are using, you can determine codebase. If you don't know what doctype you are using, you can determine
the doctype from this identifier at the top of your source code: the doctype from this identifier at the top of your source code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
...and the character encoding from this code: ...and the character encoding from this code:
<meta http-equiv="Content-type" content="text/html;charset=ENCODING"> <meta http-equiv="Content-type" content="text/html;charset=ENCODING">
If the character encoding declaration is missing, STOP NOW, and If the character encoding declaration is missing, STOP NOW, and
read 'docs/enduser-utf8.html' (web accessible at read 'docs/enduser-utf8.html' (web accessible at
http://htmlpurifier.org/docs/enduser-utf8.html). In fact, even if it is http://htmlpurifier.org/docs/enduser-utf8.html). In fact, even if it is
present, read this document anyway, as many websites specify their present, read this document anyway, as many websites specify their
document's character encoding incorrectly. document's character encoding incorrectly.
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
3. Including the library 3. Including the library
The procedure is quite simple: The procedure is quite simple:
require_once '/path/to/library/HTMLPurifier.auto.php'; require_once '/path/to/library/HTMLPurifier.auto.php';
This will setup an autoloader, so the library's files are only included This will setup an autoloader, so the library's files are only included
when you use them. when you use them.
Only the contents in the library/ folder are necessary, so you can remove Only the contents in the library/ folder are necessary, so you can remove
everything else when using HTML Purifier in a production environment. everything else when using HTML Purifier in a production environment.
If you installed HTML Purifier via PEAR, all you need to do is: If you installed HTML Purifier via PEAR, all you need to do is:
require_once 'HTMLPurifier.auto.php'; require_once 'HTMLPurifier.auto.php';
Please note that the usual PEAR practice of including just the classes you Please note that the usual PEAR practice of including just the classes you
want will not work with HTML Purifier's autoloading scheme. want will not work with HTML Purifier's autoloading scheme.
Advanced users, read on; other users can skip to section 4. Advanced users, read on; other users can skip to section 4.
Autoload compatibility Autoload compatibility
---------------------- ----------------------
HTML Purifier attempts to be as smart as possible when registering an HTML Purifier attempts to be as smart as possible when registering an
autoloader, but there are some cases where you will need to change autoloader, but there are some cases where you will need to change
your own code to accomodate HTML Purifier. These are those cases: your own code to accomodate HTML Purifier. These are those cases:
PHP VERSION IS LESS THAN 5.1.2, AND YOU'VE DEFINED __autoload PHP VERSION IS LESS THAN 5.1.2, AND YOU'VE DEFINED __autoload
Because spl_autoload_register() doesn't exist in early versions Because spl_autoload_register() doesn't exist in early versions
of PHP 5, HTML Purifier has no way of adding itself to the autoload of PHP 5, HTML Purifier has no way of adding itself to the autoload
stack. Modify your __autoload function to test stack. Modify your __autoload function to test
HTMLPurifier_Bootstrap::autoload($class) HTMLPurifier_Bootstrap::autoload($class)
For example, suppose your autoload function looks like this: For example, suppose your autoload function looks like this:
function __autoload($class) { function __autoload($class) {
require str_replace('_', '/', $class) . '.php'; require str_replace('_', '/', $class) . '.php';
return true; return true;
} }
A modified version with HTML Purifier would look like this: A modified version with HTML Purifier would look like this:
function __autoload($class) { function __autoload($class) {
if (HTMLPurifier_Bootstrap::autoload($class)) return true; if (HTMLPurifier_Bootstrap::autoload($class)) return true;
require str_replace('_', '/', $class) . '.php'; require str_replace('_', '/', $class) . '.php';
return true; return true;
} }
Note that there *is* some custom behavior in our autoloader; the Note that there *is* some custom behavior in our autoloader; the
original autoloader in our example would work for 99% of the time, original autoloader in our example would work for 99% of the time,
but would fail when including language files. but would fail when including language files.
AN __autoload FUNCTION IS DECLARED AFTER OUR AUTOLOADER IS REGISTERED AN __autoload FUNCTION IS DECLARED AFTER OUR AUTOLOADER IS REGISTERED
spl_autoload_register() has the curious behavior of disabling spl_autoload_register() has the curious behavior of disabling
the existing __autoload() handler. Users need to explicitly the existing __autoload() handler. Users need to explicitly
spl_autoload_register('__autoload'). Because we use SPL when it spl_autoload_register('__autoload'). Because we use SPL when it
is available, __autoload() will ALWAYS be disabled. If __autoload() is available, __autoload() will ALWAYS be disabled. If __autoload()
is declared before HTML Purifier is loaded, this is not a problem: is declared before HTML Purifier is loaded, this is not a problem:
HTML Purifier will register the function for you. But if it is HTML Purifier will register the function for you. But if it is
declared afterwards, it will mysteriously not work. This declared afterwards, it will mysteriously not work. This
snippet of code (after your autoloader is defined) will fix it: snippet of code (after your autoloader is defined) will fix it:
spl_autoload_register('__autoload') spl_autoload_register('__autoload')
Users should also be on guard if they use a version of PHP previous 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() 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* for you, which can collide with an autoloader that was added by *you*
later. later.
For better performance For better performance
---------------------- ----------------------
Opcode caches, which greatly speed up PHP initialization for scripts Opcode caches, which greatly speed up PHP initialization for scripts
with large amounts of code (HTML Purifier included), don't like with large amounts of code (HTML Purifier included), don't like
autoloaders. We offer an include file that includes all of HTML Purifier's autoloaders. We offer an include file that includes all of HTML Purifier's
files in one go in an opcode cache friendly manner: files in one go in an opcode cache friendly manner:
// If /path/to/library isn't already in your include path, uncomment // If /path/to/library isn't already in your include path, uncomment
// the below line: // the below line:
// require '/path/to/library/HTMLPurifier.path.php'; // require '/path/to/library/HTMLPurifier.path.php';
require 'HTMLPurifier.includes.php'; require 'HTMLPurifier.includes.php';
Optional components still need to be included--you'll know if you try to 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 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 can be used in conjunction with this approach to catch classes that are
missing. Simply add this afterwards: missing. Simply add this afterwards:
require 'HTMLPurifier.autoload.php'; require 'HTMLPurifier.autoload.php';
Standalone version Standalone version
------------------ ------------------
HTML Purifier has a standalone distribution; you can also generate HTML Purifier has a standalone distribution; you can also generate
a standalone file from the full version by running the script a standalone file from the full version by running the script
maintenance/generate-standalone.php . The standalone version has the maintenance/generate-standalone.php . The standalone version has the
benefit of having most of its code in one file, so parsing is much benefit of having most of its code in one file, so parsing is much
faster and the library is easier to manage. faster and the library is easier to manage.
If HTMLPurifier.standalone.php exists in the library directory, you If HTMLPurifier.standalone.php exists in the library directory, you
can use it like this: can use it like this:
require '/path/to/HTMLPurifier.standalone.php'; require '/path/to/HTMLPurifier.standalone.php';
This is equivalent to including HTMLPurifier.includes.php, except that This is equivalent to including HTMLPurifier.includes.php, except that
the contents of standalone/ will be added to your path. To override this the contents of standalone/ will be added to your path. To override this
behavior, specify a new HTMLPURIFIER_PREFIX where standalone files can behavior, specify a new HTMLPURIFIER_PREFIX where standalone files can
be found (usually, this will be one directory up, the "true" library be found (usually, this will be one directory up, the "true" library
directory in full distributions). Don't forget to set your path too! 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 The autoloader can be added to the end to ensure the classes are
loaded when necessary; otherwise you can manually include them. loaded when necessary; otherwise you can manually include them.
To use the autoloader, use this: To use the autoloader, use this:
require 'HTMLPurifier.autoload.php'; require 'HTMLPurifier.autoload.php';
For advanced users For advanced users
------------------ ------------------
HTMLPurifier.auto.php performs a number of operations that can be done HTMLPurifier.auto.php performs a number of operations that can be done
individually. These are: individually. These are:
HTMLPurifier.path.php HTMLPurifier.path.php
Puts /path/to/library in the include path. For high performance, Puts /path/to/library in the include path. For high performance,
this should be done in php.ini. this should be done in php.ini.
HTMLPurifier.autoload.php HTMLPurifier.autoload.php
Registers our autoload handler HTMLPurifier_Bootstrap::autoload($class). Registers our autoload handler HTMLPurifier_Bootstrap::autoload($class).
You can do these operations by yourself--in fact, you must modify your own 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 autoload handler if you are using a version of PHP earlier than PHP 5.1.2
(See "Autoload compatibility" above). (See "Autoload compatibility" above).
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
4. Configuration 4. Configuration
HTML Purifier is designed to run out-of-the-box, but occasionally HTML HTML Purifier is designed to run out-of-the-box, but occasionally HTML
Purifier needs to be told what to do. If you answer no to any of these Purifier needs to be told what to do. If you answer no to any of these
questions, read on; otherwise, you can skip to the next section (or, if you're questions, read on; otherwise, you can skip to the next section (or, if you're
into configuring things just for the heck of it, skip to 4.3). into configuring things just for the heck of it, skip to 4.3).
* Am I using UTF-8? * Am I using UTF-8?
* Am I using XHTML 1.0 Transitional? * Am I using XHTML 1.0 Transitional?
If you answered no to any of these questions, instantiate a configuration If you answered no to any of these questions, instantiate a configuration
object and read on: object and read on:
$config = HTMLPurifier_Config::createDefault(); $config = HTMLPurifier_Config::createDefault();
4.1. Setting a different character encoding 4.1. Setting a different character encoding
You really shouldn't use any other encoding except UTF-8, especially if you You really shouldn't use any other encoding except UTF-8, especially if you
plan to support multilingual websites (read section three for more details). plan to support multilingual websites (read section three for more details).
However, switching to UTF-8 is not always immediately feasible, so we can However, switching to UTF-8 is not always immediately feasible, so we can
adapt. adapt.
HTML Purifier uses iconv to support other character encodings, as such, HTML Purifier uses iconv to support other character encodings, as such,
any encoding that iconv supports <http://www.gnu.org/software/libiconv/> any encoding that iconv supports <http://www.gnu.org/software/libiconv/>
HTML Purifier supports with this code: HTML Purifier supports with this code:
$config->set('Core.Encoding', /* put your encoding here */); $config->set('Core.Encoding', /* put your encoding here */);
An example usage for Latin-1 websites (the most common encoding for English An example usage for Latin-1 websites (the most common encoding for English
websites): websites):
$config->set('Core.Encoding', 'ISO-8859-1'); $config->set('Core.Encoding', 'ISO-8859-1');
Note that HTML Purifier's support for non-Unicode encodings is crippled by the Note that HTML Purifier's support for non-Unicode encodings is crippled by the
fact that any character not supported by that encoding will be silently fact that any character not supported by that encoding will be silently
dropped, EVEN if it is ampersand escaped. If you want to work around dropped, EVEN if it is ampersand escaped. If you want to work around
this, you are welcome to read docs/enduser-utf8.html for a fix, this, you are welcome to read docs/enduser-utf8.html for a fix,
but please be cognizant of the issues the "solution" creates (for this but please be cognizant of the issues the "solution" creates (for this
reason, I do not include the solution in this document). reason, I do not include the solution in this document).
4.2. Setting a different doctype 4.2. Setting a different doctype
For those of you using HTML 4.01 Transitional, you can disable For those of you using HTML 4.01 Transitional, you can disable
XHTML output like this: XHTML output like this:
$config->set('HTML.Doctype', 'HTML 4.01 Transitional'); $config->set('HTML.Doctype', 'HTML 4.01 Transitional');
Other supported doctypes include: Other supported doctypes include:
* HTML 4.01 Strict * HTML 4.01 Strict
* HTML 4.01 Transitional * HTML 4.01 Transitional
* XHTML 1.0 Strict * XHTML 1.0 Strict
* XHTML 1.0 Transitional * XHTML 1.0 Transitional
* XHTML 1.1 * XHTML 1.1
4.3. Other settings 4.3. Other settings
There are more configuration directives which can be read about There are more configuration directives which can be read about
here: <http://htmlpurifier.org/live/configdoc/plain.html> They're a bit boring, here: <http://htmlpurifier.org/live/configdoc/plain.html> They're a bit boring,
but they can help out for those of you who like to exert maximum control over but they can help out for those of you who like to exert maximum control over
your code. Some of the more interesting ones are configurable at the your code. Some of the more interesting ones are configurable at the
demo <http://htmlpurifier.org/demo.php> and are well worth looking into demo <http://htmlpurifier.org/demo.php> and are well worth looking into
for your own system. for your own system.
For example, you can fine tune allowed elements and attributes, convert For example, you can fine tune allowed elements and attributes, convert
relative URLs to absolute ones, and even autoparagraph input text! These relative URLs to absolute ones, and even autoparagraph input text! These
are, respectively, %HTML.Allowed, %URI.MakeAbsolute and %URI.Base, and are, respectively, %HTML.Allowed, %URI.MakeAbsolute and %URI.Base, and
%AutoFormat.AutoParagraph. The %Namespace.Directive naming convention %AutoFormat.AutoParagraph. The %Namespace.Directive naming convention
translates to: translates to:
$config->set('Namespace.Directive', $value); $config->set('Namespace.Directive', $value);
E.g. E.g.
$config->set('HTML.Allowed', 'p,b,a[href],i'); $config->set('HTML.Allowed', 'p,b,a[href],i');
$config->set('URI.Base', 'http://www.example.com'); $config->set('URI.Base', 'http://www.example.com');
$config->set('URI.MakeAbsolute', true); $config->set('URI.MakeAbsolute', true);
$config->set('AutoFormat.AutoParagraph', true); $config->set('AutoFormat.AutoParagraph', true);
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
5. Caching 5. Caching
HTML Purifier generates some cache files (generally one or two) to speed up HTML Purifier generates some cache files (generally one or two) to speed up
its execution. For maximum performance, make sure that its execution. For maximum performance, make sure that
library/HTMLPurifier/DefinitionCache/Serializer is writeable by the webserver. library/HTMLPurifier/DefinitionCache/Serializer is writeable by the webserver.
If you are in the library/ folder of HTML Purifier, you can set the If you are in the library/ folder of HTML Purifier, you can set the
appropriate permissions using: appropriate permissions using:
chmod -R 0755 HTMLPurifier/DefinitionCache/Serializer chmod -R 0755 HTMLPurifier/DefinitionCache/Serializer
If the above command doesn't work, you may need to assign write permissions If the above command doesn't work, you may need to assign write permissions
to all. This may be necessary if your webserver runs as nobody, but is to all. This may be necessary if your webserver runs as nobody, but is
not recommended since it means any other user can write files in the not recommended since it means any other user can write files in the
directory. Use: directory. Use:
chmod -R 0777 HTMLPurifier/DefinitionCache/Serializer chmod -R 0777 HTMLPurifier/DefinitionCache/Serializer
You can also chmod files via your FTP client; this option You can also chmod files via your FTP client; this option
is usually accessible by right clicking the corresponding directory and is usually accessible by right clicking the corresponding directory and
then selecting "chmod" or "file permissions". then selecting "chmod" or "file permissions".
Starting with 2.0.1, HTML Purifier will generate friendly error messages Starting with 2.0.1, HTML Purifier will generate friendly error messages
that will tell you exactly what you have to chmod the directory to, if in doubt, that will tell you exactly what you have to chmod the directory to, if in doubt,
follow its advice. follow its advice.
If you are unable or unwilling to give write permissions to the cache If you are unable or unwilling to give write permissions to the cache
directory, you can either disable the cache (and suffer a performance directory, you can either disable the cache (and suffer a performance
hit): hit):
$config->set('Core.DefinitionCache', null); $config->set('Core.DefinitionCache', null);
Or move the cache directory somewhere else (no trailing slash): Or move the cache directory somewhere else (no trailing slash):
$config->set('Cache.SerializerPath', '/home/user/absolute/path'); $config->set('Cache.SerializerPath', '/home/user/absolute/path');
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
6. Using the code 6. Using the code
The interface is mind-numbingly simple: The interface is mind-numbingly simple:
$purifier = new HTMLPurifier($config); $purifier = new HTMLPurifier($config);
$clean_html = $purifier->purify( $dirty_html ); $clean_html = $purifier->purify( $dirty_html );
That's it! For more examples, check out docs/examples/ (they aren't very That's it! For more examples, check out docs/examples/ (they aren't very
different though). Also, docs/enduser-slow.html gives advice on what to different though). Also, docs/enduser-slow.html gives advice on what to
do if HTML Purifier is slowing down your application. do if HTML Purifier is slowing down your application.
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
7. Quick install 7. Quick install
First, make sure library/HTMLPurifier/DefinitionCache/Serializer is First, make sure library/HTMLPurifier/DefinitionCache/Serializer is
writable by the webserver (see Section 5: Caching above for details). writable by the webserver (see Section 5: Caching above for details).
If your website is in UTF-8 and XHTML Transitional, use this code: If your website is in UTF-8 and XHTML Transitional, use this code:
<?php <?php
require_once '/path/to/htmlpurifier/library/HTMLPurifier.auto.php'; require_once '/path/to/htmlpurifier/library/HTMLPurifier.auto.php';
$config = HTMLPurifier_Config::createDefault(); $config = HTMLPurifier_Config::createDefault();
$purifier = new HTMLPurifier($config); $purifier = new HTMLPurifier($config);
$clean_html = $purifier->purify($dirty_html); $clean_html = $purifier->purify($dirty_html);
?> ?>
If your website is in a different encoding or doctype, use this code: If your website is in a different encoding or doctype, use this code:
<?php <?php
require_once '/path/to/htmlpurifier/library/HTMLPurifier.auto.php'; require_once '/path/to/htmlpurifier/library/HTMLPurifier.auto.php';
$config = HTMLPurifier_Config::createDefault(); $config = HTMLPurifier_Config::createDefault();
$config->set('Core.Encoding', 'ISO-8859-1'); // replace with your encoding $config->set('Core.Encoding', 'ISO-8859-1'); // replace with your encoding
$config->set('HTML.Doctype', 'HTML 4.01 Transitional'); // replace with your doctype $config->set('HTML.Doctype', 'HTML 4.01 Transitional'); // replace with your doctype
$purifier = new HTMLPurifier($config); $purifier = new HTMLPurifier($config);
$clean_html = $purifier->purify($dirty_html); $clean_html = $purifier->purify($dirty_html);
?> ?>
vim: et sw=4 sts=4 vim: et sw=4 sts=4

@ -1,60 +1,60 @@
 
Installation Installation
Comment installer HTML Purifier Comment installer HTML Purifier
Attention : Ce document est encodé en UTF-8, si les lettres avec des accents Attention : Ce document est encodé en UTF-8, si les lettres avec des accents
ne s'affichent pas, prenez un meilleur éditeur de texte. ne s'affichent pas, prenez un meilleur éditeur de texte.
L'installation de HTML Purifier est très simple, parce qu'il n'a pas besoin L'installation de HTML Purifier est très simple, parce qu'il n'a pas besoin
de configuration. Pour les utilisateurs impatients, le code se trouve dans le de configuration. Pour les utilisateurs impatients, le code se trouve dans le
pied de page, mais je recommande de lire le document. pied de page, mais je recommande de lire le document.
1. Compatibilité 1. Compatibilité
HTML Purifier fonctionne avec PHP 5. PHP 5.0.5 est la dernière version testée. HTML Purifier fonctionne avec PHP 5. PHP 5.0.5 est la dernière version testée.
Il ne dépend pas d'autres librairies. Il ne dépend pas d'autres librairies.
Les extensions optionnelles sont iconv (généralement déjà installée) et tidy Les extensions optionnelles sont iconv (généralement déjà installée) et tidy
(répendue aussi). Si vous utilisez UTF-8 et que vous ne voulez pas l'indentation, (répendue aussi). Si vous utilisez UTF-8 et que vous ne voulez pas l'indentation,
vous pouvez utiliser HTML Purifier sans ces extensions. vous pouvez utiliser HTML Purifier sans ces extensions.
2. Inclure la librairie 2. Inclure la librairie
Quand vous devez l'utilisez, incluez le : Quand vous devez l'utilisez, incluez le :
require_once('/path/to/library/HTMLPurifier.auto.php'); require_once('/path/to/library/HTMLPurifier.auto.php');
Ne pas l'inclure si ce n'est pas nécessaire, car HTML Purifier est lourd. Ne pas l'inclure si ce n'est pas nécessaire, car HTML Purifier est lourd.
HTML Purifier utilise "autoload". Si vous avez défini la fonction __autoload, HTML Purifier utilise "autoload". Si vous avez défini la fonction __autoload,
vous devez ajouter cette fonction : vous devez ajouter cette fonction :
spl_autoload_register('__autoload') spl_autoload_register('__autoload')
Plus d'informations dans le document "INSTALL". Plus d'informations dans le document "INSTALL".
3. Installation rapide 3. Installation rapide
Si votre site Web est en UTF-8 et XHTML Transitional, utilisez : Si votre site Web est en UTF-8 et XHTML Transitional, utilisez :
<?php <?php
require_once('/path/to/htmlpurifier/library/HTMLPurifier.auto.php'); require_once('/path/to/htmlpurifier/library/HTMLPurifier.auto.php');
$purificateur = new HTMLPurifier(); $purificateur = new HTMLPurifier();
$html_propre = $purificateur->purify($html_a_purifier); $html_propre = $purificateur->purify($html_a_purifier);
?> ?>
Sinon, utilisez : Sinon, utilisez :
<?php <?php
require_once('/path/to/html/purifier/library/HTMLPurifier.auto.load'); require_once('/path/to/html/purifier/library/HTMLPurifier.auto.load');
$config = $HTMLPurifier_Config::createDefault(); $config = $HTMLPurifier_Config::createDefault();
$config->set('Core', 'Encoding', 'ISO-8859-1'); //Remplacez par votre $config->set('Core', 'Encoding', 'ISO-8859-1'); //Remplacez par votre
encodage encodage
$config->set('Core', 'XHTML', true); //Remplacer par false si HTML 4.01 $config->set('Core', 'XHTML', true); //Remplacer par false si HTML 4.01
$purificateur = new HTMLPurifier($config); $purificateur = new HTMLPurifier($config);
$html_propre = $purificateur->purify($html_a_purifier); $html_propre = $purificateur->purify($html_a_purifier);
?> ?>
vim: et sw=4 sts=4 vim: et sw=4 sts=4

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -1,24 +1,24 @@
README README
All about HTML Purifier All about HTML Purifier
HTML Purifier is an HTML filtering solution that uses a unique combination HTML Purifier is an HTML filtering solution that uses a unique combination
of robust whitelists and agressive parsing to ensure that not only are of robust whitelists and agressive parsing to ensure that not only are
XSS attacks thwarted, but the resulting HTML is standards compliant. XSS attacks thwarted, but the resulting HTML is standards compliant.
HTML Purifier is oriented towards richly formatted documents from HTML Purifier is oriented towards richly formatted documents from
untrusted sources that require CSS and a full tag-set. This library can 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 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 as efficient as more bare-bones parsers. It will, however, do the job
right, which may be more important. right, which may be more important.
Places to go: Places to go:
* See INSTALL for a quick installation guide * See INSTALL for a quick installation guide
* See docs/ for developer-oriented documentation, code examples and * See docs/ for developer-oriented documentation, code examples and
an in-depth installation guide. an in-depth installation guide.
* See WYSIWYG for information on editors like TinyMCE and FCKeditor * See WYSIWYG for information on editors like TinyMCE and FCKeditor
HTML Purifier can be found on the web at: http://htmlpurifier.org/ HTML Purifier can be found on the web at: http://htmlpurifier.org/
vim: et sw=4 sts=4 vim: et sw=4 sts=4

@ -1,150 +1,150 @@
TODO List TODO List
= KEY ==================== = KEY ====================
# Flagship # Flagship
- Regular - Regular
? Maybe I'll Do It ? Maybe I'll Do It
========================== ==========================
If no interest is expressed for a feature that may require a considerable If no interest is expressed for a feature that may require a considerable
amount of effort to implement, it may get endlessly delayed. Do not be amount of effort to implement, it may get endlessly delayed. Do not be
afraid to cast your vote for the next feature to be implemented! afraid to cast your vote for the next feature to be implemented!
Things to do as soon as possible: Things to do as soon as possible:
- http://htmlpurifier.org/phorum/read.php?3,5560,6307#msg-6307 - http://htmlpurifier.org/phorum/read.php?3,5560,6307#msg-6307
- Think about allowing explicit order of operations hooks for transforms - Think about allowing explicit order of operations hooks for transforms
- Fix "<.<" bug (trailing < is removed if not EOD) - Fix "<.<" bug (trailing < is removed if not EOD)
- Build in better internal state dumps and debugging tools for remote - Build in better internal state dumps and debugging tools for remote
debugging debugging
- Allowed/Allowed* have strange interactions when both set - Allowed/Allowed* have strange interactions when both set
? Transform lone embeds into object tags ? Transform lone embeds into object tags
- Deprecated config options that emit warnings when you set them (with' - Deprecated config options that emit warnings when you set them (with'
a way of muting the warning if you really want to) a way of muting the warning if you really want to)
- Make HTML.Trusted work with Output.FlashCompat - Make HTML.Trusted work with Output.FlashCompat
- HTML.Trusted and HTML.SafeObject have funny interaction; general - HTML.Trusted and HTML.SafeObject have funny interaction; general
problem is what to do when a module "supersedes" another problem is what to do when a module "supersedes" another
(see also tables and basic tables.) This is a little dicier (see also tables and basic tables.) This is a little dicier
because HTML.SafeObject has some extra functionality that because HTML.SafeObject has some extra functionality that
trusted might find useful. See http://htmlpurifier.org/phorum/read.php?3,5762,6100 trusted might find useful. See http://htmlpurifier.org/phorum/read.php?3,5762,6100
FUTURE VERSIONS FUTURE VERSIONS
--------------- ---------------
4.8 release [OMG CONFIG PONIES] 4.8 release [OMG CONFIG PONIES]
! Fix Printer. It's from the old days when we didn't have decent XML classes ! Fix Printer. It's from the old days when we didn't have decent XML classes
! Factor demo.php into a set of Printer classes, and then create a stub ! Factor demo.php into a set of Printer classes, and then create a stub
file for users here (inside the actual HTML Purifier library) file for users here (inside the actual HTML Purifier library)
- Fix error handling with form construction - Fix error handling with form construction
- Do encoding validation in Printers, or at least, where user data comes in - Do encoding validation in Printers, or at least, where user data comes in
- Config: Add examples to everything (make built-in which also automatically - Config: Add examples to everything (make built-in which also automatically
gives output) gives output)
- Add "register" field to config schemas to eliminate dependence on - Add "register" field to config schemas to eliminate dependence on
naming conventions (try to remember why we ultimately decided on tihs) naming conventions (try to remember why we ultimately decided on tihs)
5.0 release [HTML 5] 5.0 release [HTML 5]
# Swap out code to use html5lib tokenizer and tree-builder # Swap out code to use html5lib tokenizer and tree-builder
! Allow turning off of FixNesting and required attribute insertion ! Allow turning off of FixNesting and required attribute insertion
5.1 release [It's All About Trust] (floating) 5.1 release [It's All About Trust] (floating)
# Implement untrusted, dangerous elements/attributes # Implement untrusted, dangerous elements/attributes
# Implement IDREF support (harder than it seems, since you cannot have # Implement IDREF support (harder than it seems, since you cannot have
IDREFs to non-existent IDs) IDREFs to non-existent IDs)
- Implement <area> (client and server side image maps are blocking - Implement <area> (client and server side image maps are blocking
on IDREF support) on IDREF support)
# Frameset XHTML 1.0 and HTML 4.01 doctypes # Frameset XHTML 1.0 and HTML 4.01 doctypes
- Figure out how to simultaneously set %CSS.Trusted and %HTML.Trusted (?) - Figure out how to simultaneously set %CSS.Trusted and %HTML.Trusted (?)
5.2 release [Error'ed] 5.2 release [Error'ed]
# Error logging for filtering/cleanup procedures # Error logging for filtering/cleanup procedures
# Additional support for poorly written HTML # Additional support for poorly written HTML
- Microsoft Word HTML cleaning (i.e. MsoNormal, but research essential!) - Microsoft Word HTML cleaning (i.e. MsoNormal, but research essential!)
- Friendly strict handling of <address> (block -> <br>) - Friendly strict handling of <address> (block -> <br>)
- XSS-attempt detection--certain errors are flagged XSS-like - XSS-attempt detection--certain errors are flagged XSS-like
- Append something to duplicate IDs so they're still usable (impl. note: the - Append something to duplicate IDs so they're still usable (impl. note: the
dupe detector would also need to detect the suffix as well) dupe detector would also need to detect the suffix as well)
6.0 release [Beyond HTML] 6.0 release [Beyond HTML]
# Legit token based CSS parsing (will require revamping almost every # Legit token based CSS parsing (will require revamping almost every
AttrDef class). Probably will use CSSTidy AttrDef class). Probably will use CSSTidy
# More control over allowed CSS properties using a modularization # More control over allowed CSS properties using a modularization
# IRI support (this includes IDN) # IRI support (this includes IDN)
- Standardize token armor for all areas of processing - Standardize token armor for all areas of processing
7.0 release [To XML and Beyond] 7.0 release [To XML and Beyond]
- Extended HTML capabilities based on namespacing and tag transforms (COMPLEX) - Extended HTML capabilities based on namespacing and tag transforms (COMPLEX)
- Hooks for adding custom processors to custom namespaced tags and - Hooks for adding custom processors to custom namespaced tags and
attributes, offer default implementation attributes, offer default implementation
- Lots of documentation and samples - Lots of documentation and samples
Ongoing 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 - Refactor unit tests into lots of test methods
- Plugins for major CMSes (COMPLEX) - Plugins for major CMSes (COMPLEX)
- phpBB - phpBB
- Also, a FAQ for extension writers with HTML Purifier - Also, a FAQ for extension writers with HTML Purifier
AutoFormat AutoFormat
- Smileys - Smileys
- Syntax highlighting (with GeSHi) with <pre> and possibly <?php - Syntax highlighting (with GeSHi) with <pre> and possibly <?php
- Look at http://drupal.org/project/Modules/category/63 for ideas - Look at http://drupal.org/project/Modules/category/63 for ideas
Neat feature related Neat feature related
! Support exporting configuration, so users can easily tweak settings ! Support exporting configuration, so users can easily tweak settings
in the demo, and then copy-paste into their own setup in the demo, and then copy-paste into their own setup
- Advanced URI filtering schemes (see docs/proposal-new-directives.txt) - Advanced URI filtering schemes (see docs/proposal-new-directives.txt)
- Allow scoped="scoped" attribute in <style> tags; may be troublesome - Allow scoped="scoped" attribute in <style> tags; may be troublesome
because regular CSS has no way of uniquely identifying nodes, so we'd because regular CSS has no way of uniquely identifying nodes, so we'd
have to generate IDs have to generate IDs
- Explain how to use HTML Purifier in non-PHP languages / create - Explain how to use HTML Purifier in non-PHP languages / create
a simple command line stub (or complicated?) a simple command line stub (or complicated?)
- Fixes for Firefox's inability to handle COL alignment props (Bug 915) - Fixes for Firefox's inability to handle COL alignment props (Bug 915)
- Automatically add non-breaking spaces to empty table cells when - Automatically add non-breaking spaces to empty table cells when
empty-cells:show is applied to have compatibility with Internet Explorer empty-cells:show is applied to have compatibility with Internet Explorer
- Table of Contents generation (XHTML Compiler might be reusable). May also - Table of Contents generation (XHTML Compiler might be reusable). May also
be out-of-band information. be out-of-band information.
- Full set of color keywords. Also, a way to add onto them without - Full set of color keywords. Also, a way to add onto them without
finalizing the configuration object. finalizing the configuration object.
- Write a var_export and memcached DefinitionCache - Denis - Write a var_export and memcached DefinitionCache - Denis
- Built-in support for target="_blank" on all external links - Built-in support for target="_blank" on all external links
- Convert RTL/LTR override characters to <bdo> tags, or vice versa on demand. - Convert RTL/LTR override characters to <bdo> tags, or vice versa on demand.
Also, enable disabling of directionality Also, enable disabling of directionality
? Externalize inline CSS to promote clean HTML, proposed by Sander Tekelenburg ? Externalize inline CSS to promote clean HTML, proposed by Sander Tekelenburg
? Remove redundant tags, ex. <u><u>Underlined</u></u>. Implementation notes: ? Remove redundant tags, ex. <u><u>Underlined</u></u>. Implementation notes:
1. Analyzing which tags to remove duplicants 1. Analyzing which tags to remove duplicants
2. Ensure attributes are merged into the parent tag 2. Ensure attributes are merged into the parent tag
3. Extend the tag exclusion system to specify whether or not the 3. Extend the tag exclusion system to specify whether or not the
contents should be dropped or not (currently, there's code that could do contents should be dropped or not (currently, there's code that could do
something like this if it didn't drop the inner text too.) something like this if it didn't drop the inner text too.)
? Make AutoParagraph also support paragraph-izing double <br> tags, and not ? Make AutoParagraph also support paragraph-izing double <br> tags, and not
just double newlines. This is kind of tough to do in the current framework, just double newlines. This is kind of tough to do in the current framework,
though, and might be reasonably approximated by search replacing double <br>s though, and might be reasonably approximated by search replacing double <br>s
with newlines before running it through HTML Purifier. with newlines before running it through HTML Purifier.
Maintenance related (slightly boring) Maintenance related (slightly boring)
# CHMOD install script for PEAR installs # CHMOD install script for PEAR installs
! Factor out command line parser into its own class, and unit test it ! Factor out command line parser into its own class, and unit test it
- Reduce size of internal data-structures (esp. HTMLDefinition) - Reduce size of internal data-structures (esp. HTMLDefinition)
- Allow merging configurations. Thus, - Allow merging configurations. Thus,
a -> b -> default a -> b -> default
c -> d -> default c -> d -> default
becomes becomes
a -> b -> c -> d -> default a -> b -> c -> d -> default
Maybe allow more fine-grained tuning of this behavior. Alternatively, Maybe allow more fine-grained tuning of this behavior. Alternatively,
encourage people to use short plist depths before building them up. encourage people to use short plist depths before building them up.
- Time PHPT tests - Time PHPT tests
ChildDef related (very boring) ChildDef related (very boring)
- Abstract ChildDef_BlockQuote to work with all elements that only - Abstract ChildDef_BlockQuote to work with all elements that only
allow blocks in them, required or optional allow blocks in them, required or optional
- Implement lenient <ruby> child validation - Implement lenient <ruby> child validation
Wontfix Wontfix
- Non-lossy smart alternate character encoding transformations (unless - Non-lossy smart alternate character encoding transformations (unless
patch provided) patch provided)
- Pretty-printing HTML: users can use Tidy on the output on entire page - Pretty-printing HTML: users can use Tidy on the output on entire page
- Native content compression, whitespace stripping: use gzip if this is - Native content compression, whitespace stripping: use gzip if this is
really important really important
vim: et sw=4 sts=4 vim: et sw=4 sts=4

@ -1,4 +1,4 @@
HTML Purifier 4.7.0 is a bugfix release, collecting two years HTML Purifier 4.7.0 is a bugfix release, collecting two years
worth of accumulated bug fixes. Highlighted bugfixes are updated worth of accumulated bug fixes. Highlighted bugfixes are updated
YouTube filter code, corrected rgb() CSS parsing, and one new YouTube filter code, corrected rgb() CSS parsing, and one new
configuration option, %AutoFormat.RemoveEmpty.Predicate. configuration option, %AutoFormat.RemoveEmpty.Predicate.

@ -1,20 +1,20 @@
WYSIWYG - What You See Is What You Get WYSIWYG - What You See Is What You Get
HTML Purifier: A Pretty Good Fit for TinyMCE and FCKeditor HTML Purifier: A Pretty Good Fit for TinyMCE and FCKeditor
Javascript-based WYSIWYG editors, simply stated, are quite amazing. But I've Javascript-based WYSIWYG editors, simply stated, are quite amazing. But I've
always been wary about using them due to security issues: they handle the always been wary about using them due to security issues: they handle the
client-side magic, but once you've been served a piping hot load of unfiltered client-side magic, but once you've been served a piping hot load of unfiltered
HTML, what should be done then? In some situations, you can serve it uncleaned, HTML, what should be done then? In some situations, you can serve it uncleaned,
since you only offer these facilities to trusted(?) authors. since you only offer these facilities to trusted(?) authors.
Unfortunantely, for blog comments and anonymous input, BBCode, Textile and Unfortunantely, for blog comments and anonymous input, BBCode, Textile and
other markup languages still reign supreme. Put simply: filtering HTML is other markup languages still reign supreme. Put simply: filtering HTML is
hard work, and these WYSIWYG authors don't offer anything to alleviate that hard work, and these WYSIWYG authors don't offer anything to alleviate that
trouble. Therein lies the solution: trouble. Therein lies the solution:
HTML Purifier is perfect for filtering pure-HTML input from WYSIWYG editors. HTML Purifier is perfect for filtering pure-HTML input from WYSIWYG editors.
Enough said. Enough said.
vim: et sw=4 sts=4 vim: et sw=4 sts=4

@ -1,22 +1,22 @@
{ {
"name": "ezyang/htmlpurifier", "name": "ezyang/htmlpurifier",
"description": "Standards compliant HTML filter written in PHP", "description": "Standards compliant HTML filter written in PHP",
"type": "library", "type": "library",
"keywords": ["html"], "keywords": ["html"],
"homepage": "http://htmlpurifier.org/", "homepage": "http://htmlpurifier.org/",
"license": "LGPL", "license": "LGPL",
"authors": [ "authors": [
{ {
"name": "Edward Z. Yang", "name": "Edward Z. Yang",
"email": "admin@htmlpurifier.org", "email": "admin@htmlpurifier.org",
"homepage": "http://ezyang.com" "homepage": "http://ezyang.com"
} }
], ],
"require": { "require": {
"php": ">=5.2" "php": ">=5.2"
}, },
"autoload": { "autoload": {
"psr-0": { "HTMLPurifier": "library/" }, "psr-0": { "HTMLPurifier": "library/" },
"files": ["library/HTMLPurifier.composer.php"] "files": ["library/HTMLPurifier.composer.php"]
} }
} }

@ -1,91 +1,91 @@
<?php <?php
/** /**
* Decorator/extender XSLT processor specifically for HTML documents. * Decorator/extender XSLT processor specifically for HTML documents.
*/ */
class ConfigDoc_HTMLXSLTProcessor class ConfigDoc_HTMLXSLTProcessor
{ {
/** /**
* Instance of XSLTProcessor * Instance of XSLTProcessor
*/ */
protected $xsltProcessor; protected $xsltProcessor;
public function __construct($proc = false) public function __construct($proc = false)
{ {
if ($proc === false) $proc = new XSLTProcessor(); if ($proc === false) $proc = new XSLTProcessor();
$this->xsltProcessor = $proc; $this->xsltProcessor = $proc;
} }
/** /**
* @note Allows a string $xsl filename to be passed * @note Allows a string $xsl filename to be passed
*/ */
public function importStylesheet($xsl) public function importStylesheet($xsl)
{ {
if (is_string($xsl)) { if (is_string($xsl)) {
$xsl_file = $xsl; $xsl_file = $xsl;
$xsl = new DOMDocument(); $xsl = new DOMDocument();
$xsl->load($xsl_file); $xsl->load($xsl_file);
} }
return $this->xsltProcessor->importStylesheet($xsl); return $this->xsltProcessor->importStylesheet($xsl);
} }
/** /**
* Transforms an XML file into compatible XHTML based on the stylesheet * Transforms an XML file into compatible XHTML based on the stylesheet
* @param $xml XML DOM tree, or string filename * @param $xml XML DOM tree, or string filename
* @return string HTML output * @return string HTML output
* @todo Rename to transformToXHTML, as transformToHTML is misleading * @todo Rename to transformToXHTML, as transformToHTML is misleading
*/ */
public function transformToHTML($xml) public function transformToHTML($xml)
{ {
if (is_string($xml)) { if (is_string($xml)) {
$dom = new DOMDocument(); $dom = new DOMDocument();
$dom->load($xml); $dom->load($xml);
} else { } else {
$dom = $xml; $dom = $xml;
} }
$out = $this->xsltProcessor->transformToXML($dom); $out = $this->xsltProcessor->transformToXML($dom);
// fudges for HTML backwards compatibility // fudges for HTML backwards compatibility
// assumes that document is XHTML // assumes that document is XHTML
$out = str_replace('/>', ' />', $out); // <br /> not <br/> $out = str_replace('/>', ' />', $out); // <br /> not <br/>
$out = str_replace(' xmlns=""', '', $out); // rm unnecessary xmlns $out = str_replace(' xmlns=""', '', $out); // rm unnecessary xmlns
if (class_exists('Tidy')) { if (class_exists('Tidy')) {
// cleanup output // cleanup output
$config = array( $config = array(
'indent' => true, 'indent' => true,
'output-xhtml' => true, 'output-xhtml' => true,
'wrap' => 80 'wrap' => 80
); );
$tidy = new Tidy; $tidy = new Tidy;
$tidy->parseString($out, $config, 'utf8'); $tidy->parseString($out, $config, 'utf8');
$tidy->cleanRepair(); $tidy->cleanRepair();
$out = (string) $tidy; $out = (string) $tidy;
} }
return $out; return $out;
} }
/** /**
* Bulk sets parameters for the XSL stylesheet * Bulk sets parameters for the XSL stylesheet
* @param array $options Associative array of options to set * @param array $options Associative array of options to set
*/ */
public function setParameters($options) public function setParameters($options)
{ {
foreach ($options as $name => $value) { foreach ($options as $name => $value) {
$this->xsltProcessor->setParameter('', $name, $value); $this->xsltProcessor->setParameter('', $name, $value);
} }
} }
/** /**
* Forward any other calls to the XSLT processor * Forward any other calls to the XSLT processor
*/ */
public function __call($name, $arguments) public function __call($name, $arguments)
{ {
call_user_func_array(array($this->xsltProcessor, $name), $arguments); call_user_func_array(array($this->xsltProcessor, $name), $arguments);
} }
} }
// vim: et sw=4 sts=4 // vim: et sw=4 sts=4

@ -1,164 +1,164 @@
<?php <?php
/** /**
* Filesystem tools not provided by default; can recursively create, copy * Filesystem tools not provided by default; can recursively create, copy
* and delete folders. Some template methods are provided for extensibility. * and delete folders. Some template methods are provided for extensibility.
* *
* @note This class must be instantiated to be used, although it does * @note This class must be instantiated to be used, although it does
* not maintain state. * not maintain state.
*/ */
class FSTools class FSTools
{ {
private static $singleton; private static $singleton;
/** /**
* Returns a global instance of FSTools * Returns a global instance of FSTools
*/ */
public static function singleton() public static function singleton()
{ {
if (empty(FSTools::$singleton)) FSTools::$singleton = new FSTools(); if (empty(FSTools::$singleton)) FSTools::$singleton = new FSTools();
return FSTools::$singleton; return FSTools::$singleton;
} }
/** /**
* Sets our global singleton to something else; useful for overloading * Sets our global singleton to something else; useful for overloading
* functions. * functions.
*/ */
public static function setSingleton($singleton) public static function setSingleton($singleton)
{ {
FSTools::$singleton = $singleton; FSTools::$singleton = $singleton;
} }
/** /**
* Recursively creates a directory * Recursively creates a directory
* @param string $folder Name of folder to create * @param string $folder Name of folder to create
* @note Adapted from the PHP manual comment 76612 * @note Adapted from the PHP manual comment 76612
*/ */
public function mkdirr($folder) public function mkdirr($folder)
{ {
$folders = preg_split("#[\\\\/]#", $folder); $folders = preg_split("#[\\\\/]#", $folder);
$base = ''; $base = '';
for($i = 0, $c = count($folders); $i < $c; $i++) { for($i = 0, $c = count($folders); $i < $c; $i++) {
if(empty($folders[$i])) { if(empty($folders[$i])) {
if (!$i) { if (!$i) {
// special case for root level // special case for root level
$base .= DIRECTORY_SEPARATOR; $base .= DIRECTORY_SEPARATOR;
} }
continue; continue;
} }
$base .= $folders[$i]; $base .= $folders[$i];
if(!is_dir($base)){ if(!is_dir($base)){
$this->mkdir($base); $this->mkdir($base);
} }
$base .= DIRECTORY_SEPARATOR; $base .= DIRECTORY_SEPARATOR;
} }
} }
/** /**
* Copy a file, or recursively copy a folder and its contents; modified * Copy a file, or recursively copy a folder and its contents; modified
* so that copied files, if PHP, have includes removed * so that copied files, if PHP, have includes removed
* @note Adapted from http://aidanlister.com/repos/v/function.copyr.php * @note Adapted from http://aidanlister.com/repos/v/function.copyr.php
*/ */
public function copyr($source, $dest) public function copyr($source, $dest)
{ {
// Simple copy for a file // Simple copy for a file
if (is_file($source)) { if (is_file($source)) {
return $this->copy($source, $dest); return $this->copy($source, $dest);
} }
// Make destination directory // Make destination directory
if (!is_dir($dest)) { if (!is_dir($dest)) {
$this->mkdir($dest); $this->mkdir($dest);
} }
// Loop through the folder // Loop through the folder
$dir = $this->dir($source); $dir = $this->dir($source);
while ( false !== ($entry = $dir->read()) ) { while ( false !== ($entry = $dir->read()) ) {
// Skip pointers // Skip pointers
if ($entry == '.' || $entry == '..') { if ($entry == '.' || $entry == '..') {
continue; continue;
} }
if (!$this->copyable($entry)) { if (!$this->copyable($entry)) {
continue; continue;
} }
// Deep copy directories // Deep copy directories
if ($dest !== "$source/$entry") { if ($dest !== "$source/$entry") {
$this->copyr("$source/$entry", "$dest/$entry"); $this->copyr("$source/$entry", "$dest/$entry");
} }
} }
// Clean up // Clean up
$dir->close(); $dir->close();
return true; return true;
} }
/** /**
* Overloadable function that tests a filename for copyability. By * Overloadable function that tests a filename for copyability. By
* default, everything should be copied; you can restrict things to * 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(). * applies to copyr().
*/ */
public function copyable($file) public function copyable($file)
{ {
return true; return true;
} }
/** /**
* Delete a file, or a folder and its contents * Delete a file, or a folder and its contents
* @note Adapted from http://aidanlister.com/repos/v/function.rmdirr.php * @note Adapted from http://aidanlister.com/repos/v/function.rmdirr.php
*/ */
public function rmdirr($dirname) public function rmdirr($dirname)
{ {
// Sanity check // Sanity check
if (!$this->file_exists($dirname)) { if (!$this->file_exists($dirname)) {
return false; return false;
} }
// Simple delete for a file // Simple delete for a file
if ($this->is_file($dirname) || $this->is_link($dirname)) { if ($this->is_file($dirname) || $this->is_link($dirname)) {
return $this->unlink($dirname); return $this->unlink($dirname);
} }
// Loop through the folder // Loop through the folder
$dir = $this->dir($dirname); $dir = $this->dir($dirname);
while (false !== $entry = $dir->read()) { while (false !== $entry = $dir->read()) {
// Skip pointers // Skip pointers
if ($entry == '.' || $entry == '..') { if ($entry == '.' || $entry == '..') {
continue; continue;
} }
// Recurse // Recurse
$this->rmdirr($dirname . DIRECTORY_SEPARATOR . $entry); $this->rmdirr($dirname . DIRECTORY_SEPARATOR . $entry);
} }
// Clean up // Clean up
$dir->close(); $dir->close();
return $this->rmdir($dirname); return $this->rmdir($dirname);
} }
/** /**
* Recursively globs a directory. * Recursively globs a directory.
*/ */
public function globr($dir, $pattern, $flags = NULL) public function globr($dir, $pattern, $flags = NULL)
{ {
$files = $this->glob("$dir/$pattern", $flags); $files = $this->glob("$dir/$pattern", $flags);
if ($files === false) $files = array(); if ($files === false) $files = array();
$sub_dirs = $this->glob("$dir/*", GLOB_ONLYDIR); $sub_dirs = $this->glob("$dir/*", GLOB_ONLYDIR);
if ($sub_dirs === false) $sub_dirs = array(); if ($sub_dirs === false) $sub_dirs = array();
foreach ($sub_dirs as $sub_dir) { foreach ($sub_dirs as $sub_dir) {
$sub_files = $this->globr($sub_dir, $pattern, $flags); $sub_files = $this->globr($sub_dir, $pattern, $flags);
$files = array_merge($files, $sub_files); $files = array_merge($files, $sub_files);
} }
return $files; return $files;
} }
/** /**
* Allows for PHP functions to be called and be stubbed. * Allows for PHP functions to be called and be stubbed.
* @warning This function will not work for functions that need * @warning This function will not work for functions that need
* to pass references; manually define a stub function for those. * to pass references; manually define a stub function for those.
*/ */
public function __call($name, $args) public function __call($name, $args)
{ {
return call_user_func_array($name, $args); return call_user_func_array($name, $args);
} }
} }
// vim: et sw=4 sts=4 // vim: et sw=4 sts=4

@ -1,141 +1,141 @@
<?php <?php
/** /**
* Represents a file in the filesystem * Represents a file in the filesystem
* *
* @warning Be sure to distinguish between get() and write() versus * @warning Be sure to distinguish between get() and write() versus
* read() and put(), the former operates on the entire file, while * read() and put(), the former operates on the entire file, while
* the latter operates on a handle. * the latter operates on a handle.
*/ */
class FSTools_File class FSTools_File
{ {
/** Filename of file this object represents */ /** Filename of file this object represents */
protected $name; protected $name;
/** Handle for the file */ /** Handle for the file */
protected $handle = false; protected $handle = false;
/** Instance of FSTools for interfacing with filesystem */ /** Instance of FSTools for interfacing with filesystem */
protected $fs; protected $fs;
/** /**
* Filename of file you wish to instantiate. * Filename of file you wish to instantiate.
* @note This file need not exist * @note This file need not exist
*/ */
public function __construct($name, $fs = false) public function __construct($name, $fs = false)
{ {
$this->name = $name; $this->name = $name;
$this->fs = $fs ? $fs : FSTools::singleton(); $this->fs = $fs ? $fs : FSTools::singleton();
} }
/** Returns the filename of the file. */ /** Returns the filename of the file. */
public function getName() {return $this->name;} public function getName() {return $this->name;}
/** Returns directory of the file without trailing slash */ /** Returns directory of the file without trailing slash */
public function getDirectory() {return $this->fs->dirname($this->name);} public function getDirectory() {return $this->fs->dirname($this->name);}
/** /**
* Retrieves the contents of a file * Retrieves the contents of a file
* @todo Throw an exception if file doesn't exist * @todo Throw an exception if file doesn't exist
*/ */
public function get() public function get()
{ {
return $this->fs->file_get_contents($this->name); return $this->fs->file_get_contents($this->name);
} }
/** Writes contents to a file, creates new file if necessary */ /** Writes contents to a file, creates new file if necessary */
public function write($contents) public function write($contents)
{ {
return $this->fs->file_put_contents($this->name, $contents); return $this->fs->file_put_contents($this->name, $contents);
} }
/** Deletes the file */ /** Deletes the file */
public function delete() public function delete()
{ {
return $this->fs->unlink($this->name); return $this->fs->unlink($this->name);
} }
/** Returns true if file exists and is a file. */ /** Returns true if file exists and is a file. */
public function exists() public function exists()
{ {
return $this->fs->is_file($this->name); return $this->fs->is_file($this->name);
} }
/** Returns last file modification time */ /** Returns last file modification time */
public function getMTime() public function getMTime()
{ {
return $this->fs->filemtime($this->name); return $this->fs->filemtime($this->name);
} }
/** /**
* Chmod a file * Chmod a file
* @note We ignore errors because of some weird owner trickery due * @note We ignore errors because of some weird owner trickery due
* to SVN duality * to SVN duality
*/ */
public function chmod($octal_code) public function chmod($octal_code)
{ {
return @$this->fs->chmod($this->name, $octal_code); return @$this->fs->chmod($this->name, $octal_code);
} }
/** Opens file's handle */ /** Opens file's handle */
public function open($mode) public function open($mode)
{ {
if ($this->handle) $this->close(); if ($this->handle) $this->close();
$this->handle = $this->fs->fopen($this->name, $mode); $this->handle = $this->fs->fopen($this->name, $mode);
return true; return true;
} }
/** Closes file's handle */ /** Closes file's handle */
public function close() public function close()
{ {
if (!$this->handle) return false; if (!$this->handle) return false;
$status = $this->fs->fclose($this->handle); $status = $this->fs->fclose($this->handle);
$this->handle = false; $this->handle = false;
return $status; return $status;
} }
/** Retrieves a line from an open file, with optional max length $length */ /** Retrieves a line from an open file, with optional max length $length */
public function getLine($length = null) public function getLine($length = null)
{ {
if (!$this->handle) $this->open('r'); if (!$this->handle) $this->open('r');
if ($length === null) return $this->fs->fgets($this->handle); if ($length === null) return $this->fs->fgets($this->handle);
else return $this->fs->fgets($this->handle, $length); else return $this->fs->fgets($this->handle, $length);
} }
/** Retrieves a character from an open file */ /** Retrieves a character from an open file */
public function getChar() public function getChar()
{ {
if (!$this->handle) $this->open('r'); if (!$this->handle) $this->open('r');
return $this->fs->fgetc($this->handle); return $this->fs->fgetc($this->handle);
} }
/** Retrieves an $length bytes of data from an open data */ /** Retrieves an $length bytes of data from an open data */
public function read($length) public function read($length)
{ {
if (!$this->handle) $this->open('r'); if (!$this->handle) $this->open('r');
return $this->fs->fread($this->handle, $length); return $this->fs->fread($this->handle, $length);
} }
/** Writes to an open file */ /** Writes to an open file */
public function put($string) public function put($string)
{ {
if (!$this->handle) $this->open('a'); if (!$this->handle) $this->open('a');
return $this->fs->fwrite($this->handle, $string); return $this->fs->fwrite($this->handle, $string);
} }
/** Returns TRUE if the end of the file has been reached */ /** Returns TRUE if the end of the file has been reached */
public function eof() public function eof()
{ {
if (!$this->handle) return true; if (!$this->handle) return true;
return $this->fs->feof($this->handle); return $this->fs->feof($this->handle);
} }
public function __destruct() public function __destruct()
{ {
if ($this->handle) $this->close(); if ($this->handle) $this->close();
} }
} }
// vim: et sw=4 sts=4 // vim: et sw=4 sts=4

@ -1,11 +1,11 @@
<?php <?php
/** /**
* This is a stub include that automatically configures the include path. * This is a stub include that automatically configures the include path.
*/ */
set_include_path(dirname(__FILE__) . PATH_SEPARATOR . get_include_path() ); set_include_path(dirname(__FILE__) . PATH_SEPARATOR . get_include_path() );
require_once 'HTMLPurifierExtras.php'; require_once 'HTMLPurifierExtras.php';
require_once 'HTMLPurifierExtras.autoload.php'; require_once 'HTMLPurifierExtras.autoload.php';
// vim: et sw=4 sts=4 // vim: et sw=4 sts=4

@ -1,26 +1,26 @@
<?php <?php
/** /**
* @file * @file
* Convenience file that registers autoload handler for HTML Purifier. * Convenience file that registers autoload handler for HTML Purifier.
* *
* @warning * @warning
* This autoloader does not contain the compatibility code seen in * This autoloader does not contain the compatibility code seen in
* HTMLPurifier_Bootstrap; the user is expected to make any necessary * HTMLPurifier_Bootstrap; the user is expected to make any necessary
* changes to use this library. * changes to use this library.
*/ */
if (function_exists('spl_autoload_register')) { if (function_exists('spl_autoload_register')) {
spl_autoload_register(array('HTMLPurifierExtras', 'autoload')); spl_autoload_register(array('HTMLPurifierExtras', 'autoload'));
if (function_exists('__autoload')) { if (function_exists('__autoload')) {
// Be polite and ensure that userland autoload gets retained // Be polite and ensure that userland autoload gets retained
spl_autoload_register('__autoload'); spl_autoload_register('__autoload');
} }
} elseif (!function_exists('__autoload')) { } elseif (!function_exists('__autoload')) {
function __autoload($class) function __autoload($class)
{ {
return HTMLPurifierExtras::autoload($class); return HTMLPurifierExtras::autoload($class);
} }
} }
// vim: et sw=4 sts=4 // vim: et sw=4 sts=4

@ -1,31 +1,31 @@
<?php <?php
/** /**
* Meta-class for HTML Purifier's extra class hierarchies, similar to * Meta-class for HTML Purifier's extra class hierarchies, similar to
* HTMLPurifier_Bootstrap. * HTMLPurifier_Bootstrap.
*/ */
class HTMLPurifierExtras class HTMLPurifierExtras
{ {
public static function autoload($class) public static function autoload($class)
{ {
$path = HTMLPurifierExtras::getPath($class); $path = HTMLPurifierExtras::getPath($class);
if (!$path) return false; if (!$path) return false;
require $path; require $path;
return true; return true;
} }
public static function getPath($class) public static function getPath($class)
{ {
if ( if (
strncmp('FSTools', $class, 7) !== 0 && strncmp('FSTools', $class, 7) !== 0 &&
strncmp('ConfigDoc', $class, 9) !== 0 strncmp('ConfigDoc', $class, 9) !== 0
) return false; ) return false;
// Custom implementations can go here // Custom implementations can go here
// Standard implementation: // Standard implementation:
return str_replace('_', '/', $class) . '.php'; return str_replace('_', '/', $class) . '.php';
} }
} }
// vim: et sw=4 sts=4 // vim: et sw=4 sts=4

@ -1,32 +1,32 @@
HTML Purifier Extras HTML Purifier Extras
The Method Behind The Madness! The Method Behind The Madness!
The extras/ folder in HTML Purifier contains--you guessed it--extra things The extras/ folder in HTML Purifier contains--you guessed it--extra things
for HTML Purifier. Specifically, these are two extra libraries called for HTML Purifier. Specifically, these are two extra libraries called
FSTools and ConfigSchema. They're extra for a reason: you don't need them FSTools and ConfigSchema. They're extra for a reason: you don't need them
if you're using HTML Purifier for normal usage: filtering HTML. However, if you're using HTML Purifier for normal usage: filtering HTML. However,
if you're a developer, and would like to test HTML Purifier, or need to if you're a developer, and would like to test HTML Purifier, or need to
use one of HTML Purifier's maintenance scripts, chances are they'll need use one of HTML Purifier's maintenance scripts, chances are they'll need
these libraries. Who knows: maybe you'll find them useful too! these libraries. Who knows: maybe you'll find them useful too!
Here are the libraries: Here are the libraries:
FSTools FSTools
------- -------
Short for File System Tools, this is a poor-man's object-oriented wrapper for Short for File System Tools, this is a poor-man's object-oriented wrapper for
the filesystem. It currently consists of two classes: the filesystem. It currently consists of two classes:
- FSTools: This is a singleton that contains a manner of useful functions - FSTools: This is a singleton that contains a manner of useful functions
such as recursive glob, directory removal, etc, as well as the ability such as recursive glob, directory removal, etc, as well as the ability
to call arbitrary native PHP functions through it like $FS->fopen(...). 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. 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. method imaginable one would need.
Check the files themselves for more information. Check the files themselves for more information.
vim: et sw=4 sts=4 vim: et sw=4 sts=4

@ -1,11 +1,11 @@
<?php <?php
/** /**
* This is a stub include that automatically configures the include path. * This is a stub include that automatically configures the include path.
*/ */
set_include_path(dirname(__FILE__) . PATH_SEPARATOR . get_include_path() ); set_include_path(dirname(__FILE__) . PATH_SEPARATOR . get_include_path() );
require_once 'HTMLPurifier/Bootstrap.php'; require_once 'HTMLPurifier/Bootstrap.php';
require_once 'HTMLPurifier.autoload.php'; require_once 'HTMLPurifier.autoload.php';
// vim: et sw=4 sts=4 // vim: et sw=4 sts=4

@ -1,27 +1,27 @@
<?php <?php
/** /**
* @file * @file
* Convenience file that registers autoload handler for HTML Purifier. * Convenience file that registers autoload handler for HTML Purifier.
* It also does some sanity checks. * It also does some sanity checks.
*/ */
if (function_exists('spl_autoload_register') && function_exists('spl_autoload_unregister')) { if (function_exists('spl_autoload_register') && function_exists('spl_autoload_unregister')) {
// We need unregister for our pre-registering functionality // We need unregister for our pre-registering functionality
HTMLPurifier_Bootstrap::registerAutoload(); HTMLPurifier_Bootstrap::registerAutoload();
if (function_exists('__autoload')) { if (function_exists('__autoload')) {
// Be polite and ensure that userland autoload gets retained // Be polite and ensure that userland autoload gets retained
spl_autoload_register('__autoload'); spl_autoload_register('__autoload');
} }
} elseif (!function_exists('__autoload')) { } elseif (!function_exists('__autoload')) {
function __autoload($class) function __autoload($class)
{ {
return HTMLPurifier_Bootstrap::autoload($class); return HTMLPurifier_Bootstrap::autoload($class);
} }
} }
if (ini_get('zend.ze1_compatibility_mode')) { if (ini_get('zend.ze1_compatibility_mode')) {
trigger_error("HTML Purifier is not compatible with zend.ze1_compatibility_mode; please turn it off", E_USER_ERROR); trigger_error("HTML Purifier is not compatible with zend.ze1_compatibility_mode; please turn it off", E_USER_ERROR);
} }
// vim: et sw=4 sts=4 // vim: et sw=4 sts=4

@ -1,4 +1,4 @@
<?php <?php
if (!defined('HTMLPURIFIER_PREFIX')) { if (!defined('HTMLPURIFIER_PREFIX')) {
define('HTMLPURIFIER_PREFIX', dirname(__FILE__)); define('HTMLPURIFIER_PREFIX', dirname(__FILE__));
} }

@ -1,25 +1,25 @@
<?php <?php
/** /**
* @file * @file
* Defines a function wrapper for HTML Purifier for quick use. * Defines a function wrapper for HTML Purifier for quick use.
* @note ''HTMLPurifier()'' is NOT the same as ''new HTMLPurifier()'' * @note ''HTMLPurifier()'' is NOT the same as ''new HTMLPurifier()''
*/ */
/** /**
* Purify HTML. * Purify HTML.
* @param string $html String HTML to purify * @param string $html String HTML to purify
* @param mixed $config Configuration to use, can be any value accepted by * @param mixed $config Configuration to use, can be any value accepted by
* HTMLPurifier_Config::create() * HTMLPurifier_Config::create()
* @return string * @return string
*/ */
function HTMLPurifier($html, $config = null) function HTMLPurifier($html, $config = null)
{ {
static $purifier = false; static $purifier = false;
if (!$purifier) { if (!$purifier) {
$purifier = new HTMLPurifier(); $purifier = new HTMLPurifier();
} }
return $purifier->purify($html, $config); return $purifier->purify($html, $config);
} }
// vim: et sw=4 sts=4 // vim: et sw=4 sts=4

@ -1,229 +1,229 @@
<?php <?php
/** /**
* @file * @file
* This file was auto-generated by generate-includes.php and includes all of * This file was auto-generated by generate-includes.php and includes all of
* the core files required by HTML Purifier. Use this if performance is a * 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 * 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. * FILE, changes will be overwritten the next time the script is run.
* *
* @version 4.7.0 * @version 4.7.0
* *
* @warning * @warning
* You must *not* include any other HTML Purifier files before this file, * You must *not* include any other HTML Purifier files before this file,
* because 'require' not 'require_once' is used. * because 'require' not 'require_once' is used.
* *
* @warning * @warning
* This file requires that the include path contains the HTML Purifier * This file requires that the include path contains the HTML Purifier
* library directory; this is not auto-set. * library directory; this is not auto-set.
*/ */
require 'HTMLPurifier.php'; require 'HTMLPurifier.php';
require 'HTMLPurifier/Arborize.php'; require 'HTMLPurifier/Arborize.php';
require 'HTMLPurifier/AttrCollections.php'; require 'HTMLPurifier/AttrCollections.php';
require 'HTMLPurifier/AttrDef.php'; require 'HTMLPurifier/AttrDef.php';
require 'HTMLPurifier/AttrTransform.php'; require 'HTMLPurifier/AttrTransform.php';
require 'HTMLPurifier/AttrTypes.php'; require 'HTMLPurifier/AttrTypes.php';
require 'HTMLPurifier/AttrValidator.php'; require 'HTMLPurifier/AttrValidator.php';
require 'HTMLPurifier/Bootstrap.php'; require 'HTMLPurifier/Bootstrap.php';
require 'HTMLPurifier/Definition.php'; require 'HTMLPurifier/Definition.php';
require 'HTMLPurifier/CSSDefinition.php'; require 'HTMLPurifier/CSSDefinition.php';
require 'HTMLPurifier/ChildDef.php'; require 'HTMLPurifier/ChildDef.php';
require 'HTMLPurifier/Config.php'; require 'HTMLPurifier/Config.php';
require 'HTMLPurifier/ConfigSchema.php'; require 'HTMLPurifier/ConfigSchema.php';
require 'HTMLPurifier/ContentSets.php'; require 'HTMLPurifier/ContentSets.php';
require 'HTMLPurifier/Context.php'; require 'HTMLPurifier/Context.php';
require 'HTMLPurifier/DefinitionCache.php'; require 'HTMLPurifier/DefinitionCache.php';
require 'HTMLPurifier/DefinitionCacheFactory.php'; require 'HTMLPurifier/DefinitionCacheFactory.php';
require 'HTMLPurifier/Doctype.php'; require 'HTMLPurifier/Doctype.php';
require 'HTMLPurifier/DoctypeRegistry.php'; require 'HTMLPurifier/DoctypeRegistry.php';
require 'HTMLPurifier/ElementDef.php'; require 'HTMLPurifier/ElementDef.php';
require 'HTMLPurifier/Encoder.php'; require 'HTMLPurifier/Encoder.php';
require 'HTMLPurifier/EntityLookup.php'; require 'HTMLPurifier/EntityLookup.php';
require 'HTMLPurifier/EntityParser.php'; require 'HTMLPurifier/EntityParser.php';
require 'HTMLPurifier/ErrorCollector.php'; require 'HTMLPurifier/ErrorCollector.php';
require 'HTMLPurifier/ErrorStruct.php'; require 'HTMLPurifier/ErrorStruct.php';
require 'HTMLPurifier/Exception.php'; require 'HTMLPurifier/Exception.php';
require 'HTMLPurifier/Filter.php'; require 'HTMLPurifier/Filter.php';
require 'HTMLPurifier/Generator.php'; require 'HTMLPurifier/Generator.php';
require 'HTMLPurifier/HTMLDefinition.php'; require 'HTMLPurifier/HTMLDefinition.php';
require 'HTMLPurifier/HTMLModule.php'; require 'HTMLPurifier/HTMLModule.php';
require 'HTMLPurifier/HTMLModuleManager.php'; require 'HTMLPurifier/HTMLModuleManager.php';
require 'HTMLPurifier/IDAccumulator.php'; require 'HTMLPurifier/IDAccumulator.php';
require 'HTMLPurifier/Injector.php'; require 'HTMLPurifier/Injector.php';
require 'HTMLPurifier/Language.php'; require 'HTMLPurifier/Language.php';
require 'HTMLPurifier/LanguageFactory.php'; require 'HTMLPurifier/LanguageFactory.php';
require 'HTMLPurifier/Length.php'; require 'HTMLPurifier/Length.php';
require 'HTMLPurifier/Lexer.php'; require 'HTMLPurifier/Lexer.php';
require 'HTMLPurifier/Node.php'; require 'HTMLPurifier/Node.php';
require 'HTMLPurifier/PercentEncoder.php'; require 'HTMLPurifier/PercentEncoder.php';
require 'HTMLPurifier/PropertyList.php'; require 'HTMLPurifier/PropertyList.php';
require 'HTMLPurifier/PropertyListIterator.php'; require 'HTMLPurifier/PropertyListIterator.php';
require 'HTMLPurifier/Queue.php'; require 'HTMLPurifier/Queue.php';
require 'HTMLPurifier/Strategy.php'; require 'HTMLPurifier/Strategy.php';
require 'HTMLPurifier/StringHash.php'; require 'HTMLPurifier/StringHash.php';
require 'HTMLPurifier/StringHashParser.php'; require 'HTMLPurifier/StringHashParser.php';
require 'HTMLPurifier/TagTransform.php'; require 'HTMLPurifier/TagTransform.php';
require 'HTMLPurifier/Token.php'; require 'HTMLPurifier/Token.php';
require 'HTMLPurifier/TokenFactory.php'; require 'HTMLPurifier/TokenFactory.php';
require 'HTMLPurifier/URI.php'; require 'HTMLPurifier/URI.php';
require 'HTMLPurifier/URIDefinition.php'; require 'HTMLPurifier/URIDefinition.php';
require 'HTMLPurifier/URIFilter.php'; require 'HTMLPurifier/URIFilter.php';
require 'HTMLPurifier/URIParser.php'; require 'HTMLPurifier/URIParser.php';
require 'HTMLPurifier/URIScheme.php'; require 'HTMLPurifier/URIScheme.php';
require 'HTMLPurifier/URISchemeRegistry.php'; require 'HTMLPurifier/URISchemeRegistry.php';
require 'HTMLPurifier/UnitConverter.php'; require 'HTMLPurifier/UnitConverter.php';
require 'HTMLPurifier/VarParser.php'; require 'HTMLPurifier/VarParser.php';
require 'HTMLPurifier/VarParserException.php'; require 'HTMLPurifier/VarParserException.php';
require 'HTMLPurifier/Zipper.php'; require 'HTMLPurifier/Zipper.php';
require 'HTMLPurifier/AttrDef/CSS.php'; require 'HTMLPurifier/AttrDef/CSS.php';
require 'HTMLPurifier/AttrDef/Clone.php'; require 'HTMLPurifier/AttrDef/Clone.php';
require 'HTMLPurifier/AttrDef/Enum.php'; require 'HTMLPurifier/AttrDef/Enum.php';
require 'HTMLPurifier/AttrDef/Integer.php'; require 'HTMLPurifier/AttrDef/Integer.php';
require 'HTMLPurifier/AttrDef/Lang.php'; require 'HTMLPurifier/AttrDef/Lang.php';
require 'HTMLPurifier/AttrDef/Switch.php'; require 'HTMLPurifier/AttrDef/Switch.php';
require 'HTMLPurifier/AttrDef/Text.php'; require 'HTMLPurifier/AttrDef/Text.php';
require 'HTMLPurifier/AttrDef/URI.php'; require 'HTMLPurifier/AttrDef/URI.php';
require 'HTMLPurifier/AttrDef/CSS/Number.php'; require 'HTMLPurifier/AttrDef/CSS/Number.php';
require 'HTMLPurifier/AttrDef/CSS/AlphaValue.php'; require 'HTMLPurifier/AttrDef/CSS/AlphaValue.php';
require 'HTMLPurifier/AttrDef/CSS/Background.php'; require 'HTMLPurifier/AttrDef/CSS/Background.php';
require 'HTMLPurifier/AttrDef/CSS/BackgroundPosition.php'; require 'HTMLPurifier/AttrDef/CSS/BackgroundPosition.php';
require 'HTMLPurifier/AttrDef/CSS/Border.php'; require 'HTMLPurifier/AttrDef/CSS/Border.php';
require 'HTMLPurifier/AttrDef/CSS/Color.php'; require 'HTMLPurifier/AttrDef/CSS/Color.php';
require 'HTMLPurifier/AttrDef/CSS/Composite.php'; require 'HTMLPurifier/AttrDef/CSS/Composite.php';
require 'HTMLPurifier/AttrDef/CSS/DenyElementDecorator.php'; require 'HTMLPurifier/AttrDef/CSS/DenyElementDecorator.php';
require 'HTMLPurifier/AttrDef/CSS/Filter.php'; require 'HTMLPurifier/AttrDef/CSS/Filter.php';
require 'HTMLPurifier/AttrDef/CSS/Font.php'; require 'HTMLPurifier/AttrDef/CSS/Font.php';
require 'HTMLPurifier/AttrDef/CSS/FontFamily.php'; require 'HTMLPurifier/AttrDef/CSS/FontFamily.php';
require 'HTMLPurifier/AttrDef/CSS/Ident.php'; require 'HTMLPurifier/AttrDef/CSS/Ident.php';
require 'HTMLPurifier/AttrDef/CSS/ImportantDecorator.php'; require 'HTMLPurifier/AttrDef/CSS/ImportantDecorator.php';
require 'HTMLPurifier/AttrDef/CSS/Length.php'; require 'HTMLPurifier/AttrDef/CSS/Length.php';
require 'HTMLPurifier/AttrDef/CSS/ListStyle.php'; require 'HTMLPurifier/AttrDef/CSS/ListStyle.php';
require 'HTMLPurifier/AttrDef/CSS/Multiple.php'; require 'HTMLPurifier/AttrDef/CSS/Multiple.php';
require 'HTMLPurifier/AttrDef/CSS/Percentage.php'; require 'HTMLPurifier/AttrDef/CSS/Percentage.php';
require 'HTMLPurifier/AttrDef/CSS/TextDecoration.php'; require 'HTMLPurifier/AttrDef/CSS/TextDecoration.php';
require 'HTMLPurifier/AttrDef/CSS/URI.php'; require 'HTMLPurifier/AttrDef/CSS/URI.php';
require 'HTMLPurifier/AttrDef/HTML/Bool.php'; require 'HTMLPurifier/AttrDef/HTML/Bool.php';
require 'HTMLPurifier/AttrDef/HTML/Nmtokens.php'; require 'HTMLPurifier/AttrDef/HTML/Nmtokens.php';
require 'HTMLPurifier/AttrDef/HTML/Class.php'; require 'HTMLPurifier/AttrDef/HTML/Class.php';
require 'HTMLPurifier/AttrDef/HTML/Color.php'; require 'HTMLPurifier/AttrDef/HTML/Color.php';
require 'HTMLPurifier/AttrDef/HTML/FrameTarget.php'; require 'HTMLPurifier/AttrDef/HTML/FrameTarget.php';
require 'HTMLPurifier/AttrDef/HTML/ID.php'; require 'HTMLPurifier/AttrDef/HTML/ID.php';
require 'HTMLPurifier/AttrDef/HTML/Pixels.php'; require 'HTMLPurifier/AttrDef/HTML/Pixels.php';
require 'HTMLPurifier/AttrDef/HTML/Length.php'; require 'HTMLPurifier/AttrDef/HTML/Length.php';
require 'HTMLPurifier/AttrDef/HTML/LinkTypes.php'; require 'HTMLPurifier/AttrDef/HTML/LinkTypes.php';
require 'HTMLPurifier/AttrDef/HTML/MultiLength.php'; require 'HTMLPurifier/AttrDef/HTML/MultiLength.php';
require 'HTMLPurifier/AttrDef/URI/Email.php'; require 'HTMLPurifier/AttrDef/URI/Email.php';
require 'HTMLPurifier/AttrDef/URI/Host.php'; require 'HTMLPurifier/AttrDef/URI/Host.php';
require 'HTMLPurifier/AttrDef/URI/IPv4.php'; require 'HTMLPurifier/AttrDef/URI/IPv4.php';
require 'HTMLPurifier/AttrDef/URI/IPv6.php'; require 'HTMLPurifier/AttrDef/URI/IPv6.php';
require 'HTMLPurifier/AttrDef/URI/Email/SimpleCheck.php'; require 'HTMLPurifier/AttrDef/URI/Email/SimpleCheck.php';
require 'HTMLPurifier/AttrTransform/Background.php'; require 'HTMLPurifier/AttrTransform/Background.php';
require 'HTMLPurifier/AttrTransform/BdoDir.php'; require 'HTMLPurifier/AttrTransform/BdoDir.php';
require 'HTMLPurifier/AttrTransform/BgColor.php'; require 'HTMLPurifier/AttrTransform/BgColor.php';
require 'HTMLPurifier/AttrTransform/BoolToCSS.php'; require 'HTMLPurifier/AttrTransform/BoolToCSS.php';
require 'HTMLPurifier/AttrTransform/Border.php'; require 'HTMLPurifier/AttrTransform/Border.php';
require 'HTMLPurifier/AttrTransform/EnumToCSS.php'; require 'HTMLPurifier/AttrTransform/EnumToCSS.php';
require 'HTMLPurifier/AttrTransform/ImgRequired.php'; require 'HTMLPurifier/AttrTransform/ImgRequired.php';
require 'HTMLPurifier/AttrTransform/ImgSpace.php'; require 'HTMLPurifier/AttrTransform/ImgSpace.php';
require 'HTMLPurifier/AttrTransform/Input.php'; require 'HTMLPurifier/AttrTransform/Input.php';
require 'HTMLPurifier/AttrTransform/Lang.php'; require 'HTMLPurifier/AttrTransform/Lang.php';
require 'HTMLPurifier/AttrTransform/Length.php'; require 'HTMLPurifier/AttrTransform/Length.php';
require 'HTMLPurifier/AttrTransform/Name.php'; require 'HTMLPurifier/AttrTransform/Name.php';
require 'HTMLPurifier/AttrTransform/NameSync.php'; require 'HTMLPurifier/AttrTransform/NameSync.php';
require 'HTMLPurifier/AttrTransform/Nofollow.php'; require 'HTMLPurifier/AttrTransform/Nofollow.php';
require 'HTMLPurifier/AttrTransform/SafeEmbed.php'; require 'HTMLPurifier/AttrTransform/SafeEmbed.php';
require 'HTMLPurifier/AttrTransform/SafeObject.php'; require 'HTMLPurifier/AttrTransform/SafeObject.php';
require 'HTMLPurifier/AttrTransform/SafeParam.php'; require 'HTMLPurifier/AttrTransform/SafeParam.php';
require 'HTMLPurifier/AttrTransform/ScriptRequired.php'; require 'HTMLPurifier/AttrTransform/ScriptRequired.php';
require 'HTMLPurifier/AttrTransform/TargetBlank.php'; require 'HTMLPurifier/AttrTransform/TargetBlank.php';
require 'HTMLPurifier/AttrTransform/Textarea.php'; require 'HTMLPurifier/AttrTransform/Textarea.php';
require 'HTMLPurifier/ChildDef/Chameleon.php'; require 'HTMLPurifier/ChildDef/Chameleon.php';
require 'HTMLPurifier/ChildDef/Custom.php'; require 'HTMLPurifier/ChildDef/Custom.php';
require 'HTMLPurifier/ChildDef/Empty.php'; require 'HTMLPurifier/ChildDef/Empty.php';
require 'HTMLPurifier/ChildDef/List.php'; require 'HTMLPurifier/ChildDef/List.php';
require 'HTMLPurifier/ChildDef/Required.php'; require 'HTMLPurifier/ChildDef/Required.php';
require 'HTMLPurifier/ChildDef/Optional.php'; require 'HTMLPurifier/ChildDef/Optional.php';
require 'HTMLPurifier/ChildDef/StrictBlockquote.php'; require 'HTMLPurifier/ChildDef/StrictBlockquote.php';
require 'HTMLPurifier/ChildDef/Table.php'; require 'HTMLPurifier/ChildDef/Table.php';
require 'HTMLPurifier/DefinitionCache/Decorator.php'; require 'HTMLPurifier/DefinitionCache/Decorator.php';
require 'HTMLPurifier/DefinitionCache/Null.php'; require 'HTMLPurifier/DefinitionCache/Null.php';
require 'HTMLPurifier/DefinitionCache/Serializer.php'; require 'HTMLPurifier/DefinitionCache/Serializer.php';
require 'HTMLPurifier/DefinitionCache/Decorator/Cleanup.php'; require 'HTMLPurifier/DefinitionCache/Decorator/Cleanup.php';
require 'HTMLPurifier/DefinitionCache/Decorator/Memory.php'; require 'HTMLPurifier/DefinitionCache/Decorator/Memory.php';
require 'HTMLPurifier/HTMLModule/Bdo.php'; require 'HTMLPurifier/HTMLModule/Bdo.php';
require 'HTMLPurifier/HTMLModule/CommonAttributes.php'; require 'HTMLPurifier/HTMLModule/CommonAttributes.php';
require 'HTMLPurifier/HTMLModule/Edit.php'; require 'HTMLPurifier/HTMLModule/Edit.php';
require 'HTMLPurifier/HTMLModule/Forms.php'; require 'HTMLPurifier/HTMLModule/Forms.php';
require 'HTMLPurifier/HTMLModule/Hypertext.php'; require 'HTMLPurifier/HTMLModule/Hypertext.php';
require 'HTMLPurifier/HTMLModule/Iframe.php'; require 'HTMLPurifier/HTMLModule/Iframe.php';
require 'HTMLPurifier/HTMLModule/Image.php'; require 'HTMLPurifier/HTMLModule/Image.php';
require 'HTMLPurifier/HTMLModule/Legacy.php'; require 'HTMLPurifier/HTMLModule/Legacy.php';
require 'HTMLPurifier/HTMLModule/List.php'; require 'HTMLPurifier/HTMLModule/List.php';
require 'HTMLPurifier/HTMLModule/Name.php'; require 'HTMLPurifier/HTMLModule/Name.php';
require 'HTMLPurifier/HTMLModule/Nofollow.php'; require 'HTMLPurifier/HTMLModule/Nofollow.php';
require 'HTMLPurifier/HTMLModule/NonXMLCommonAttributes.php'; require 'HTMLPurifier/HTMLModule/NonXMLCommonAttributes.php';
require 'HTMLPurifier/HTMLModule/Object.php'; require 'HTMLPurifier/HTMLModule/Object.php';
require 'HTMLPurifier/HTMLModule/Presentation.php'; require 'HTMLPurifier/HTMLModule/Presentation.php';
require 'HTMLPurifier/HTMLModule/Proprietary.php'; require 'HTMLPurifier/HTMLModule/Proprietary.php';
require 'HTMLPurifier/HTMLModule/Ruby.php'; require 'HTMLPurifier/HTMLModule/Ruby.php';
require 'HTMLPurifier/HTMLModule/SafeEmbed.php'; require 'HTMLPurifier/HTMLModule/SafeEmbed.php';
require 'HTMLPurifier/HTMLModule/SafeObject.php'; require 'HTMLPurifier/HTMLModule/SafeObject.php';
require 'HTMLPurifier/HTMLModule/SafeScripting.php'; require 'HTMLPurifier/HTMLModule/SafeScripting.php';
require 'HTMLPurifier/HTMLModule/Scripting.php'; require 'HTMLPurifier/HTMLModule/Scripting.php';
require 'HTMLPurifier/HTMLModule/StyleAttribute.php'; require 'HTMLPurifier/HTMLModule/StyleAttribute.php';
require 'HTMLPurifier/HTMLModule/Tables.php'; require 'HTMLPurifier/HTMLModule/Tables.php';
require 'HTMLPurifier/HTMLModule/Target.php'; require 'HTMLPurifier/HTMLModule/Target.php';
require 'HTMLPurifier/HTMLModule/TargetBlank.php'; require 'HTMLPurifier/HTMLModule/TargetBlank.php';
require 'HTMLPurifier/HTMLModule/Text.php'; require 'HTMLPurifier/HTMLModule/Text.php';
require 'HTMLPurifier/HTMLModule/Tidy.php'; require 'HTMLPurifier/HTMLModule/Tidy.php';
require 'HTMLPurifier/HTMLModule/XMLCommonAttributes.php'; require 'HTMLPurifier/HTMLModule/XMLCommonAttributes.php';
require 'HTMLPurifier/HTMLModule/Tidy/Name.php'; require 'HTMLPurifier/HTMLModule/Tidy/Name.php';
require 'HTMLPurifier/HTMLModule/Tidy/Proprietary.php'; require 'HTMLPurifier/HTMLModule/Tidy/Proprietary.php';
require 'HTMLPurifier/HTMLModule/Tidy/XHTMLAndHTML4.php'; require 'HTMLPurifier/HTMLModule/Tidy/XHTMLAndHTML4.php';
require 'HTMLPurifier/HTMLModule/Tidy/Strict.php'; require 'HTMLPurifier/HTMLModule/Tidy/Strict.php';
require 'HTMLPurifier/HTMLModule/Tidy/Transitional.php'; require 'HTMLPurifier/HTMLModule/Tidy/Transitional.php';
require 'HTMLPurifier/HTMLModule/Tidy/XHTML.php'; require 'HTMLPurifier/HTMLModule/Tidy/XHTML.php';
require 'HTMLPurifier/Injector/AutoParagraph.php'; require 'HTMLPurifier/Injector/AutoParagraph.php';
require 'HTMLPurifier/Injector/DisplayLinkURI.php'; require 'HTMLPurifier/Injector/DisplayLinkURI.php';
require 'HTMLPurifier/Injector/Linkify.php'; require 'HTMLPurifier/Injector/Linkify.php';
require 'HTMLPurifier/Injector/PurifierLinkify.php'; require 'HTMLPurifier/Injector/PurifierLinkify.php';
require 'HTMLPurifier/Injector/RemoveEmpty.php'; require 'HTMLPurifier/Injector/RemoveEmpty.php';
require 'HTMLPurifier/Injector/RemoveSpansWithoutAttributes.php'; require 'HTMLPurifier/Injector/RemoveSpansWithoutAttributes.php';
require 'HTMLPurifier/Injector/SafeObject.php'; require 'HTMLPurifier/Injector/SafeObject.php';
require 'HTMLPurifier/Lexer/DOMLex.php'; require 'HTMLPurifier/Lexer/DOMLex.php';
require 'HTMLPurifier/Lexer/DirectLex.php'; require 'HTMLPurifier/Lexer/DirectLex.php';
require 'HTMLPurifier/Node/Comment.php'; require 'HTMLPurifier/Node/Comment.php';
require 'HTMLPurifier/Node/Element.php'; require 'HTMLPurifier/Node/Element.php';
require 'HTMLPurifier/Node/Text.php'; require 'HTMLPurifier/Node/Text.php';
require 'HTMLPurifier/Strategy/Composite.php'; require 'HTMLPurifier/Strategy/Composite.php';
require 'HTMLPurifier/Strategy/Core.php'; require 'HTMLPurifier/Strategy/Core.php';
require 'HTMLPurifier/Strategy/FixNesting.php'; require 'HTMLPurifier/Strategy/FixNesting.php';
require 'HTMLPurifier/Strategy/MakeWellFormed.php'; require 'HTMLPurifier/Strategy/MakeWellFormed.php';
require 'HTMLPurifier/Strategy/RemoveForeignElements.php'; require 'HTMLPurifier/Strategy/RemoveForeignElements.php';
require 'HTMLPurifier/Strategy/ValidateAttributes.php'; require 'HTMLPurifier/Strategy/ValidateAttributes.php';
require 'HTMLPurifier/TagTransform/Font.php'; require 'HTMLPurifier/TagTransform/Font.php';
require 'HTMLPurifier/TagTransform/Simple.php'; require 'HTMLPurifier/TagTransform/Simple.php';
require 'HTMLPurifier/Token/Comment.php'; require 'HTMLPurifier/Token/Comment.php';
require 'HTMLPurifier/Token/Tag.php'; require 'HTMLPurifier/Token/Tag.php';
require 'HTMLPurifier/Token/Empty.php'; require 'HTMLPurifier/Token/Empty.php';
require 'HTMLPurifier/Token/End.php'; require 'HTMLPurifier/Token/End.php';
require 'HTMLPurifier/Token/Start.php'; require 'HTMLPurifier/Token/Start.php';
require 'HTMLPurifier/Token/Text.php'; require 'HTMLPurifier/Token/Text.php';
require 'HTMLPurifier/URIFilter/DisableExternal.php'; require 'HTMLPurifier/URIFilter/DisableExternal.php';
require 'HTMLPurifier/URIFilter/DisableExternalResources.php'; require 'HTMLPurifier/URIFilter/DisableExternalResources.php';
require 'HTMLPurifier/URIFilter/DisableResources.php'; require 'HTMLPurifier/URIFilter/DisableResources.php';
require 'HTMLPurifier/URIFilter/HostBlacklist.php'; require 'HTMLPurifier/URIFilter/HostBlacklist.php';
require 'HTMLPurifier/URIFilter/MakeAbsolute.php'; require 'HTMLPurifier/URIFilter/MakeAbsolute.php';
require 'HTMLPurifier/URIFilter/Munge.php'; require 'HTMLPurifier/URIFilter/Munge.php';
require 'HTMLPurifier/URIFilter/SafeIframe.php'; require 'HTMLPurifier/URIFilter/SafeIframe.php';
require 'HTMLPurifier/URIScheme/data.php'; require 'HTMLPurifier/URIScheme/data.php';
require 'HTMLPurifier/URIScheme/file.php'; require 'HTMLPurifier/URIScheme/file.php';
require 'HTMLPurifier/URIScheme/ftp.php'; require 'HTMLPurifier/URIScheme/ftp.php';
require 'HTMLPurifier/URIScheme/http.php'; require 'HTMLPurifier/URIScheme/http.php';
require 'HTMLPurifier/URIScheme/https.php'; require 'HTMLPurifier/URIScheme/https.php';
require 'HTMLPurifier/URIScheme/mailto.php'; require 'HTMLPurifier/URIScheme/mailto.php';
require 'HTMLPurifier/URIScheme/news.php'; require 'HTMLPurifier/URIScheme/news.php';
require 'HTMLPurifier/URIScheme/nntp.php'; require 'HTMLPurifier/URIScheme/nntp.php';
require 'HTMLPurifier/VarParser/Flexible.php'; require 'HTMLPurifier/VarParser/Flexible.php';
require 'HTMLPurifier/VarParser/Native.php'; require 'HTMLPurifier/VarParser/Native.php';

@ -1,30 +1,30 @@
<?php <?php
/** /**
* @file * @file
* Emulation layer for code that used kses(), substituting in HTML Purifier. * Emulation layer for code that used kses(), substituting in HTML Purifier.
*/ */
require_once dirname(__FILE__) . '/HTMLPurifier.auto.php'; require_once dirname(__FILE__) . '/HTMLPurifier.auto.php';
function kses($string, $allowed_html, $allowed_protocols = null) function kses($string, $allowed_html, $allowed_protocols = null)
{ {
$config = HTMLPurifier_Config::createDefault(); $config = HTMLPurifier_Config::createDefault();
$allowed_elements = array(); $allowed_elements = array();
$allowed_attributes = array(); $allowed_attributes = array();
foreach ($allowed_html as $element => $attributes) { foreach ($allowed_html as $element => $attributes) {
$allowed_elements[$element] = true; $allowed_elements[$element] = true;
foreach ($attributes as $attribute => $x) { foreach ($attributes as $attribute => $x) {
$allowed_attributes["$element.$attribute"] = true; $allowed_attributes["$element.$attribute"] = true;
} }
} }
$config->set('HTML.AllowedElements', $allowed_elements); $config->set('HTML.AllowedElements', $allowed_elements);
$config->set('HTML.AllowedAttributes', $allowed_attributes); $config->set('HTML.AllowedAttributes', $allowed_attributes);
if ($allowed_protocols !== null) { if ($allowed_protocols !== null) {
$config->set('URI.AllowedSchemes', $allowed_protocols); $config->set('URI.AllowedSchemes', $allowed_protocols);
} }
$purifier = new HTMLPurifier($config); $purifier = new HTMLPurifier($config);
return $purifier->purify($string); return $purifier->purify($string);
} }
// vim: et sw=4 sts=4 // vim: et sw=4 sts=4

@ -1,11 +1,11 @@
<?php <?php
/** /**
* @file * @file
* Convenience stub file that adds HTML Purifier's library file to the path * Convenience stub file that adds HTML Purifier's library file to the path
* without any other side-effects. * without any other side-effects.
*/ */
set_include_path(dirname(__FILE__) . PATH_SEPARATOR . get_include_path() ); set_include_path(dirname(__FILE__) . PATH_SEPARATOR . get_include_path() );
// vim: et sw=4 sts=4 // vim: et sw=4 sts=4

@ -1,292 +1,292 @@
<?php <?php
/*! @mainpage /*! @mainpage
* *
* HTML Purifier is an HTML filter that will take an arbitrary snippet of * HTML Purifier is an HTML filter that will take an arbitrary snippet of
* HTML and rigorously test, validate and filter it into a version that * HTML and rigorously test, validate and filter it into a version that
* is safe for output onto webpages. It achieves this by: * is safe for output onto webpages. It achieves this by:
* *
* -# Lexing (parsing into tokens) the document, * -# Lexing (parsing into tokens) the document,
* -# Executing various strategies on the tokens: * -# Executing various strategies on the tokens:
* -# Removing all elements not in the whitelist, * -# Removing all elements not in the whitelist,
* -# Making the tokens well-formed, * -# Making the tokens well-formed,
* -# Fixing the nesting of the nodes, and * -# Fixing the nesting of the nodes, and
* -# Validating attributes of the nodes; and * -# Validating attributes of the nodes; and
* -# Generating HTML from the purified tokens. * -# Generating HTML from the purified tokens.
* *
* However, most users will only need to interface with the HTMLPurifier * However, most users will only need to interface with the HTMLPurifier
* and HTMLPurifier_Config. * and HTMLPurifier_Config.
*/ */
/* /*
HTML Purifier 4.7.0 - Standards Compliant HTML Filtering HTML Purifier 4.7.0 - Standards Compliant HTML Filtering
Copyright (C) 2006-2008 Edward Z. Yang Copyright (C) 2006-2008 Edward Z. Yang
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version. version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details. Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
/** /**
* Facade that coordinates HTML Purifier's subsystems in order to purify HTML. * Facade that coordinates HTML Purifier's subsystems in order to purify HTML.
* *
* @note There are several points in which configuration can be specified * @note There are several points in which configuration can be specified
* for HTML Purifier. The precedence of these (from lowest to * for HTML Purifier. The precedence of these (from lowest to
* highest) is as follows: * highest) is as follows:
* -# Instance: new HTMLPurifier($config) * -# Instance: new HTMLPurifier($config)
* -# Invocation: purify($html, $config) * -# Invocation: purify($html, $config)
* These configurations are entirely independent of each other and * These configurations are entirely independent of each other and
* are *not* merged (this behavior may change in the future). * are *not* merged (this behavior may change in the future).
* *
* @todo We need an easier way to inject strategies using the configuration * @todo We need an easier way to inject strategies using the configuration
* object. * object.
*/ */
class HTMLPurifier class HTMLPurifier
{ {
/** /**
* Version of HTML Purifier. * Version of HTML Purifier.
* @type string * @type string
*/ */
public $version = '4.7.0'; public $version = '4.7.0';
/** /**
* Constant with version of HTML Purifier. * Constant with version of HTML Purifier.
*/ */
const VERSION = '4.7.0'; const VERSION = '4.7.0';
/** /**
* Global configuration object. * Global configuration object.
* @type HTMLPurifier_Config * @type HTMLPurifier_Config
*/ */
public $config; public $config;
/** /**
* Array of extra filter objects to run on HTML, * Array of extra filter objects to run on HTML,
* for backwards compatibility. * for backwards compatibility.
* @type HTMLPurifier_Filter[] * @type HTMLPurifier_Filter[]
*/ */
private $filters = array(); private $filters = array();
/** /**
* Single instance of HTML Purifier. * Single instance of HTML Purifier.
* @type HTMLPurifier * @type HTMLPurifier
*/ */
private static $instance; private static $instance;
/** /**
* @type HTMLPurifier_Strategy_Core * @type HTMLPurifier_Strategy_Core
*/ */
protected $strategy; protected $strategy;
/** /**
* @type HTMLPurifier_Generator * @type HTMLPurifier_Generator
*/ */
protected $generator; protected $generator;
/** /**
* Resultant context of last run purification. * Resultant context of last run purification.
* Is an array of contexts if the last called method was purifyArray(). * Is an array of contexts if the last called method was purifyArray().
* @type HTMLPurifier_Context * @type HTMLPurifier_Context
*/ */
public $context; public $context;
/** /**
* Initializes the purifier. * Initializes the purifier.
* *
* @param HTMLPurifier_Config $config Optional HTMLPurifier_Config object * @param HTMLPurifier_Config $config Optional HTMLPurifier_Config object
* for all instances of the purifier, if omitted, a default * for all instances of the purifier, if omitted, a default
* configuration is supplied (which can be overridden on a * configuration is supplied (which can be overridden on a
* per-use basis). * per-use basis).
* The parameter can also be any type that * The parameter can also be any type that
* HTMLPurifier_Config::create() supports. * HTMLPurifier_Config::create() supports.
*/ */
public function __construct($config = null) public function __construct($config = null)
{ {
$this->config = HTMLPurifier_Config::create($config); $this->config = HTMLPurifier_Config::create($config);
$this->strategy = new HTMLPurifier_Strategy_Core(); $this->strategy = new HTMLPurifier_Strategy_Core();
} }
/** /**
* Adds a filter to process the output. First come first serve * Adds a filter to process the output. First come first serve
* *
* @param HTMLPurifier_Filter $filter HTMLPurifier_Filter object * @param HTMLPurifier_Filter $filter HTMLPurifier_Filter object
*/ */
public function addFilter($filter) public function addFilter($filter)
{ {
trigger_error( trigger_error(
'HTMLPurifier->addFilter() is deprecated, use configuration directives' . 'HTMLPurifier->addFilter() is deprecated, use configuration directives' .
' in the Filter namespace or Filter.Custom', ' in the Filter namespace or Filter.Custom',
E_USER_WARNING E_USER_WARNING
); );
$this->filters[] = $filter; $this->filters[] = $filter;
} }
/** /**
* Filters an HTML snippet/document to be XSS-free and standards-compliant. * Filters an HTML snippet/document to be XSS-free and standards-compliant.
* *
* @param string $html String of HTML to purify * @param string $html String of HTML to purify
* @param HTMLPurifier_Config $config Config object for this operation, * @param HTMLPurifier_Config $config Config object for this operation,
* if omitted, defaults to the config object specified during this * if omitted, defaults to the config object specified during this
* object's construction. The parameter can also be any type * object's construction. The parameter can also be any type
* that HTMLPurifier_Config::create() supports. * that HTMLPurifier_Config::create() supports.
* *
* @return string Purified HTML * @return string Purified HTML
*/ */
public function purify($html, $config = null) public function purify($html, $config = null)
{ {
// :TODO: make the config merge in, instead of replace // :TODO: make the config merge in, instead of replace
$config = $config ? HTMLPurifier_Config::create($config) : $this->config; $config = $config ? HTMLPurifier_Config::create($config) : $this->config;
// implementation is partially environment dependant, partially // implementation is partially environment dependant, partially
// configuration dependant // configuration dependant
$lexer = HTMLPurifier_Lexer::create($config); $lexer = HTMLPurifier_Lexer::create($config);
$context = new HTMLPurifier_Context(); $context = new HTMLPurifier_Context();
// setup HTML generator // setup HTML generator
$this->generator = new HTMLPurifier_Generator($config, $context); $this->generator = new HTMLPurifier_Generator($config, $context);
$context->register('Generator', $this->generator); $context->register('Generator', $this->generator);
// set up global context variables // set up global context variables
if ($config->get('Core.CollectErrors')) { if ($config->get('Core.CollectErrors')) {
// may get moved out if other facilities use it // may get moved out if other facilities use it
$language_factory = HTMLPurifier_LanguageFactory::instance(); $language_factory = HTMLPurifier_LanguageFactory::instance();
$language = $language_factory->create($config, $context); $language = $language_factory->create($config, $context);
$context->register('Locale', $language); $context->register('Locale', $language);
$error_collector = new HTMLPurifier_ErrorCollector($context); $error_collector = new HTMLPurifier_ErrorCollector($context);
$context->register('ErrorCollector', $error_collector); $context->register('ErrorCollector', $error_collector);
} }
// setup id_accumulator context, necessary due to the fact that // setup id_accumulator context, necessary due to the fact that
// AttrValidator can be called from many places // AttrValidator can be called from many places
$id_accumulator = HTMLPurifier_IDAccumulator::build($config, $context); $id_accumulator = HTMLPurifier_IDAccumulator::build($config, $context);
$context->register('IDAccumulator', $id_accumulator); $context->register('IDAccumulator', $id_accumulator);
$html = HTMLPurifier_Encoder::convertToUTF8($html, $config, $context); $html = HTMLPurifier_Encoder::convertToUTF8($html, $config, $context);
// setup filters // setup filters
$filter_flags = $config->getBatch('Filter'); $filter_flags = $config->getBatch('Filter');
$custom_filters = $filter_flags['Custom']; $custom_filters = $filter_flags['Custom'];
unset($filter_flags['Custom']); unset($filter_flags['Custom']);
$filters = array(); $filters = array();
foreach ($filter_flags as $filter => $flag) { foreach ($filter_flags as $filter => $flag) {
if (!$flag) { if (!$flag) {
continue; continue;
} }
if (strpos($filter, '.') !== false) { if (strpos($filter, '.') !== false) {
continue; continue;
} }
$class = "HTMLPurifier_Filter_$filter"; $class = "HTMLPurifier_Filter_$filter";
$filters[] = new $class; $filters[] = new $class;
} }
foreach ($custom_filters as $filter) { foreach ($custom_filters as $filter) {
// maybe "HTMLPurifier_Filter_$filter", but be consistent with AutoFormat // maybe "HTMLPurifier_Filter_$filter", but be consistent with AutoFormat
$filters[] = $filter; $filters[] = $filter;
} }
$filters = array_merge($filters, $this->filters); $filters = array_merge($filters, $this->filters);
// maybe prepare(), but later // maybe prepare(), but later
for ($i = 0, $filter_size = count($filters); $i < $filter_size; $i++) { for ($i = 0, $filter_size = count($filters); $i < $filter_size; $i++) {
$html = $filters[$i]->preFilter($html, $config, $context); $html = $filters[$i]->preFilter($html, $config, $context);
} }
// purified HTML // purified HTML
$html = $html =
$this->generator->generateFromTokens( $this->generator->generateFromTokens(
// list of tokens // list of tokens
$this->strategy->execute( $this->strategy->execute(
// list of un-purified tokens // list of un-purified tokens
$lexer->tokenizeHTML( $lexer->tokenizeHTML(
// un-purified HTML // un-purified HTML
$html, $html,
$config, $config,
$context $context
), ),
$config, $config,
$context $context
) )
); );
for ($i = $filter_size - 1; $i >= 0; $i--) { for ($i = $filter_size - 1; $i >= 0; $i--) {
$html = $filters[$i]->postFilter($html, $config, $context); $html = $filters[$i]->postFilter($html, $config, $context);
} }
$html = HTMLPurifier_Encoder::convertFromUTF8($html, $config, $context); $html = HTMLPurifier_Encoder::convertFromUTF8($html, $config, $context);
$this->context =& $context; $this->context =& $context;
return $html; return $html;
} }
/** /**
* Filters an array of HTML snippets * Filters an array of HTML snippets
* *
* @param string[] $array_of_html Array of html snippets * @param string[] $array_of_html Array of html snippets
* @param HTMLPurifier_Config $config Optional config object for this operation. * @param HTMLPurifier_Config $config Optional config object for this operation.
* See HTMLPurifier::purify() for more details. * See HTMLPurifier::purify() for more details.
* *
* @return string[] Array of purified HTML * @return string[] Array of purified HTML
*/ */
public function purifyArray($array_of_html, $config = null) public function purifyArray($array_of_html, $config = null)
{ {
$context_array = array(); $context_array = array();
foreach ($array_of_html as $key => $html) { foreach ($array_of_html as $key => $html) {
$array_of_html[$key] = $this->purify($html, $config); $array_of_html[$key] = $this->purify($html, $config);
$context_array[$key] = $this->context; $context_array[$key] = $this->context;
} }
$this->context = $context_array; $this->context = $context_array;
return $array_of_html; return $array_of_html;
} }
/** /**
* Singleton for enforcing just one HTML Purifier in your system * Singleton for enforcing just one HTML Purifier in your system
* *
* @param HTMLPurifier|HTMLPurifier_Config $prototype Optional prototype * @param HTMLPurifier|HTMLPurifier_Config $prototype Optional prototype
* HTMLPurifier instance to overload singleton with, * HTMLPurifier instance to overload singleton with,
* or HTMLPurifier_Config instance to configure the * or HTMLPurifier_Config instance to configure the
* generated version with. * generated version with.
* *
* @return HTMLPurifier * @return HTMLPurifier
*/ */
public static function instance($prototype = null) public static function instance($prototype = null)
{ {
if (!self::$instance || $prototype) { if (!self::$instance || $prototype) {
if ($prototype instanceof HTMLPurifier) { if ($prototype instanceof HTMLPurifier) {
self::$instance = $prototype; self::$instance = $prototype;
} elseif ($prototype) { } elseif ($prototype) {
self::$instance = new HTMLPurifier($prototype); self::$instance = new HTMLPurifier($prototype);
} else { } else {
self::$instance = new HTMLPurifier(); self::$instance = new HTMLPurifier();
} }
} }
return self::$instance; return self::$instance;
} }
/** /**
* Singleton for enforcing just one HTML Purifier in your system * Singleton for enforcing just one HTML Purifier in your system
* *
* @param HTMLPurifier|HTMLPurifier_Config $prototype Optional prototype * @param HTMLPurifier|HTMLPurifier_Config $prototype Optional prototype
* HTMLPurifier instance to overload singleton with, * HTMLPurifier instance to overload singleton with,
* or HTMLPurifier_Config instance to configure the * or HTMLPurifier_Config instance to configure the
* generated version with. * generated version with.
* *
* @return HTMLPurifier * @return HTMLPurifier
* @note Backwards compatibility, see instance() * @note Backwards compatibility, see instance()
*/ */
public static function getInstance($prototype = null) public static function getInstance($prototype = null)
{ {
return HTMLPurifier::instance($prototype); return HTMLPurifier::instance($prototype);
} }
} }
// vim: et sw=4 sts=4 // vim: et sw=4 sts=4

@ -1,223 +1,223 @@
<?php <?php
/** /**
* @file * @file
* This file was auto-generated by generate-includes.php and includes all of * This file was auto-generated by generate-includes.php and includes all of
* the core files required by HTML Purifier. This is a convenience stub that * 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 * 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. * EDIT THIS FILE, changes will be overwritten the next time the script is run.
* *
* Changes to include_path are not necessary. * Changes to include_path are not necessary.
*/ */
$__dir = dirname(__FILE__); $__dir = dirname(__FILE__);
require_once $__dir . '/HTMLPurifier.php'; require_once $__dir . '/HTMLPurifier.php';
require_once $__dir . '/HTMLPurifier/Arborize.php'; require_once $__dir . '/HTMLPurifier/Arborize.php';
require_once $__dir . '/HTMLPurifier/AttrCollections.php'; require_once $__dir . '/HTMLPurifier/AttrCollections.php';
require_once $__dir . '/HTMLPurifier/AttrDef.php'; require_once $__dir . '/HTMLPurifier/AttrDef.php';
require_once $__dir . '/HTMLPurifier/AttrTransform.php'; require_once $__dir . '/HTMLPurifier/AttrTransform.php';
require_once $__dir . '/HTMLPurifier/AttrTypes.php'; require_once $__dir . '/HTMLPurifier/AttrTypes.php';
require_once $__dir . '/HTMLPurifier/AttrValidator.php'; require_once $__dir . '/HTMLPurifier/AttrValidator.php';
require_once $__dir . '/HTMLPurifier/Bootstrap.php'; require_once $__dir . '/HTMLPurifier/Bootstrap.php';
require_once $__dir . '/HTMLPurifier/Definition.php'; require_once $__dir . '/HTMLPurifier/Definition.php';
require_once $__dir . '/HTMLPurifier/CSSDefinition.php'; require_once $__dir . '/HTMLPurifier/CSSDefinition.php';
require_once $__dir . '/HTMLPurifier/ChildDef.php'; require_once $__dir . '/HTMLPurifier/ChildDef.php';
require_once $__dir . '/HTMLPurifier/Config.php'; require_once $__dir . '/HTMLPurifier/Config.php';
require_once $__dir . '/HTMLPurifier/ConfigSchema.php'; require_once $__dir . '/HTMLPurifier/ConfigSchema.php';
require_once $__dir . '/HTMLPurifier/ContentSets.php'; require_once $__dir . '/HTMLPurifier/ContentSets.php';
require_once $__dir . '/HTMLPurifier/Context.php'; require_once $__dir . '/HTMLPurifier/Context.php';
require_once $__dir . '/HTMLPurifier/DefinitionCache.php'; require_once $__dir . '/HTMLPurifier/DefinitionCache.php';
require_once $__dir . '/HTMLPurifier/DefinitionCacheFactory.php'; require_once $__dir . '/HTMLPurifier/DefinitionCacheFactory.php';
require_once $__dir . '/HTMLPurifier/Doctype.php'; require_once $__dir . '/HTMLPurifier/Doctype.php';
require_once $__dir . '/HTMLPurifier/DoctypeRegistry.php'; require_once $__dir . '/HTMLPurifier/DoctypeRegistry.php';
require_once $__dir . '/HTMLPurifier/ElementDef.php'; require_once $__dir . '/HTMLPurifier/ElementDef.php';
require_once $__dir . '/HTMLPurifier/Encoder.php'; require_once $__dir . '/HTMLPurifier/Encoder.php';
require_once $__dir . '/HTMLPurifier/EntityLookup.php'; require_once $__dir . '/HTMLPurifier/EntityLookup.php';
require_once $__dir . '/HTMLPurifier/EntityParser.php'; require_once $__dir . '/HTMLPurifier/EntityParser.php';
require_once $__dir . '/HTMLPurifier/ErrorCollector.php'; require_once $__dir . '/HTMLPurifier/ErrorCollector.php';
require_once $__dir . '/HTMLPurifier/ErrorStruct.php'; require_once $__dir . '/HTMLPurifier/ErrorStruct.php';
require_once $__dir . '/HTMLPurifier/Exception.php'; require_once $__dir . '/HTMLPurifier/Exception.php';
require_once $__dir . '/HTMLPurifier/Filter.php'; require_once $__dir . '/HTMLPurifier/Filter.php';
require_once $__dir . '/HTMLPurifier/Generator.php'; require_once $__dir . '/HTMLPurifier/Generator.php';
require_once $__dir . '/HTMLPurifier/HTMLDefinition.php'; require_once $__dir . '/HTMLPurifier/HTMLDefinition.php';
require_once $__dir . '/HTMLPurifier/HTMLModule.php'; require_once $__dir . '/HTMLPurifier/HTMLModule.php';
require_once $__dir . '/HTMLPurifier/HTMLModuleManager.php'; require_once $__dir . '/HTMLPurifier/HTMLModuleManager.php';
require_once $__dir . '/HTMLPurifier/IDAccumulator.php'; require_once $__dir . '/HTMLPurifier/IDAccumulator.php';
require_once $__dir . '/HTMLPurifier/Injector.php'; require_once $__dir . '/HTMLPurifier/Injector.php';
require_once $__dir . '/HTMLPurifier/Language.php'; require_once $__dir . '/HTMLPurifier/Language.php';
require_once $__dir . '/HTMLPurifier/LanguageFactory.php'; require_once $__dir . '/HTMLPurifier/LanguageFactory.php';
require_once $__dir . '/HTMLPurifier/Length.php'; require_once $__dir . '/HTMLPurifier/Length.php';
require_once $__dir . '/HTMLPurifier/Lexer.php'; require_once $__dir . '/HTMLPurifier/Lexer.php';
require_once $__dir . '/HTMLPurifier/Node.php'; require_once $__dir . '/HTMLPurifier/Node.php';
require_once $__dir . '/HTMLPurifier/PercentEncoder.php'; require_once $__dir . '/HTMLPurifier/PercentEncoder.php';
require_once $__dir . '/HTMLPurifier/PropertyList.php'; require_once $__dir . '/HTMLPurifier/PropertyList.php';
require_once $__dir . '/HTMLPurifier/PropertyListIterator.php'; require_once $__dir . '/HTMLPurifier/PropertyListIterator.php';
require_once $__dir . '/HTMLPurifier/Queue.php'; require_once $__dir . '/HTMLPurifier/Queue.php';
require_once $__dir . '/HTMLPurifier/Strategy.php'; require_once $__dir . '/HTMLPurifier/Strategy.php';
require_once $__dir . '/HTMLPurifier/StringHash.php'; require_once $__dir . '/HTMLPurifier/StringHash.php';
require_once $__dir . '/HTMLPurifier/StringHashParser.php'; require_once $__dir . '/HTMLPurifier/StringHashParser.php';
require_once $__dir . '/HTMLPurifier/TagTransform.php'; require_once $__dir . '/HTMLPurifier/TagTransform.php';
require_once $__dir . '/HTMLPurifier/Token.php'; require_once $__dir . '/HTMLPurifier/Token.php';
require_once $__dir . '/HTMLPurifier/TokenFactory.php'; require_once $__dir . '/HTMLPurifier/TokenFactory.php';
require_once $__dir . '/HTMLPurifier/URI.php'; require_once $__dir . '/HTMLPurifier/URI.php';
require_once $__dir . '/HTMLPurifier/URIDefinition.php'; require_once $__dir . '/HTMLPurifier/URIDefinition.php';
require_once $__dir . '/HTMLPurifier/URIFilter.php'; require_once $__dir . '/HTMLPurifier/URIFilter.php';
require_once $__dir . '/HTMLPurifier/URIParser.php'; require_once $__dir . '/HTMLPurifier/URIParser.php';
require_once $__dir . '/HTMLPurifier/URIScheme.php'; require_once $__dir . '/HTMLPurifier/URIScheme.php';
require_once $__dir . '/HTMLPurifier/URISchemeRegistry.php'; require_once $__dir . '/HTMLPurifier/URISchemeRegistry.php';
require_once $__dir . '/HTMLPurifier/UnitConverter.php'; require_once $__dir . '/HTMLPurifier/UnitConverter.php';
require_once $__dir . '/HTMLPurifier/VarParser.php'; require_once $__dir . '/HTMLPurifier/VarParser.php';
require_once $__dir . '/HTMLPurifier/VarParserException.php'; require_once $__dir . '/HTMLPurifier/VarParserException.php';
require_once $__dir . '/HTMLPurifier/Zipper.php'; require_once $__dir . '/HTMLPurifier/Zipper.php';
require_once $__dir . '/HTMLPurifier/AttrDef/CSS.php'; require_once $__dir . '/HTMLPurifier/AttrDef/CSS.php';
require_once $__dir . '/HTMLPurifier/AttrDef/Clone.php'; require_once $__dir . '/HTMLPurifier/AttrDef/Clone.php';
require_once $__dir . '/HTMLPurifier/AttrDef/Enum.php'; require_once $__dir . '/HTMLPurifier/AttrDef/Enum.php';
require_once $__dir . '/HTMLPurifier/AttrDef/Integer.php'; require_once $__dir . '/HTMLPurifier/AttrDef/Integer.php';
require_once $__dir . '/HTMLPurifier/AttrDef/Lang.php'; require_once $__dir . '/HTMLPurifier/AttrDef/Lang.php';
require_once $__dir . '/HTMLPurifier/AttrDef/Switch.php'; require_once $__dir . '/HTMLPurifier/AttrDef/Switch.php';
require_once $__dir . '/HTMLPurifier/AttrDef/Text.php'; require_once $__dir . '/HTMLPurifier/AttrDef/Text.php';
require_once $__dir . '/HTMLPurifier/AttrDef/URI.php'; require_once $__dir . '/HTMLPurifier/AttrDef/URI.php';
require_once $__dir . '/HTMLPurifier/AttrDef/CSS/Number.php'; require_once $__dir . '/HTMLPurifier/AttrDef/CSS/Number.php';
require_once $__dir . '/HTMLPurifier/AttrDef/CSS/AlphaValue.php'; require_once $__dir . '/HTMLPurifier/AttrDef/CSS/AlphaValue.php';
require_once $__dir . '/HTMLPurifier/AttrDef/CSS/Background.php'; require_once $__dir . '/HTMLPurifier/AttrDef/CSS/Background.php';
require_once $__dir . '/HTMLPurifier/AttrDef/CSS/BackgroundPosition.php'; require_once $__dir . '/HTMLPurifier/AttrDef/CSS/BackgroundPosition.php';
require_once $__dir . '/HTMLPurifier/AttrDef/CSS/Border.php'; require_once $__dir . '/HTMLPurifier/AttrDef/CSS/Border.php';
require_once $__dir . '/HTMLPurifier/AttrDef/CSS/Color.php'; require_once $__dir . '/HTMLPurifier/AttrDef/CSS/Color.php';
require_once $__dir . '/HTMLPurifier/AttrDef/CSS/Composite.php'; require_once $__dir . '/HTMLPurifier/AttrDef/CSS/Composite.php';
require_once $__dir . '/HTMLPurifier/AttrDef/CSS/DenyElementDecorator.php'; require_once $__dir . '/HTMLPurifier/AttrDef/CSS/DenyElementDecorator.php';
require_once $__dir . '/HTMLPurifier/AttrDef/CSS/Filter.php'; require_once $__dir . '/HTMLPurifier/AttrDef/CSS/Filter.php';
require_once $__dir . '/HTMLPurifier/AttrDef/CSS/Font.php'; require_once $__dir . '/HTMLPurifier/AttrDef/CSS/Font.php';
require_once $__dir . '/HTMLPurifier/AttrDef/CSS/FontFamily.php'; require_once $__dir . '/HTMLPurifier/AttrDef/CSS/FontFamily.php';
require_once $__dir . '/HTMLPurifier/AttrDef/CSS/Ident.php'; require_once $__dir . '/HTMLPurifier/AttrDef/CSS/Ident.php';
require_once $__dir . '/HTMLPurifier/AttrDef/CSS/ImportantDecorator.php'; require_once $__dir . '/HTMLPurifier/AttrDef/CSS/ImportantDecorator.php';
require_once $__dir . '/HTMLPurifier/AttrDef/CSS/Length.php'; require_once $__dir . '/HTMLPurifier/AttrDef/CSS/Length.php';
require_once $__dir . '/HTMLPurifier/AttrDef/CSS/ListStyle.php'; require_once $__dir . '/HTMLPurifier/AttrDef/CSS/ListStyle.php';
require_once $__dir . '/HTMLPurifier/AttrDef/CSS/Multiple.php'; require_once $__dir . '/HTMLPurifier/AttrDef/CSS/Multiple.php';
require_once $__dir . '/HTMLPurifier/AttrDef/CSS/Percentage.php'; require_once $__dir . '/HTMLPurifier/AttrDef/CSS/Percentage.php';
require_once $__dir . '/HTMLPurifier/AttrDef/CSS/TextDecoration.php'; require_once $__dir . '/HTMLPurifier/AttrDef/CSS/TextDecoration.php';
require_once $__dir . '/HTMLPurifier/AttrDef/CSS/URI.php'; require_once $__dir . '/HTMLPurifier/AttrDef/CSS/URI.php';
require_once $__dir . '/HTMLPurifier/AttrDef/HTML/Bool.php'; require_once $__dir . '/HTMLPurifier/AttrDef/HTML/Bool.php';
require_once $__dir . '/HTMLPurifier/AttrDef/HTML/Nmtokens.php'; require_once $__dir . '/HTMLPurifier/AttrDef/HTML/Nmtokens.php';
require_once $__dir . '/HTMLPurifier/AttrDef/HTML/Class.php'; require_once $__dir . '/HTMLPurifier/AttrDef/HTML/Class.php';
require_once $__dir . '/HTMLPurifier/AttrDef/HTML/Color.php'; require_once $__dir . '/HTMLPurifier/AttrDef/HTML/Color.php';
require_once $__dir . '/HTMLPurifier/AttrDef/HTML/FrameTarget.php'; require_once $__dir . '/HTMLPurifier/AttrDef/HTML/FrameTarget.php';
require_once $__dir . '/HTMLPurifier/AttrDef/HTML/ID.php'; require_once $__dir . '/HTMLPurifier/AttrDef/HTML/ID.php';
require_once $__dir . '/HTMLPurifier/AttrDef/HTML/Pixels.php'; require_once $__dir . '/HTMLPurifier/AttrDef/HTML/Pixels.php';
require_once $__dir . '/HTMLPurifier/AttrDef/HTML/Length.php'; require_once $__dir . '/HTMLPurifier/AttrDef/HTML/Length.php';
require_once $__dir . '/HTMLPurifier/AttrDef/HTML/LinkTypes.php'; require_once $__dir . '/HTMLPurifier/AttrDef/HTML/LinkTypes.php';
require_once $__dir . '/HTMLPurifier/AttrDef/HTML/MultiLength.php'; require_once $__dir . '/HTMLPurifier/AttrDef/HTML/MultiLength.php';
require_once $__dir . '/HTMLPurifier/AttrDef/URI/Email.php'; require_once $__dir . '/HTMLPurifier/AttrDef/URI/Email.php';
require_once $__dir . '/HTMLPurifier/AttrDef/URI/Host.php'; require_once $__dir . '/HTMLPurifier/AttrDef/URI/Host.php';
require_once $__dir . '/HTMLPurifier/AttrDef/URI/IPv4.php'; require_once $__dir . '/HTMLPurifier/AttrDef/URI/IPv4.php';
require_once $__dir . '/HTMLPurifier/AttrDef/URI/IPv6.php'; require_once $__dir . '/HTMLPurifier/AttrDef/URI/IPv6.php';
require_once $__dir . '/HTMLPurifier/AttrDef/URI/Email/SimpleCheck.php'; require_once $__dir . '/HTMLPurifier/AttrDef/URI/Email/SimpleCheck.php';
require_once $__dir . '/HTMLPurifier/AttrTransform/Background.php'; require_once $__dir . '/HTMLPurifier/AttrTransform/Background.php';
require_once $__dir . '/HTMLPurifier/AttrTransform/BdoDir.php'; require_once $__dir . '/HTMLPurifier/AttrTransform/BdoDir.php';
require_once $__dir . '/HTMLPurifier/AttrTransform/BgColor.php'; require_once $__dir . '/HTMLPurifier/AttrTransform/BgColor.php';
require_once $__dir . '/HTMLPurifier/AttrTransform/BoolToCSS.php'; require_once $__dir . '/HTMLPurifier/AttrTransform/BoolToCSS.php';
require_once $__dir . '/HTMLPurifier/AttrTransform/Border.php'; require_once $__dir . '/HTMLPurifier/AttrTransform/Border.php';
require_once $__dir . '/HTMLPurifier/AttrTransform/EnumToCSS.php'; require_once $__dir . '/HTMLPurifier/AttrTransform/EnumToCSS.php';
require_once $__dir . '/HTMLPurifier/AttrTransform/ImgRequired.php'; require_once $__dir . '/HTMLPurifier/AttrTransform/ImgRequired.php';
require_once $__dir . '/HTMLPurifier/AttrTransform/ImgSpace.php'; require_once $__dir . '/HTMLPurifier/AttrTransform/ImgSpace.php';
require_once $__dir . '/HTMLPurifier/AttrTransform/Input.php'; require_once $__dir . '/HTMLPurifier/AttrTransform/Input.php';
require_once $__dir . '/HTMLPurifier/AttrTransform/Lang.php'; require_once $__dir . '/HTMLPurifier/AttrTransform/Lang.php';
require_once $__dir . '/HTMLPurifier/AttrTransform/Length.php'; require_once $__dir . '/HTMLPurifier/AttrTransform/Length.php';
require_once $__dir . '/HTMLPurifier/AttrTransform/Name.php'; require_once $__dir . '/HTMLPurifier/AttrTransform/Name.php';
require_once $__dir . '/HTMLPurifier/AttrTransform/NameSync.php'; require_once $__dir . '/HTMLPurifier/AttrTransform/NameSync.php';
require_once $__dir . '/HTMLPurifier/AttrTransform/Nofollow.php'; require_once $__dir . '/HTMLPurifier/AttrTransform/Nofollow.php';
require_once $__dir . '/HTMLPurifier/AttrTransform/SafeEmbed.php'; require_once $__dir . '/HTMLPurifier/AttrTransform/SafeEmbed.php';
require_once $__dir . '/HTMLPurifier/AttrTransform/SafeObject.php'; require_once $__dir . '/HTMLPurifier/AttrTransform/SafeObject.php';
require_once $__dir . '/HTMLPurifier/AttrTransform/SafeParam.php'; require_once $__dir . '/HTMLPurifier/AttrTransform/SafeParam.php';
require_once $__dir . '/HTMLPurifier/AttrTransform/ScriptRequired.php'; require_once $__dir . '/HTMLPurifier/AttrTransform/ScriptRequired.php';
require_once $__dir . '/HTMLPurifier/AttrTransform/TargetBlank.php'; require_once $__dir . '/HTMLPurifier/AttrTransform/TargetBlank.php';
require_once $__dir . '/HTMLPurifier/AttrTransform/Textarea.php'; require_once $__dir . '/HTMLPurifier/AttrTransform/Textarea.php';
require_once $__dir . '/HTMLPurifier/ChildDef/Chameleon.php'; require_once $__dir . '/HTMLPurifier/ChildDef/Chameleon.php';
require_once $__dir . '/HTMLPurifier/ChildDef/Custom.php'; require_once $__dir . '/HTMLPurifier/ChildDef/Custom.php';
require_once $__dir . '/HTMLPurifier/ChildDef/Empty.php'; require_once $__dir . '/HTMLPurifier/ChildDef/Empty.php';
require_once $__dir . '/HTMLPurifier/ChildDef/List.php'; require_once $__dir . '/HTMLPurifier/ChildDef/List.php';
require_once $__dir . '/HTMLPurifier/ChildDef/Required.php'; require_once $__dir . '/HTMLPurifier/ChildDef/Required.php';
require_once $__dir . '/HTMLPurifier/ChildDef/Optional.php'; require_once $__dir . '/HTMLPurifier/ChildDef/Optional.php';
require_once $__dir . '/HTMLPurifier/ChildDef/StrictBlockquote.php'; require_once $__dir . '/HTMLPurifier/ChildDef/StrictBlockquote.php';
require_once $__dir . '/HTMLPurifier/ChildDef/Table.php'; require_once $__dir . '/HTMLPurifier/ChildDef/Table.php';
require_once $__dir . '/HTMLPurifier/DefinitionCache/Decorator.php'; require_once $__dir . '/HTMLPurifier/DefinitionCache/Decorator.php';
require_once $__dir . '/HTMLPurifier/DefinitionCache/Null.php'; require_once $__dir . '/HTMLPurifier/DefinitionCache/Null.php';
require_once $__dir . '/HTMLPurifier/DefinitionCache/Serializer.php'; require_once $__dir . '/HTMLPurifier/DefinitionCache/Serializer.php';
require_once $__dir . '/HTMLPurifier/DefinitionCache/Decorator/Cleanup.php'; require_once $__dir . '/HTMLPurifier/DefinitionCache/Decorator/Cleanup.php';
require_once $__dir . '/HTMLPurifier/DefinitionCache/Decorator/Memory.php'; require_once $__dir . '/HTMLPurifier/DefinitionCache/Decorator/Memory.php';
require_once $__dir . '/HTMLPurifier/HTMLModule/Bdo.php'; require_once $__dir . '/HTMLPurifier/HTMLModule/Bdo.php';
require_once $__dir . '/HTMLPurifier/HTMLModule/CommonAttributes.php'; require_once $__dir . '/HTMLPurifier/HTMLModule/CommonAttributes.php';
require_once $__dir . '/HTMLPurifier/HTMLModule/Edit.php'; require_once $__dir . '/HTMLPurifier/HTMLModule/Edit.php';
require_once $__dir . '/HTMLPurifier/HTMLModule/Forms.php'; require_once $__dir . '/HTMLPurifier/HTMLModule/Forms.php';
require_once $__dir . '/HTMLPurifier/HTMLModule/Hypertext.php'; require_once $__dir . '/HTMLPurifier/HTMLModule/Hypertext.php';
require_once $__dir . '/HTMLPurifier/HTMLModule/Iframe.php'; require_once $__dir . '/HTMLPurifier/HTMLModule/Iframe.php';
require_once $__dir . '/HTMLPurifier/HTMLModule/Image.php'; require_once $__dir . '/HTMLPurifier/HTMLModule/Image.php';
require_once $__dir . '/HTMLPurifier/HTMLModule/Legacy.php'; require_once $__dir . '/HTMLPurifier/HTMLModule/Legacy.php';
require_once $__dir . '/HTMLPurifier/HTMLModule/List.php'; require_once $__dir . '/HTMLPurifier/HTMLModule/List.php';
require_once $__dir . '/HTMLPurifier/HTMLModule/Name.php'; require_once $__dir . '/HTMLPurifier/HTMLModule/Name.php';
require_once $__dir . '/HTMLPurifier/HTMLModule/Nofollow.php'; require_once $__dir . '/HTMLPurifier/HTMLModule/Nofollow.php';
require_once $__dir . '/HTMLPurifier/HTMLModule/NonXMLCommonAttributes.php'; require_once $__dir . '/HTMLPurifier/HTMLModule/NonXMLCommonAttributes.php';
require_once $__dir . '/HTMLPurifier/HTMLModule/Object.php'; require_once $__dir . '/HTMLPurifier/HTMLModule/Object.php';
require_once $__dir . '/HTMLPurifier/HTMLModule/Presentation.php'; require_once $__dir . '/HTMLPurifier/HTMLModule/Presentation.php';
require_once $__dir . '/HTMLPurifier/HTMLModule/Proprietary.php'; require_once $__dir . '/HTMLPurifier/HTMLModule/Proprietary.php';
require_once $__dir . '/HTMLPurifier/HTMLModule/Ruby.php'; require_once $__dir . '/HTMLPurifier/HTMLModule/Ruby.php';
require_once $__dir . '/HTMLPurifier/HTMLModule/SafeEmbed.php'; require_once $__dir . '/HTMLPurifier/HTMLModule/SafeEmbed.php';
require_once $__dir . '/HTMLPurifier/HTMLModule/SafeObject.php'; require_once $__dir . '/HTMLPurifier/HTMLModule/SafeObject.php';
require_once $__dir . '/HTMLPurifier/HTMLModule/SafeScripting.php'; require_once $__dir . '/HTMLPurifier/HTMLModule/SafeScripting.php';
require_once $__dir . '/HTMLPurifier/HTMLModule/Scripting.php'; require_once $__dir . '/HTMLPurifier/HTMLModule/Scripting.php';
require_once $__dir . '/HTMLPurifier/HTMLModule/StyleAttribute.php'; require_once $__dir . '/HTMLPurifier/HTMLModule/StyleAttribute.php';
require_once $__dir . '/HTMLPurifier/HTMLModule/Tables.php'; require_once $__dir . '/HTMLPurifier/HTMLModule/Tables.php';
require_once $__dir . '/HTMLPurifier/HTMLModule/Target.php'; require_once $__dir . '/HTMLPurifier/HTMLModule/Target.php';
require_once $__dir . '/HTMLPurifier/HTMLModule/TargetBlank.php'; require_once $__dir . '/HTMLPurifier/HTMLModule/TargetBlank.php';
require_once $__dir . '/HTMLPurifier/HTMLModule/Text.php'; require_once $__dir . '/HTMLPurifier/HTMLModule/Text.php';
require_once $__dir . '/HTMLPurifier/HTMLModule/Tidy.php'; require_once $__dir . '/HTMLPurifier/HTMLModule/Tidy.php';
require_once $__dir . '/HTMLPurifier/HTMLModule/XMLCommonAttributes.php'; require_once $__dir . '/HTMLPurifier/HTMLModule/XMLCommonAttributes.php';
require_once $__dir . '/HTMLPurifier/HTMLModule/Tidy/Name.php'; require_once $__dir . '/HTMLPurifier/HTMLModule/Tidy/Name.php';
require_once $__dir . '/HTMLPurifier/HTMLModule/Tidy/Proprietary.php'; require_once $__dir . '/HTMLPurifier/HTMLModule/Tidy/Proprietary.php';
require_once $__dir . '/HTMLPurifier/HTMLModule/Tidy/XHTMLAndHTML4.php'; require_once $__dir . '/HTMLPurifier/HTMLModule/Tidy/XHTMLAndHTML4.php';
require_once $__dir . '/HTMLPurifier/HTMLModule/Tidy/Strict.php'; require_once $__dir . '/HTMLPurifier/HTMLModule/Tidy/Strict.php';
require_once $__dir . '/HTMLPurifier/HTMLModule/Tidy/Transitional.php'; require_once $__dir . '/HTMLPurifier/HTMLModule/Tidy/Transitional.php';
require_once $__dir . '/HTMLPurifier/HTMLModule/Tidy/XHTML.php'; require_once $__dir . '/HTMLPurifier/HTMLModule/Tidy/XHTML.php';
require_once $__dir . '/HTMLPurifier/Injector/AutoParagraph.php'; require_once $__dir . '/HTMLPurifier/Injector/AutoParagraph.php';
require_once $__dir . '/HTMLPurifier/Injector/DisplayLinkURI.php'; require_once $__dir . '/HTMLPurifier/Injector/DisplayLinkURI.php';
require_once $__dir . '/HTMLPurifier/Injector/Linkify.php'; require_once $__dir . '/HTMLPurifier/Injector/Linkify.php';
require_once $__dir . '/HTMLPurifier/Injector/PurifierLinkify.php'; require_once $__dir . '/HTMLPurifier/Injector/PurifierLinkify.php';
require_once $__dir . '/HTMLPurifier/Injector/RemoveEmpty.php'; require_once $__dir . '/HTMLPurifier/Injector/RemoveEmpty.php';
require_once $__dir . '/HTMLPurifier/Injector/RemoveSpansWithoutAttributes.php'; require_once $__dir . '/HTMLPurifier/Injector/RemoveSpansWithoutAttributes.php';
require_once $__dir . '/HTMLPurifier/Injector/SafeObject.php'; require_once $__dir . '/HTMLPurifier/Injector/SafeObject.php';
require_once $__dir . '/HTMLPurifier/Lexer/DOMLex.php'; require_once $__dir . '/HTMLPurifier/Lexer/DOMLex.php';
require_once $__dir . '/HTMLPurifier/Lexer/DirectLex.php'; require_once $__dir . '/HTMLPurifier/Lexer/DirectLex.php';
require_once $__dir . '/HTMLPurifier/Node/Comment.php'; require_once $__dir . '/HTMLPurifier/Node/Comment.php';
require_once $__dir . '/HTMLPurifier/Node/Element.php'; require_once $__dir . '/HTMLPurifier/Node/Element.php';
require_once $__dir . '/HTMLPurifier/Node/Text.php'; require_once $__dir . '/HTMLPurifier/Node/Text.php';
require_once $__dir . '/HTMLPurifier/Strategy/Composite.php'; require_once $__dir . '/HTMLPurifier/Strategy/Composite.php';
require_once $__dir . '/HTMLPurifier/Strategy/Core.php'; require_once $__dir . '/HTMLPurifier/Strategy/Core.php';
require_once $__dir . '/HTMLPurifier/Strategy/FixNesting.php'; require_once $__dir . '/HTMLPurifier/Strategy/FixNesting.php';
require_once $__dir . '/HTMLPurifier/Strategy/MakeWellFormed.php'; require_once $__dir . '/HTMLPurifier/Strategy/MakeWellFormed.php';
require_once $__dir . '/HTMLPurifier/Strategy/RemoveForeignElements.php'; require_once $__dir . '/HTMLPurifier/Strategy/RemoveForeignElements.php';
require_once $__dir . '/HTMLPurifier/Strategy/ValidateAttributes.php'; require_once $__dir . '/HTMLPurifier/Strategy/ValidateAttributes.php';
require_once $__dir . '/HTMLPurifier/TagTransform/Font.php'; require_once $__dir . '/HTMLPurifier/TagTransform/Font.php';
require_once $__dir . '/HTMLPurifier/TagTransform/Simple.php'; require_once $__dir . '/HTMLPurifier/TagTransform/Simple.php';
require_once $__dir . '/HTMLPurifier/Token/Comment.php'; require_once $__dir . '/HTMLPurifier/Token/Comment.php';
require_once $__dir . '/HTMLPurifier/Token/Tag.php'; require_once $__dir . '/HTMLPurifier/Token/Tag.php';
require_once $__dir . '/HTMLPurifier/Token/Empty.php'; require_once $__dir . '/HTMLPurifier/Token/Empty.php';
require_once $__dir . '/HTMLPurifier/Token/End.php'; require_once $__dir . '/HTMLPurifier/Token/End.php';
require_once $__dir . '/HTMLPurifier/Token/Start.php'; require_once $__dir . '/HTMLPurifier/Token/Start.php';
require_once $__dir . '/HTMLPurifier/Token/Text.php'; require_once $__dir . '/HTMLPurifier/Token/Text.php';
require_once $__dir . '/HTMLPurifier/URIFilter/DisableExternal.php'; require_once $__dir . '/HTMLPurifier/URIFilter/DisableExternal.php';
require_once $__dir . '/HTMLPurifier/URIFilter/DisableExternalResources.php'; require_once $__dir . '/HTMLPurifier/URIFilter/DisableExternalResources.php';
require_once $__dir . '/HTMLPurifier/URIFilter/DisableResources.php'; require_once $__dir . '/HTMLPurifier/URIFilter/DisableResources.php';
require_once $__dir . '/HTMLPurifier/URIFilter/HostBlacklist.php'; require_once $__dir . '/HTMLPurifier/URIFilter/HostBlacklist.php';
require_once $__dir . '/HTMLPurifier/URIFilter/MakeAbsolute.php'; require_once $__dir . '/HTMLPurifier/URIFilter/MakeAbsolute.php';
require_once $__dir . '/HTMLPurifier/URIFilter/Munge.php'; require_once $__dir . '/HTMLPurifier/URIFilter/Munge.php';
require_once $__dir . '/HTMLPurifier/URIFilter/SafeIframe.php'; require_once $__dir . '/HTMLPurifier/URIFilter/SafeIframe.php';
require_once $__dir . '/HTMLPurifier/URIScheme/data.php'; require_once $__dir . '/HTMLPurifier/URIScheme/data.php';
require_once $__dir . '/HTMLPurifier/URIScheme/file.php'; require_once $__dir . '/HTMLPurifier/URIScheme/file.php';
require_once $__dir . '/HTMLPurifier/URIScheme/ftp.php'; require_once $__dir . '/HTMLPurifier/URIScheme/ftp.php';
require_once $__dir . '/HTMLPurifier/URIScheme/http.php'; require_once $__dir . '/HTMLPurifier/URIScheme/http.php';
require_once $__dir . '/HTMLPurifier/URIScheme/https.php'; require_once $__dir . '/HTMLPurifier/URIScheme/https.php';
require_once $__dir . '/HTMLPurifier/URIScheme/mailto.php'; require_once $__dir . '/HTMLPurifier/URIScheme/mailto.php';
require_once $__dir . '/HTMLPurifier/URIScheme/news.php'; require_once $__dir . '/HTMLPurifier/URIScheme/news.php';
require_once $__dir . '/HTMLPurifier/URIScheme/nntp.php'; require_once $__dir . '/HTMLPurifier/URIScheme/nntp.php';
require_once $__dir . '/HTMLPurifier/VarParser/Flexible.php'; require_once $__dir . '/HTMLPurifier/VarParser/Flexible.php';
require_once $__dir . '/HTMLPurifier/VarParser/Native.php'; require_once $__dir . '/HTMLPurifier/VarParser/Native.php';

@ -1,71 +1,71 @@
<?php <?php
/** /**
* Converts a stream of HTMLPurifier_Token into an HTMLPurifier_Node, * Converts a stream of HTMLPurifier_Token into an HTMLPurifier_Node,
* and back again. * and back again.
* *
* @note This transformation is not an equivalence. We mutate the input * @note This transformation is not an equivalence. We mutate the input
* token stream to make it so; see all [MUT] markers in code. * token stream to make it so; see all [MUT] markers in code.
*/ */
class HTMLPurifier_Arborize class HTMLPurifier_Arborize
{ {
public static function arborize($tokens, $config, $context) { public static function arborize($tokens, $config, $context) {
$definition = $config->getHTMLDefinition(); $definition = $config->getHTMLDefinition();
$parent = new HTMLPurifier_Token_Start($definition->info_parent); $parent = new HTMLPurifier_Token_Start($definition->info_parent);
$stack = array($parent->toNode()); $stack = array($parent->toNode());
foreach ($tokens as $token) { foreach ($tokens as $token) {
$token->skip = null; // [MUT] $token->skip = null; // [MUT]
$token->carryover = null; // [MUT] $token->carryover = null; // [MUT]
if ($token instanceof HTMLPurifier_Token_End) { if ($token instanceof HTMLPurifier_Token_End) {
$token->start = null; // [MUT] $token->start = null; // [MUT]
$r = array_pop($stack); $r = array_pop($stack);
assert($r->name === $token->name); assert($r->name === $token->name);
assert(empty($token->attr)); assert(empty($token->attr));
$r->endCol = $token->col; $r->endCol = $token->col;
$r->endLine = $token->line; $r->endLine = $token->line;
$r->endArmor = $token->armor; $r->endArmor = $token->armor;
continue; continue;
} }
$node = $token->toNode(); $node = $token->toNode();
$stack[count($stack)-1]->children[] = $node; $stack[count($stack)-1]->children[] = $node;
if ($token instanceof HTMLPurifier_Token_Start) { if ($token instanceof HTMLPurifier_Token_Start) {
$stack[] = $node; $stack[] = $node;
} }
} }
assert(count($stack) == 1); assert(count($stack) == 1);
return $stack[0]; return $stack[0];
} }
public static function flatten($node, $config, $context) { public static function flatten($node, $config, $context) {
$level = 0; $level = 0;
$nodes = array($level => new HTMLPurifier_Queue(array($node))); $nodes = array($level => new HTMLPurifier_Queue(array($node)));
$closingTokens = array(); $closingTokens = array();
$tokens = array(); $tokens = array();
do { do {
while (!$nodes[$level]->isEmpty()) { while (!$nodes[$level]->isEmpty()) {
$node = $nodes[$level]->shift(); // FIFO $node = $nodes[$level]->shift(); // FIFO
list($start, $end) = $node->toTokenPair(); list($start, $end) = $node->toTokenPair();
if ($level > 0) { if ($level > 0) {
$tokens[] = $start; $tokens[] = $start;
} }
if ($end !== NULL) { if ($end !== NULL) {
$closingTokens[$level][] = $end; $closingTokens[$level][] = $end;
} }
if ($node instanceof HTMLPurifier_Node_Element) { if ($node instanceof HTMLPurifier_Node_Element) {
$level++; $level++;
$nodes[$level] = new HTMLPurifier_Queue(); $nodes[$level] = new HTMLPurifier_Queue();
foreach ($node->children as $childNode) { foreach ($node->children as $childNode) {
$nodes[$level]->push($childNode); $nodes[$level]->push($childNode);
} }
} }
} }
$level--; $level--;
if ($level && isset($closingTokens[$level])) { if ($level && isset($closingTokens[$level])) {
while ($token = array_pop($closingTokens[$level])) { while ($token = array_pop($closingTokens[$level])) {
$tokens[] = $token; $tokens[] = $token;
} }
} }
} while ($level > 0); } while ($level > 0);
return $tokens; return $tokens;
} }
} }

@ -1,143 +1,143 @@
<?php <?php
/** /**
* Defines common attribute collections that modules reference * Defines common attribute collections that modules reference
*/ */
class HTMLPurifier_AttrCollections class HTMLPurifier_AttrCollections
{ {
/** /**
* Associative array of attribute collections, indexed by name. * Associative array of attribute collections, indexed by name.
* @type array * @type array
*/ */
public $info = array(); public $info = array();
/** /**
* Performs all expansions on internal data for use by other inclusions * Performs all expansions on internal data for use by other inclusions
* It also collects all attribute collection extensions from * It also collects all attribute collection extensions from
* modules * modules
* @param HTMLPurifier_AttrTypes $attr_types HTMLPurifier_AttrTypes instance * @param HTMLPurifier_AttrTypes $attr_types HTMLPurifier_AttrTypes instance
* @param HTMLPurifier_HTMLModule[] $modules Hash array of HTMLPurifier_HTMLModule members * @param HTMLPurifier_HTMLModule[] $modules Hash array of HTMLPurifier_HTMLModule members
*/ */
public function __construct($attr_types, $modules) public function __construct($attr_types, $modules)
{ {
// load extensions from the modules // load extensions from the modules
foreach ($modules as $module) { foreach ($modules as $module) {
foreach ($module->attr_collections as $coll_i => $coll) { foreach ($module->attr_collections as $coll_i => $coll) {
if (!isset($this->info[$coll_i])) { if (!isset($this->info[$coll_i])) {
$this->info[$coll_i] = array(); $this->info[$coll_i] = array();
} }
foreach ($coll as $attr_i => $attr) { foreach ($coll as $attr_i => $attr) {
if ($attr_i === 0 && isset($this->info[$coll_i][$attr_i])) { if ($attr_i === 0 && isset($this->info[$coll_i][$attr_i])) {
// merge in includes // merge in includes
$this->info[$coll_i][$attr_i] = array_merge( $this->info[$coll_i][$attr_i] = array_merge(
$this->info[$coll_i][$attr_i], $this->info[$coll_i][$attr_i],
$attr $attr
); );
continue; continue;
} }
$this->info[$coll_i][$attr_i] = $attr; $this->info[$coll_i][$attr_i] = $attr;
} }
} }
} }
// perform internal expansions and inclusions // perform internal expansions and inclusions
foreach ($this->info as $name => $attr) { foreach ($this->info as $name => $attr) {
// merge attribute collections that include others // merge attribute collections that include others
$this->performInclusions($this->info[$name]); $this->performInclusions($this->info[$name]);
// replace string identifiers with actual attribute objects // replace string identifiers with actual attribute objects
$this->expandIdentifiers($this->info[$name], $attr_types); $this->expandIdentifiers($this->info[$name], $attr_types);
} }
} }
/** /**
* Takes a reference to an attribute associative array and performs * Takes a reference to an attribute associative array and performs
* all inclusions specified by the zero index. * all inclusions specified by the zero index.
* @param array &$attr Reference to attribute array * @param array &$attr Reference to attribute array
*/ */
public function performInclusions(&$attr) public function performInclusions(&$attr)
{ {
if (!isset($attr[0])) { if (!isset($attr[0])) {
return; return;
} }
$merge = $attr[0]; $merge = $attr[0];
$seen = array(); // recursion guard $seen = array(); // recursion guard
// loop through all the inclusions // loop through all the inclusions
for ($i = 0; isset($merge[$i]); $i++) { for ($i = 0; isset($merge[$i]); $i++) {
if (isset($seen[$merge[$i]])) { if (isset($seen[$merge[$i]])) {
continue; continue;
} }
$seen[$merge[$i]] = true; $seen[$merge[$i]] = true;
// foreach attribute of the inclusion, copy it over // foreach attribute of the inclusion, copy it over
if (!isset($this->info[$merge[$i]])) { if (!isset($this->info[$merge[$i]])) {
continue; continue;
} }
foreach ($this->info[$merge[$i]] as $key => $value) { foreach ($this->info[$merge[$i]] as $key => $value) {
if (isset($attr[$key])) { if (isset($attr[$key])) {
continue; continue;
} // also catches more inclusions } // also catches more inclusions
$attr[$key] = $value; $attr[$key] = $value;
} }
if (isset($this->info[$merge[$i]][0])) { if (isset($this->info[$merge[$i]][0])) {
// recursion // recursion
$merge = array_merge($merge, $this->info[$merge[$i]][0]); $merge = array_merge($merge, $this->info[$merge[$i]][0]);
} }
} }
unset($attr[0]); unset($attr[0]);
} }
/** /**
* Expands all string identifiers in an attribute array by replacing * Expands all string identifiers in an attribute array by replacing
* them with the appropriate values inside HTMLPurifier_AttrTypes * them with the appropriate values inside HTMLPurifier_AttrTypes
* @param array &$attr Reference to attribute array * @param array &$attr Reference to attribute array
* @param HTMLPurifier_AttrTypes $attr_types HTMLPurifier_AttrTypes instance * @param HTMLPurifier_AttrTypes $attr_types HTMLPurifier_AttrTypes instance
*/ */
public function expandIdentifiers(&$attr, $attr_types) public function expandIdentifiers(&$attr, $attr_types)
{ {
// because foreach will process new elements we add, make sure we // because foreach will process new elements we add, make sure we
// skip duplicates // skip duplicates
$processed = array(); $processed = array();
foreach ($attr as $def_i => $def) { foreach ($attr as $def_i => $def) {
// skip inclusions // skip inclusions
if ($def_i === 0) { if ($def_i === 0) {
continue; continue;
} }
if (isset($processed[$def_i])) { if (isset($processed[$def_i])) {
continue; continue;
} }
// determine whether or not attribute is required // determine whether or not attribute is required
if ($required = (strpos($def_i, '*') !== false)) { if ($required = (strpos($def_i, '*') !== false)) {
// rename the definition // rename the definition
unset($attr[$def_i]); unset($attr[$def_i]);
$def_i = trim($def_i, '*'); $def_i = trim($def_i, '*');
$attr[$def_i] = $def; $attr[$def_i] = $def;
} }
$processed[$def_i] = true; $processed[$def_i] = true;
// if we've already got a literal object, move on // if we've already got a literal object, move on
if (is_object($def)) { if (is_object($def)) {
// preserve previous required // preserve previous required
$attr[$def_i]->required = ($required || $attr[$def_i]->required); $attr[$def_i]->required = ($required || $attr[$def_i]->required);
continue; continue;
} }
if ($def === false) { if ($def === false) {
unset($attr[$def_i]); unset($attr[$def_i]);
continue; continue;
} }
if ($t = $attr_types->get($def)) { if ($t = $attr_types->get($def)) {
$attr[$def_i] = $t; $attr[$def_i] = $t;
$attr[$def_i]->required = $required; $attr[$def_i]->required = $required;
} else { } else {
unset($attr[$def_i]); unset($attr[$def_i]);
} }
} }
} }
} }
// vim: et sw=4 sts=4 // vim: et sw=4 sts=4

@ -1,138 +1,138 @@
<?php <?php
/** /**
* Base class for all validating attribute definitions. * Base class for all validating attribute definitions.
* *
* This family of classes forms the core for not only HTML attribute validation, * 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 * 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, * Besides defining (through code) what precisely makes the string valid,
* subclasses are also responsible for cleaning the code if possible. * subclasses are also responsible for cleaning the code if possible.
*/ */
abstract class HTMLPurifier_AttrDef abstract class HTMLPurifier_AttrDef
{ {
/** /**
* Tells us whether or not an HTML attribute is minimized. * Tells us whether or not an HTML attribute is minimized.
* Has no meaning in other contexts. * Has no meaning in other contexts.
* @type bool * @type bool
*/ */
public $minimized = false; public $minimized = false;
/** /**
* Tells us whether or not an HTML attribute is required. * Tells us whether or not an HTML attribute is required.
* Has no meaning in other contexts * Has no meaning in other contexts
* @type bool * @type bool
*/ */
public $required = false; public $required = false;
/** /**
* Validates and cleans passed string according to a definition. * Validates and cleans passed string according to a definition.
* *
* @param string $string String to be validated and cleaned. * @param string $string String to be validated and cleaned.
* @param HTMLPurifier_Config $config Mandatory HTMLPurifier_Config object. * @param HTMLPurifier_Config $config Mandatory HTMLPurifier_Config object.
* @param HTMLPurifier_Context $context Mandatory HTMLPurifier_Context object. * @param HTMLPurifier_Context $context Mandatory HTMLPurifier_Context object.
*/ */
abstract public function validate($string, $config, $context); abstract public function validate($string, $config, $context);
/** /**
* Convenience method that parses a string as if it were CDATA. * Convenience method that parses a string as if it were CDATA.
* *
* This method process a string in the manner specified at * This method process a string in the manner specified at
* <http://www.w3.org/TR/html4/types.html#h-6.2> by removing * <http://www.w3.org/TR/html4/types.html#h-6.2> by removing
* leading and trailing whitespace, ignoring line feeds, and replacing * leading and trailing whitespace, ignoring line feeds, and replacing
* carriage returns and tabs with spaces. While most useful for HTML * carriage returns and tabs with spaces. While most useful for HTML
* attributes specified as CDATA, it can also be applied to most CSS * attributes specified as CDATA, it can also be applied to most CSS
* values. * values.
* *
* @note This method is not entirely standards compliant, as trim() removes * @note This method is not entirely standards compliant, as trim() removes
* more types of whitespace than specified in the spec. In practice, * more types of whitespace than specified in the spec. In practice,
* this is rarely a problem, as those extra characters usually have * this is rarely a problem, as those extra characters usually have
* already been removed by HTMLPurifier_Encoder. * already been removed by HTMLPurifier_Encoder.
* *
* @warning This processing is inconsistent with XML's whitespace handling * @warning This processing is inconsistent with XML's whitespace handling
* as specified by section 3.3.3 and referenced XHTML 1.0 section * as specified by section 3.3.3 and referenced XHTML 1.0 section
* 4.7. However, note that we are NOT necessarily * 4.7. However, note that we are NOT necessarily
* parsing XML, thus, this behavior may still be correct. We * parsing XML, thus, this behavior may still be correct. We
* assume that newlines have been normalized. * assume that newlines have been normalized.
*/ */
public function parseCDATA($string) public function parseCDATA($string)
{ {
$string = trim($string); $string = trim($string);
$string = str_replace(array("\n", "\t", "\r"), ' ', $string); $string = str_replace(array("\n", "\t", "\r"), ' ', $string);
return $string; return $string;
} }
/** /**
* Factory method for creating this class from a string. * Factory method for creating this class from a string.
* @param string $string String construction info * @param string $string String construction info
* @return HTMLPurifier_AttrDef Created AttrDef object corresponding to $string * @return HTMLPurifier_AttrDef Created AttrDef object corresponding to $string
*/ */
public function make($string) public function make($string)
{ {
// default implementation, return a flyweight of this object. // default implementation, return a flyweight of this object.
// If $string has an effect on the returned object (i.e. you // If $string has an effect on the returned object (i.e. you
// need to overload this method), it is best // need to overload this method), it is best
// to clone or instantiate new copies. (Instantiation is safer.) // to clone or instantiate new copies. (Instantiation is safer.)
return $this; return $this;
} }
/** /**
* Removes spaces from rgb(0, 0, 0) so that shorthand CSS properties work * Removes spaces from rgb(0, 0, 0) so that shorthand CSS properties work
* properly. THIS IS A HACK! * properly. THIS IS A HACK!
* @param string $string a CSS colour definition * @param string $string a CSS colour definition
* @return string * @return string
*/ */
protected function mungeRgb($string) protected function mungeRgb($string)
{ {
return preg_replace('/rgb\((\d+)\s*,\s*(\d+)\s*,\s*(\d+)\)/', 'rgb(\1,\2,\3)', $string); return preg_replace('/rgb\((\d+)\s*,\s*(\d+)\s*,\s*(\d+)\)/', 'rgb(\1,\2,\3)', $string);
} }
/** /**
* Parses a possibly escaped CSS string and returns the "pure" * Parses a possibly escaped CSS string and returns the "pure"
* version of it. * version of it.
*/ */
protected function expandCSSEscape($string) protected function expandCSSEscape($string)
{ {
// flexibly parse it // flexibly parse it
$ret = ''; $ret = '';
for ($i = 0, $c = strlen($string); $i < $c; $i++) { for ($i = 0, $c = strlen($string); $i < $c; $i++) {
if ($string[$i] === '\\') { if ($string[$i] === '\\') {
$i++; $i++;
if ($i >= $c) { if ($i >= $c) {
$ret .= '\\'; $ret .= '\\';
break; break;
} }
if (ctype_xdigit($string[$i])) { if (ctype_xdigit($string[$i])) {
$code = $string[$i]; $code = $string[$i];
for ($a = 1, $i++; $i < $c && $a < 6; $i++, $a++) { for ($a = 1, $i++; $i < $c && $a < 6; $i++, $a++) {
if (!ctype_xdigit($string[$i])) { if (!ctype_xdigit($string[$i])) {
break; break;
} }
$code .= $string[$i]; $code .= $string[$i];
} }
// We have to be extremely careful when adding // We have to be extremely careful when adding
// new characters, to make sure we're not breaking // new characters, to make sure we're not breaking
// the encoding. // the encoding.
$char = HTMLPurifier_Encoder::unichr(hexdec($code)); $char = HTMLPurifier_Encoder::unichr(hexdec($code));
if (HTMLPurifier_Encoder::cleanUTF8($char) === '') { if (HTMLPurifier_Encoder::cleanUTF8($char) === '') {
continue; continue;
} }
$ret .= $char; $ret .= $char;
if ($i < $c && trim($string[$i]) !== '') { if ($i < $c && trim($string[$i]) !== '') {
$i--; $i--;
} }
continue; continue;
} }
if ($string[$i] === "\n") { if ($string[$i] === "\n") {
continue; continue;
} }
} }
$ret .= $string[$i]; $ret .= $string[$i];
} }
return $ret; return $ret;
} }
} }
// vim: et sw=4 sts=4 // vim: et sw=4 sts=4

@ -1,106 +1,106 @@
<?php <?php
/** /**
* Validates the HTML attribute style, otherwise known as CSS. * Validates the HTML attribute style, otherwise known as CSS.
* @note We don't implement the whole CSS specification, so it might be * @note We don't implement the whole CSS specification, so it might be
* difficult to reuse this component in the context of validating * difficult to reuse this component in the context of validating
* actual stylesheet declarations. * actual stylesheet declarations.
* @note If we were really serious about validating the CSS, we would * @note If we were really serious about validating the CSS, we would
* tokenize the styles and then parse the tokens. Obviously, we * tokenize the styles and then parse the tokens. Obviously, we
* are not doing that. Doing that could seriously harm performance, * are not doing that. Doing that could seriously harm performance,
* but would make these components a lot more viable for a CSS * but would make these components a lot more viable for a CSS
* filtering solution. * filtering solution.
*/ */
class HTMLPurifier_AttrDef_CSS extends HTMLPurifier_AttrDef class HTMLPurifier_AttrDef_CSS extends HTMLPurifier_AttrDef
{ {
/** /**
* @param string $css * @param string $css
* @param HTMLPurifier_Config $config * @param HTMLPurifier_Config $config
* @param HTMLPurifier_Context $context * @param HTMLPurifier_Context $context
* @return bool|string * @return bool|string
*/ */
public function validate($css, $config, $context) public function validate($css, $config, $context)
{ {
$css = $this->parseCDATA($css); $css = $this->parseCDATA($css);
$definition = $config->getCSSDefinition(); $definition = $config->getCSSDefinition();
// we're going to break the spec and explode by semicolons. // we're going to break the spec and explode by semicolons.
// This is because semicolon rarely appears in escaped form // This is because semicolon rarely appears in escaped form
// Doing this is generally flaky but fast // Doing this is generally flaky but fast
// IT MIGHT APPEAR IN URIs, see HTMLPurifier_AttrDef_CSSURI // IT MIGHT APPEAR IN URIs, see HTMLPurifier_AttrDef_CSSURI
// for details // for details
$declarations = explode(';', $css); $declarations = explode(';', $css);
$propvalues = array(); $propvalues = array();
/** /**
* Name of the current CSS property being validated. * Name of the current CSS property being validated.
*/ */
$property = false; $property = false;
$context->register('CurrentCSSProperty', $property); $context->register('CurrentCSSProperty', $property);
foreach ($declarations as $declaration) { foreach ($declarations as $declaration) {
if (!$declaration) { if (!$declaration) {
continue; continue;
} }
if (!strpos($declaration, ':')) { if (!strpos($declaration, ':')) {
continue; continue;
} }
list($property, $value) = explode(':', $declaration, 2); list($property, $value) = explode(':', $declaration, 2);
$property = trim($property); $property = trim($property);
$value = trim($value); $value = trim($value);
$ok = false; $ok = false;
do { do {
if (isset($definition->info[$property])) { if (isset($definition->info[$property])) {
$ok = true; $ok = true;
break; break;
} }
if (ctype_lower($property)) { if (ctype_lower($property)) {
break; break;
} }
$property = strtolower($property); $property = strtolower($property);
if (isset($definition->info[$property])) { if (isset($definition->info[$property])) {
$ok = true; $ok = true;
break; break;
} }
} while (0); } while (0);
if (!$ok) { if (!$ok) {
continue; continue;
} }
// inefficient call, since the validator will do this again // inefficient call, since the validator will do this again
if (strtolower(trim($value)) !== 'inherit') { if (strtolower(trim($value)) !== 'inherit') {
// inherit works for everything (but only on the base property) // inherit works for everything (but only on the base property)
$result = $definition->info[$property]->validate( $result = $definition->info[$property]->validate(
$value, $value,
$config, $config,
$context $context
); );
} else { } else {
$result = 'inherit'; $result = 'inherit';
} }
if ($result === false) { if ($result === false) {
continue; continue;
} }
$propvalues[$property] = $result; $propvalues[$property] = $result;
} }
$context->destroy('CurrentCSSProperty'); $context->destroy('CurrentCSSProperty');
// procedure does not write the new CSS simultaneously, so it's // procedure does not write the new CSS simultaneously, so it's
// slightly inefficient, but it's the only way of getting rid of // slightly inefficient, but it's the only way of getting rid of
// duplicates. Perhaps config to optimize it, but not now. // duplicates. Perhaps config to optimize it, but not now.
$new_declarations = ''; $new_declarations = '';
foreach ($propvalues as $prop => $value) { foreach ($propvalues as $prop => $value) {
$new_declarations .= "$prop:$value;"; $new_declarations .= "$prop:$value;";
} }
return $new_declarations ? $new_declarations : false; return $new_declarations ? $new_declarations : false;
} }
} }
// vim: et sw=4 sts=4 // vim: et sw=4 sts=4

@ -1,34 +1,34 @@
<?php <?php
class HTMLPurifier_AttrDef_CSS_AlphaValue extends HTMLPurifier_AttrDef_CSS_Number class HTMLPurifier_AttrDef_CSS_AlphaValue extends HTMLPurifier_AttrDef_CSS_Number
{ {
public function __construct() public function __construct()
{ {
parent::__construct(false); // opacity is non-negative, but we will clamp it parent::__construct(false); // opacity is non-negative, but we will clamp it
} }
/** /**
* @param string $number * @param string $number
* @param HTMLPurifier_Config $config * @param HTMLPurifier_Config $config
* @param HTMLPurifier_Context $context * @param HTMLPurifier_Context $context
* @return string * @return string
*/ */
public function validate($number, $config, $context) public function validate($number, $config, $context)
{ {
$result = parent::validate($number, $config, $context); $result = parent::validate($number, $config, $context);
if ($result === false) { if ($result === false) {
return $result; return $result;
} }
$float = (float)$result; $float = (float)$result;
if ($float < 0.0) { if ($float < 0.0) {
$result = '0'; $result = '0';
} }
if ($float > 1.0) { if ($float > 1.0) {
$result = '1'; $result = '1';
} }
return $result; return $result;
} }
} }
// vim: et sw=4 sts=4 // vim: et sw=4 sts=4

@ -1,111 +1,111 @@
<?php <?php
/** /**
* Validates shorthand CSS property background. * Validates shorthand CSS property background.
* @warning Does not support url tokens that have internal spaces. * @warning Does not support url tokens that have internal spaces.
*/ */
class HTMLPurifier_AttrDef_CSS_Background extends HTMLPurifier_AttrDef class HTMLPurifier_AttrDef_CSS_Background extends HTMLPurifier_AttrDef
{ {
/** /**
* Local copy of component validators. * Local copy of component validators.
* @type HTMLPurifier_AttrDef[] * @type HTMLPurifier_AttrDef[]
* @note See HTMLPurifier_AttrDef_Font::$info for a similar impl. * @note See HTMLPurifier_AttrDef_Font::$info for a similar impl.
*/ */
protected $info; protected $info;
/** /**
* @param HTMLPurifier_Config $config * @param HTMLPurifier_Config $config
*/ */
public function __construct($config) public function __construct($config)
{ {
$def = $config->getCSSDefinition(); $def = $config->getCSSDefinition();
$this->info['background-color'] = $def->info['background-color']; $this->info['background-color'] = $def->info['background-color'];
$this->info['background-image'] = $def->info['background-image']; $this->info['background-image'] = $def->info['background-image'];
$this->info['background-repeat'] = $def->info['background-repeat']; $this->info['background-repeat'] = $def->info['background-repeat'];
$this->info['background-attachment'] = $def->info['background-attachment']; $this->info['background-attachment'] = $def->info['background-attachment'];
$this->info['background-position'] = $def->info['background-position']; $this->info['background-position'] = $def->info['background-position'];
} }
/** /**
* @param string $string * @param string $string
* @param HTMLPurifier_Config $config * @param HTMLPurifier_Config $config
* @param HTMLPurifier_Context $context * @param HTMLPurifier_Context $context
* @return bool|string * @return bool|string
*/ */
public function validate($string, $config, $context) public function validate($string, $config, $context)
{ {
// regular pre-processing // regular pre-processing
$string = $this->parseCDATA($string); $string = $this->parseCDATA($string);
if ($string === '') { if ($string === '') {
return false; return false;
} }
// munge rgb() decl if necessary // munge rgb() decl if necessary
$string = $this->mungeRgb($string); $string = $this->mungeRgb($string);
// assumes URI doesn't have spaces in it // assumes URI doesn't have spaces in it
$bits = explode(' ', $string); // bits to process $bits = explode(' ', $string); // bits to process
$caught = array(); $caught = array();
$caught['color'] = false; $caught['color'] = false;
$caught['image'] = false; $caught['image'] = false;
$caught['repeat'] = false; $caught['repeat'] = false;
$caught['attachment'] = false; $caught['attachment'] = false;
$caught['position'] = false; $caught['position'] = false;
$i = 0; // number of catches $i = 0; // number of catches
foreach ($bits as $bit) { foreach ($bits as $bit) {
if ($bit === '') { if ($bit === '') {
continue; continue;
} }
foreach ($caught as $key => $status) { foreach ($caught as $key => $status) {
if ($key != 'position') { if ($key != 'position') {
if ($status !== false) { if ($status !== false) {
continue; continue;
} }
$r = $this->info['background-' . $key]->validate($bit, $config, $context); $r = $this->info['background-' . $key]->validate($bit, $config, $context);
} else { } else {
$r = $bit; $r = $bit;
} }
if ($r === false) { if ($r === false) {
continue; continue;
} }
if ($key == 'position') { if ($key == 'position') {
if ($caught[$key] === false) { if ($caught[$key] === false) {
$caught[$key] = ''; $caught[$key] = '';
} }
$caught[$key] .= $r . ' '; $caught[$key] .= $r . ' ';
} else { } else {
$caught[$key] = $r; $caught[$key] = $r;
} }
$i++; $i++;
break; break;
} }
} }
if (!$i) { if (!$i) {
return false; return false;
} }
if ($caught['position'] !== false) { if ($caught['position'] !== false) {
$caught['position'] = $this->info['background-position']-> $caught['position'] = $this->info['background-position']->
validate($caught['position'], $config, $context); validate($caught['position'], $config, $context);
} }
$ret = array(); $ret = array();
foreach ($caught as $value) { foreach ($caught as $value) {
if ($value === false) { if ($value === false) {
continue; continue;
} }
$ret[] = $value; $ret[] = $value;
} }
if (empty($ret)) { if (empty($ret)) {
return false; return false;
} }
return implode(' ', $ret); return implode(' ', $ret);
} }
} }
// vim: et sw=4 sts=4 // vim: et sw=4 sts=4

@ -1,157 +1,157 @@
<?php <?php
/* W3C says: /* W3C says:
[ // adjective and number must be in correct order, even if [ // adjective and number must be in correct order, even if
// you could switch them without introducing ambiguity. // you could switch them without introducing ambiguity.
// some browsers support that syntax // some browsers support that syntax
[ [
<percentage> | <length> | left | center | right <percentage> | <length> | left | center | right
] ]
[ [
<percentage> | <length> | top | center | bottom <percentage> | <length> | top | center | bottom
]? ]?
] | ] |
[ // this signifies that the vertical and horizontal adjectives [ // this signifies that the vertical and horizontal adjectives
// can be arbitrarily ordered, however, there can only be two, // can be arbitrarily ordered, however, there can only be two,
// one of each, or none at all // one of each, or none at all
[ [
left | center | right left | center | right
] || ] ||
[ [
top | center | bottom top | center | bottom
] ]
] ]
top, left = 0% top, left = 0%
center, (none) = 50% center, (none) = 50%
bottom, right = 100% bottom, right = 100%
*/ */
/* QuirksMode says: /* QuirksMode says:
keyword + length/percentage must be ordered correctly, as per W3C keyword + length/percentage must be ordered correctly, as per W3C
Internet Explorer and Opera, however, support arbitrary ordering. We Internet Explorer and Opera, however, support arbitrary ordering. We
should fix it up. should fix it up.
Minor issue though, not strictly necessary. Minor issue though, not strictly necessary.
*/ */
// control freaks may appreciate the ability to convert these to // control freaks may appreciate the ability to convert these to
// percentages or something, but it's not necessary // percentages or something, but it's not necessary
/** /**
* Validates the value of background-position. * Validates the value of background-position.
*/ */
class HTMLPurifier_AttrDef_CSS_BackgroundPosition extends HTMLPurifier_AttrDef class HTMLPurifier_AttrDef_CSS_BackgroundPosition extends HTMLPurifier_AttrDef
{ {
/** /**
* @type HTMLPurifier_AttrDef_CSS_Length * @type HTMLPurifier_AttrDef_CSS_Length
*/ */
protected $length; protected $length;
/** /**
* @type HTMLPurifier_AttrDef_CSS_Percentage * @type HTMLPurifier_AttrDef_CSS_Percentage
*/ */
protected $percentage; protected $percentage;
public function __construct() public function __construct()
{ {
$this->length = new HTMLPurifier_AttrDef_CSS_Length(); $this->length = new HTMLPurifier_AttrDef_CSS_Length();
$this->percentage = new HTMLPurifier_AttrDef_CSS_Percentage(); $this->percentage = new HTMLPurifier_AttrDef_CSS_Percentage();
} }
/** /**
* @param string $string * @param string $string
* @param HTMLPurifier_Config $config * @param HTMLPurifier_Config $config
* @param HTMLPurifier_Context $context * @param HTMLPurifier_Context $context
* @return bool|string * @return bool|string
*/ */
public function validate($string, $config, $context) public function validate($string, $config, $context)
{ {
$string = $this->parseCDATA($string); $string = $this->parseCDATA($string);
$bits = explode(' ', $string); $bits = explode(' ', $string);
$keywords = array(); $keywords = array();
$keywords['h'] = false; // left, right $keywords['h'] = false; // left, right
$keywords['v'] = false; // top, bottom $keywords['v'] = false; // top, bottom
$keywords['ch'] = false; // center (first word) $keywords['ch'] = false; // center (first word)
$keywords['cv'] = false; // center (second word) $keywords['cv'] = false; // center (second word)
$measures = array(); $measures = array();
$i = 0; $i = 0;
$lookup = array( $lookup = array(
'top' => 'v', 'top' => 'v',
'bottom' => 'v', 'bottom' => 'v',
'left' => 'h', 'left' => 'h',
'right' => 'h', 'right' => 'h',
'center' => 'c' 'center' => 'c'
); );
foreach ($bits as $bit) { foreach ($bits as $bit) {
if ($bit === '') { if ($bit === '') {
continue; continue;
} }
// test for keyword // test for keyword
$lbit = ctype_lower($bit) ? $bit : strtolower($bit); $lbit = ctype_lower($bit) ? $bit : strtolower($bit);
if (isset($lookup[$lbit])) { if (isset($lookup[$lbit])) {
$status = $lookup[$lbit]; $status = $lookup[$lbit];
if ($status == 'c') { if ($status == 'c') {
if ($i == 0) { if ($i == 0) {
$status = 'ch'; $status = 'ch';
} else { } else {
$status = 'cv'; $status = 'cv';
} }
} }
$keywords[$status] = $lbit; $keywords[$status] = $lbit;
$i++; $i++;
} }
// test for length // test for length
$r = $this->length->validate($bit, $config, $context); $r = $this->length->validate($bit, $config, $context);
if ($r !== false) { if ($r !== false) {
$measures[] = $r; $measures[] = $r;
$i++; $i++;
} }
// test for percentage // test for percentage
$r = $this->percentage->validate($bit, $config, $context); $r = $this->percentage->validate($bit, $config, $context);
if ($r !== false) { if ($r !== false) {
$measures[] = $r; $measures[] = $r;
$i++; $i++;
} }
} }
if (!$i) { if (!$i) {
return false; return false;
} // no valid values were caught } // no valid values were caught
$ret = array(); $ret = array();
// first keyword // first keyword
if ($keywords['h']) { if ($keywords['h']) {
$ret[] = $keywords['h']; $ret[] = $keywords['h'];
} elseif ($keywords['ch']) { } elseif ($keywords['ch']) {
$ret[] = $keywords['ch']; $ret[] = $keywords['ch'];
$keywords['cv'] = false; // prevent re-use: center = center center $keywords['cv'] = false; // prevent re-use: center = center center
} elseif (count($measures)) { } elseif (count($measures)) {
$ret[] = array_shift($measures); $ret[] = array_shift($measures);
} }
if ($keywords['v']) { if ($keywords['v']) {
$ret[] = $keywords['v']; $ret[] = $keywords['v'];
} elseif ($keywords['cv']) { } elseif ($keywords['cv']) {
$ret[] = $keywords['cv']; $ret[] = $keywords['cv'];
} elseif (count($measures)) { } elseif (count($measures)) {
$ret[] = array_shift($measures); $ret[] = array_shift($measures);
} }
if (empty($ret)) { if (empty($ret)) {
return false; return false;
} }
return implode(' ', $ret); return implode(' ', $ret);
} }
} }
// vim: et sw=4 sts=4 // vim: et sw=4 sts=4

@ -1,56 +1,56 @@
<?php <?php
/** /**
* Validates the border property as defined by CSS. * Validates the border property as defined by CSS.
*/ */
class HTMLPurifier_AttrDef_CSS_Border extends HTMLPurifier_AttrDef class HTMLPurifier_AttrDef_CSS_Border extends HTMLPurifier_AttrDef
{ {
/** /**
* Local copy of properties this property is shorthand for. * Local copy of properties this property is shorthand for.
* @type HTMLPurifier_AttrDef[] * @type HTMLPurifier_AttrDef[]
*/ */
protected $info = array(); protected $info = array();
/** /**
* @param HTMLPurifier_Config $config * @param HTMLPurifier_Config $config
*/ */
public function __construct($config) public function __construct($config)
{ {
$def = $config->getCSSDefinition(); $def = $config->getCSSDefinition();
$this->info['border-width'] = $def->info['border-width']; $this->info['border-width'] = $def->info['border-width'];
$this->info['border-style'] = $def->info['border-style']; $this->info['border-style'] = $def->info['border-style'];
$this->info['border-top-color'] = $def->info['border-top-color']; $this->info['border-top-color'] = $def->info['border-top-color'];
} }
/** /**
* @param string $string * @param string $string
* @param HTMLPurifier_Config $config * @param HTMLPurifier_Config $config
* @param HTMLPurifier_Context $context * @param HTMLPurifier_Context $context
* @return bool|string * @return bool|string
*/ */
public function validate($string, $config, $context) public function validate($string, $config, $context)
{ {
$string = $this->parseCDATA($string); $string = $this->parseCDATA($string);
$string = $this->mungeRgb($string); $string = $this->mungeRgb($string);
$bits = explode(' ', $string); $bits = explode(' ', $string);
$done = array(); // segments we've finished $done = array(); // segments we've finished
$ret = ''; // return value $ret = ''; // return value
foreach ($bits as $bit) { foreach ($bits as $bit) {
foreach ($this->info as $propname => $validator) { foreach ($this->info as $propname => $validator) {
if (isset($done[$propname])) { if (isset($done[$propname])) {
continue; continue;
} }
$r = $validator->validate($bit, $config, $context); $r = $validator->validate($bit, $config, $context);
if ($r !== false) { if ($r !== false) {
$ret .= $r . ' '; $ret .= $r . ' ';
$done[$propname] = true; $done[$propname] = true;
break; break;
} }
} }
} }
return rtrim($ret); return rtrim($ret);
} }
} }
// vim: et sw=4 sts=4 // vim: et sw=4 sts=4

@ -1,105 +1,105 @@
<?php <?php
/** /**
* Validates Color as defined by CSS. * Validates Color as defined by CSS.
*/ */
class HTMLPurifier_AttrDef_CSS_Color extends HTMLPurifier_AttrDef class HTMLPurifier_AttrDef_CSS_Color extends HTMLPurifier_AttrDef
{ {
/** /**
* @param string $color * @param string $color
* @param HTMLPurifier_Config $config * @param HTMLPurifier_Config $config
* @param HTMLPurifier_Context $context * @param HTMLPurifier_Context $context
* @return bool|string * @return bool|string
*/ */
public function validate($color, $config, $context) public function validate($color, $config, $context)
{ {
static $colors = null; static $colors = null;
if ($colors === null) { if ($colors === null) {
$colors = $config->get('Core.ColorKeywords'); $colors = $config->get('Core.ColorKeywords');
} }
$color = trim($color); $color = trim($color);
if ($color === '') { if ($color === '') {
return false; return false;
} }
$lower = strtolower($color); $lower = strtolower($color);
if (isset($colors[$lower])) { if (isset($colors[$lower])) {
return $colors[$lower]; return $colors[$lower];
} }
if (strpos($color, 'rgb(') !== false) { if (strpos($color, 'rgb(') !== false) {
// rgb literal handling // rgb literal handling
$length = strlen($color); $length = strlen($color);
if (strpos($color, ')') !== $length - 1) { if (strpos($color, ')') !== $length - 1) {
return false; return false;
} }
$triad = substr($color, 4, $length - 4 - 1); $triad = substr($color, 4, $length - 4 - 1);
$parts = explode(',', $triad); $parts = explode(',', $triad);
if (count($parts) !== 3) { if (count($parts) !== 3) {
return false; return false;
} }
$type = false; // to ensure that they're all the same type $type = false; // to ensure that they're all the same type
$new_parts = array(); $new_parts = array();
foreach ($parts as $part) { foreach ($parts as $part) {
$part = trim($part); $part = trim($part);
if ($part === '') { if ($part === '') {
return false; return false;
} }
$length = strlen($part); $length = strlen($part);
if ($part[$length - 1] === '%') { if ($part[$length - 1] === '%') {
// handle percents // handle percents
if (!$type) { if (!$type) {
$type = 'percentage'; $type = 'percentage';
} elseif ($type !== 'percentage') { } elseif ($type !== 'percentage') {
return false; return false;
} }
$num = (float)substr($part, 0, $length - 1); $num = (float)substr($part, 0, $length - 1);
if ($num < 0) { if ($num < 0) {
$num = 0; $num = 0;
} }
if ($num > 100) { if ($num > 100) {
$num = 100; $num = 100;
} }
$new_parts[] = "$num%"; $new_parts[] = "$num%";
} else { } else {
// handle integers // handle integers
if (!$type) { if (!$type) {
$type = 'integer'; $type = 'integer';
} elseif ($type !== 'integer') { } elseif ($type !== 'integer') {
return false; return false;
} }
$num = (int)$part; $num = (int)$part;
if ($num < 0) { if ($num < 0) {
$num = 0; $num = 0;
} }
if ($num > 255) { if ($num > 255) {
$num = 255; $num = 255;
} }
$new_parts[] = (string)$num; $new_parts[] = (string)$num;
} }
} }
$new_triad = implode(',', $new_parts); $new_triad = implode(',', $new_parts);
$color = "rgb($new_triad)"; $color = "rgb($new_triad)";
} else { } else {
// hexadecimal handling // hexadecimal handling
if ($color[0] === '#') { if ($color[0] === '#') {
$hex = substr($color, 1); $hex = substr($color, 1);
} else { } else {
$hex = $color; $hex = $color;
$color = '#' . $color; $color = '#' . $color;
} }
$length = strlen($hex); $length = strlen($hex);
if ($length !== 3 && $length !== 6) { if ($length !== 3 && $length !== 6) {
return false; return false;
} }
if (!ctype_xdigit($hex)) { if (!ctype_xdigit($hex)) {
return false; return false;
} }
} }
return $color; return $color;
} }
} }
// vim: et sw=4 sts=4 // vim: et sw=4 sts=4

@ -1,48 +1,48 @@
<?php <?php
/** /**
* Allows multiple validators to attempt to validate attribute. * Allows multiple validators to attempt to validate attribute.
* *
* Composite is just what it sounds like: a composite of many validators. * Composite is just what it sounds like: a composite of many validators.
* This means that multiple HTMLPurifier_AttrDef objects will have a whack * 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 * at the string. If one of them passes, that's what is returned. This is
* especially useful for CSS values, which often are a choice between * especially useful for CSS values, which often are a choice between
* an enumerated set of predefined values or a flexible data type. * an enumerated set of predefined values or a flexible data type.
*/ */
class HTMLPurifier_AttrDef_CSS_Composite extends HTMLPurifier_AttrDef class HTMLPurifier_AttrDef_CSS_Composite extends HTMLPurifier_AttrDef
{ {
/** /**
* List of objects that may process strings. * List of objects that may process strings.
* @type HTMLPurifier_AttrDef[] * @type HTMLPurifier_AttrDef[]
* @todo Make protected * @todo Make protected
*/ */
public $defs; public $defs;
/** /**
* @param HTMLPurifier_AttrDef[] $defs List of HTMLPurifier_AttrDef objects * @param HTMLPurifier_AttrDef[] $defs List of HTMLPurifier_AttrDef objects
*/ */
public function __construct($defs) public function __construct($defs)
{ {
$this->defs = $defs; $this->defs = $defs;
} }
/** /**
* @param string $string * @param string $string
* @param HTMLPurifier_Config $config * @param HTMLPurifier_Config $config
* @param HTMLPurifier_Context $context * @param HTMLPurifier_Context $context
* @return bool|string * @return bool|string
*/ */
public function validate($string, $config, $context) public function validate($string, $config, $context)
{ {
foreach ($this->defs as $i => $def) { foreach ($this->defs as $i => $def) {
$result = $this->defs[$i]->validate($string, $config, $context); $result = $this->defs[$i]->validate($string, $config, $context);
if ($result !== false) { if ($result !== false) {
return $result; return $result;
} }
} }
return false; return false;
} }
} }
// vim: et sw=4 sts=4 // vim: et sw=4 sts=4

@ -1,44 +1,44 @@
<?php <?php
/** /**
* Decorator which enables CSS properties to be disabled for specific elements. * Decorator which enables CSS properties to be disabled for specific elements.
*/ */
class HTMLPurifier_AttrDef_CSS_DenyElementDecorator extends HTMLPurifier_AttrDef class HTMLPurifier_AttrDef_CSS_DenyElementDecorator extends HTMLPurifier_AttrDef
{ {
/** /**
* @type HTMLPurifier_AttrDef * @type HTMLPurifier_AttrDef
*/ */
public $def; public $def;
/** /**
* @type string * @type string
*/ */
public $element; public $element;
/** /**
* @param HTMLPurifier_AttrDef $def Definition to wrap * @param HTMLPurifier_AttrDef $def Definition to wrap
* @param string $element Element to deny * @param string $element Element to deny
*/ */
public function __construct($def, $element) public function __construct($def, $element)
{ {
$this->def = $def; $this->def = $def;
$this->element = $element; $this->element = $element;
} }
/** /**
* Checks if CurrentToken is set and equal to $this->element * Checks if CurrentToken is set and equal to $this->element
* @param string $string * @param string $string
* @param HTMLPurifier_Config $config * @param HTMLPurifier_Config $config
* @param HTMLPurifier_Context $context * @param HTMLPurifier_Context $context
* @return bool|string * @return bool|string
*/ */
public function validate($string, $config, $context) public function validate($string, $config, $context)
{ {
$token = $context->get('CurrentToken', true); $token = $context->get('CurrentToken', true);
if ($token && $token->name == $this->element) { if ($token && $token->name == $this->element) {
return false; return false;
} }
return $this->def->validate($string, $config, $context); return $this->def->validate($string, $config, $context);
} }
} }
// vim: et sw=4 sts=4 // vim: et sw=4 sts=4

@ -1,77 +1,77 @@
<?php <?php
/** /**
* Microsoft's proprietary filter: CSS property * Microsoft's proprietary filter: CSS property
* @note Currently supports the alpha filter. In the future, this will * @note Currently supports the alpha filter. In the future, this will
* probably need an extensible framework * probably need an extensible framework
*/ */
class HTMLPurifier_AttrDef_CSS_Filter extends HTMLPurifier_AttrDef class HTMLPurifier_AttrDef_CSS_Filter extends HTMLPurifier_AttrDef
{ {
/** /**
* @type HTMLPurifier_AttrDef_Integer * @type HTMLPurifier_AttrDef_Integer
*/ */
protected $intValidator; protected $intValidator;
public function __construct() public function __construct()
{ {
$this->intValidator = new HTMLPurifier_AttrDef_Integer(); $this->intValidator = new HTMLPurifier_AttrDef_Integer();
} }
/** /**
* @param string $value * @param string $value
* @param HTMLPurifier_Config $config * @param HTMLPurifier_Config $config
* @param HTMLPurifier_Context $context * @param HTMLPurifier_Context $context
* @return bool|string * @return bool|string
*/ */
public function validate($value, $config, $context) public function validate($value, $config, $context)
{ {
$value = $this->parseCDATA($value); $value = $this->parseCDATA($value);
if ($value === 'none') { if ($value === 'none') {
return $value; return $value;
} }
// if we looped this we could support multiple filters // if we looped this we could support multiple filters
$function_length = strcspn($value, '('); $function_length = strcspn($value, '(');
$function = trim(substr($value, 0, $function_length)); $function = trim(substr($value, 0, $function_length));
if ($function !== 'alpha' && if ($function !== 'alpha' &&
$function !== 'Alpha' && $function !== 'Alpha' &&
$function !== 'progid:DXImageTransform.Microsoft.Alpha' $function !== 'progid:DXImageTransform.Microsoft.Alpha'
) { ) {
return false; return false;
} }
$cursor = $function_length + 1; $cursor = $function_length + 1;
$parameters_length = strcspn($value, ')', $cursor); $parameters_length = strcspn($value, ')', $cursor);
$parameters = substr($value, $cursor, $parameters_length); $parameters = substr($value, $cursor, $parameters_length);
$params = explode(',', $parameters); $params = explode(',', $parameters);
$ret_params = array(); $ret_params = array();
$lookup = array(); $lookup = array();
foreach ($params as $param) { foreach ($params as $param) {
list($key, $value) = explode('=', $param); list($key, $value) = explode('=', $param);
$key = trim($key); $key = trim($key);
$value = trim($value); $value = trim($value);
if (isset($lookup[$key])) { if (isset($lookup[$key])) {
continue; continue;
} }
if ($key !== 'opacity') { if ($key !== 'opacity') {
continue; continue;
} }
$value = $this->intValidator->validate($value, $config, $context); $value = $this->intValidator->validate($value, $config, $context);
if ($value === false) { if ($value === false) {
continue; continue;
} }
$int = (int)$value; $int = (int)$value;
if ($int > 100) { if ($int > 100) {
$value = '100'; $value = '100';
} }
if ($int < 0) { if ($int < 0) {
$value = '0'; $value = '0';
} }
$ret_params[] = "$key=$value"; $ret_params[] = "$key=$value";
$lookup[$key] = true; $lookup[$key] = true;
} }
$ret_parameters = implode(',', $ret_params); $ret_parameters = implode(',', $ret_params);
$ret_function = "$function($ret_parameters)"; $ret_function = "$function($ret_parameters)";
return $ret_function; return $ret_function;
} }
} }
// vim: et sw=4 sts=4 // vim: et sw=4 sts=4

@ -1,176 +1,176 @@
<?php <?php
/** /**
* Validates shorthand CSS property font. * Validates shorthand CSS property font.
*/ */
class HTMLPurifier_AttrDef_CSS_Font extends HTMLPurifier_AttrDef class HTMLPurifier_AttrDef_CSS_Font extends HTMLPurifier_AttrDef
{ {
/** /**
* Local copy of validators * Local copy of validators
* @type HTMLPurifier_AttrDef[] * @type HTMLPurifier_AttrDef[]
* @note If we moved specific CSS property definitions to their own * @note If we moved specific CSS property definitions to their own
* classes instead of having them be assembled at run time by * classes instead of having them be assembled at run time by
* CSSDefinition, this wouldn't be necessary. We'd instantiate * CSSDefinition, this wouldn't be necessary. We'd instantiate
* our own copies. * our own copies.
*/ */
protected $info = array(); protected $info = array();
/** /**
* @param HTMLPurifier_Config $config * @param HTMLPurifier_Config $config
*/ */
public function __construct($config) public function __construct($config)
{ {
$def = $config->getCSSDefinition(); $def = $config->getCSSDefinition();
$this->info['font-style'] = $def->info['font-style']; $this->info['font-style'] = $def->info['font-style'];
$this->info['font-variant'] = $def->info['font-variant']; $this->info['font-variant'] = $def->info['font-variant'];
$this->info['font-weight'] = $def->info['font-weight']; $this->info['font-weight'] = $def->info['font-weight'];
$this->info['font-size'] = $def->info['font-size']; $this->info['font-size'] = $def->info['font-size'];
$this->info['line-height'] = $def->info['line-height']; $this->info['line-height'] = $def->info['line-height'];
$this->info['font-family'] = $def->info['font-family']; $this->info['font-family'] = $def->info['font-family'];
} }
/** /**
* @param string $string * @param string $string
* @param HTMLPurifier_Config $config * @param HTMLPurifier_Config $config
* @param HTMLPurifier_Context $context * @param HTMLPurifier_Context $context
* @return bool|string * @return bool|string
*/ */
public function validate($string, $config, $context) public function validate($string, $config, $context)
{ {
static $system_fonts = array( static $system_fonts = array(
'caption' => true, 'caption' => true,
'icon' => true, 'icon' => true,
'menu' => true, 'menu' => true,
'message-box' => true, 'message-box' => true,
'small-caption' => true, 'small-caption' => true,
'status-bar' => true 'status-bar' => true
); );
// regular pre-processing // regular pre-processing
$string = $this->parseCDATA($string); $string = $this->parseCDATA($string);
if ($string === '') { if ($string === '') {
return false; return false;
} }
// check if it's one of the keywords // check if it's one of the keywords
$lowercase_string = strtolower($string); $lowercase_string = strtolower($string);
if (isset($system_fonts[$lowercase_string])) { if (isset($system_fonts[$lowercase_string])) {
return $lowercase_string; return $lowercase_string;
} }
$bits = explode(' ', $string); // bits to process $bits = explode(' ', $string); // bits to process
$stage = 0; // this indicates what we're looking for $stage = 0; // this indicates what we're looking for
$caught = array(); // which stage 0 properties have we caught? $caught = array(); // which stage 0 properties have we caught?
$stage_1 = array('font-style', 'font-variant', 'font-weight'); $stage_1 = array('font-style', 'font-variant', 'font-weight');
$final = ''; // output $final = ''; // output
for ($i = 0, $size = count($bits); $i < $size; $i++) { for ($i = 0, $size = count($bits); $i < $size; $i++) {
if ($bits[$i] === '') { if ($bits[$i] === '') {
continue; continue;
} }
switch ($stage) { switch ($stage) {
case 0: // attempting to catch font-style, font-variant or font-weight case 0: // attempting to catch font-style, font-variant or font-weight
foreach ($stage_1 as $validator_name) { foreach ($stage_1 as $validator_name) {
if (isset($caught[$validator_name])) { if (isset($caught[$validator_name])) {
continue; continue;
} }
$r = $this->info[$validator_name]->validate( $r = $this->info[$validator_name]->validate(
$bits[$i], $bits[$i],
$config, $config,
$context $context
); );
if ($r !== false) { if ($r !== false) {
$final .= $r . ' '; $final .= $r . ' ';
$caught[$validator_name] = true; $caught[$validator_name] = true;
break; break;
} }
} }
// all three caught, continue on // all three caught, continue on
if (count($caught) >= 3) { if (count($caught) >= 3) {
$stage = 1; $stage = 1;
} }
if ($r !== false) { if ($r !== false) {
break; break;
} }
case 1: // attempting to catch font-size and perhaps line-height case 1: // attempting to catch font-size and perhaps line-height
$found_slash = false; $found_slash = false;
if (strpos($bits[$i], '/') !== false) { if (strpos($bits[$i], '/') !== false) {
list($font_size, $line_height) = list($font_size, $line_height) =
explode('/', $bits[$i]); explode('/', $bits[$i]);
if ($line_height === '') { if ($line_height === '') {
// ooh, there's a space after the slash! // ooh, there's a space after the slash!
$line_height = false; $line_height = false;
$found_slash = true; $found_slash = true;
} }
} else { } else {
$font_size = $bits[$i]; $font_size = $bits[$i];
$line_height = false; $line_height = false;
} }
$r = $this->info['font-size']->validate( $r = $this->info['font-size']->validate(
$font_size, $font_size,
$config, $config,
$context $context
); );
if ($r !== false) { if ($r !== false) {
$final .= $r; $final .= $r;
// attempt to catch line-height // attempt to catch line-height
if ($line_height === false) { if ($line_height === false) {
// we need to scroll forward // we need to scroll forward
for ($j = $i + 1; $j < $size; $j++) { for ($j = $i + 1; $j < $size; $j++) {
if ($bits[$j] === '') { if ($bits[$j] === '') {
continue; continue;
} }
if ($bits[$j] === '/') { if ($bits[$j] === '/') {
if ($found_slash) { if ($found_slash) {
return false; return false;
} else { } else {
$found_slash = true; $found_slash = true;
continue; continue;
} }
} }
$line_height = $bits[$j]; $line_height = $bits[$j];
break; break;
} }
} else { } else {
// slash already found // slash already found
$found_slash = true; $found_slash = true;
$j = $i; $j = $i;
} }
if ($found_slash) { if ($found_slash) {
$i = $j; $i = $j;
$r = $this->info['line-height']->validate( $r = $this->info['line-height']->validate(
$line_height, $line_height,
$config, $config,
$context $context
); );
if ($r !== false) { if ($r !== false) {
$final .= '/' . $r; $final .= '/' . $r;
} }
} }
$final .= ' '; $final .= ' ';
$stage = 2; $stage = 2;
break; break;
} }
return false; return false;
case 2: // attempting to catch font-family case 2: // attempting to catch font-family
$font_family = $font_family =
implode(' ', array_slice($bits, $i, $size - $i)); implode(' ', array_slice($bits, $i, $size - $i));
$r = $this->info['font-family']->validate( $r = $this->info['font-family']->validate(
$font_family, $font_family,
$config, $config,
$context $context
); );
if ($r !== false) { if ($r !== false) {
$final .= $r . ' '; $final .= $r . ' ';
// processing completed successfully // processing completed successfully
return rtrim($final); return rtrim($final);
} }
return false; return false;
} }
} }
return false; return false;
} }
} }
// vim: et sw=4 sts=4 // vim: et sw=4 sts=4

@ -1,219 +1,219 @@
<?php <?php
/** /**
* Validates a font family list according to CSS spec * Validates a font family list according to CSS spec
*/ */
class HTMLPurifier_AttrDef_CSS_FontFamily extends HTMLPurifier_AttrDef class HTMLPurifier_AttrDef_CSS_FontFamily extends HTMLPurifier_AttrDef
{ {
protected $mask = null; protected $mask = null;
public function __construct() public function __construct()
{ {
$this->mask = '_- '; $this->mask = '_- ';
for ($c = 'a'; $c <= 'z'; $c++) { for ($c = 'a'; $c <= 'z'; $c++) {
$this->mask .= $c; $this->mask .= $c;
} }
for ($c = 'A'; $c <= 'Z'; $c++) { for ($c = 'A'; $c <= 'Z'; $c++) {
$this->mask .= $c; $this->mask .= $c;
} }
for ($c = '0'; $c <= '9'; $c++) { for ($c = '0'; $c <= '9'; $c++) {
$this->mask .= $c; $this->mask .= $c;
} // cast-y, but should be fine } // cast-y, but should be fine
// special bytes used by UTF-8 // special bytes used by UTF-8
for ($i = 0x80; $i <= 0xFF; $i++) { for ($i = 0x80; $i <= 0xFF; $i++) {
// We don't bother excluding invalid bytes in this range, // We don't bother excluding invalid bytes in this range,
// because the our restriction of well-formed UTF-8 will // because the our restriction of well-formed UTF-8 will
// prevent these from ever occurring. // prevent these from ever occurring.
$this->mask .= chr($i); $this->mask .= chr($i);
} }
/* /*
PHP's internal strcspn implementation is PHP's internal strcspn implementation is
O(length of string * length of mask), making it inefficient O(length of string * length of mask), making it inefficient
for large masks. However, it's still faster than for large masks. However, it's still faster than
preg_match 8) preg_match 8)
for (p = s1;;) { for (p = s1;;) {
spanp = s2; spanp = s2;
do { do {
if (*spanp == c || p == s1_end) { if (*spanp == c || p == s1_end) {
return p - s1; return p - s1;
} }
} while (spanp++ < (s2_end - 1)); } while (spanp++ < (s2_end - 1));
c = *++p; c = *++p;
} }
*/ */
// possible optimization: invert the mask. // possible optimization: invert the mask.
} }
/** /**
* @param string $string * @param string $string
* @param HTMLPurifier_Config $config * @param HTMLPurifier_Config $config
* @param HTMLPurifier_Context $context * @param HTMLPurifier_Context $context
* @return bool|string * @return bool|string
*/ */
public function validate($string, $config, $context) public function validate($string, $config, $context)
{ {
static $generic_names = array( static $generic_names = array(
'serif' => true, 'serif' => true,
'sans-serif' => true, 'sans-serif' => true,
'monospace' => true, 'monospace' => true,
'fantasy' => true, 'fantasy' => true,
'cursive' => true 'cursive' => true
); );
$allowed_fonts = $config->get('CSS.AllowedFonts'); $allowed_fonts = $config->get('CSS.AllowedFonts');
// assume that no font names contain commas in them // assume that no font names contain commas in them
$fonts = explode(',', $string); $fonts = explode(',', $string);
$final = ''; $final = '';
foreach ($fonts as $font) { foreach ($fonts as $font) {
$font = trim($font); $font = trim($font);
if ($font === '') { if ($font === '') {
continue; continue;
} }
// match a generic name // match a generic name
if (isset($generic_names[$font])) { if (isset($generic_names[$font])) {
if ($allowed_fonts === null || isset($allowed_fonts[$font])) { if ($allowed_fonts === null || isset($allowed_fonts[$font])) {
$final .= $font . ', '; $final .= $font . ', ';
} }
continue; continue;
} }
// match a quoted name // match a quoted name
if ($font[0] === '"' || $font[0] === "'") { if ($font[0] === '"' || $font[0] === "'") {
$length = strlen($font); $length = strlen($font);
if ($length <= 2) { if ($length <= 2) {
continue; continue;
} }
$quote = $font[0]; $quote = $font[0];
if ($font[$length - 1] !== $quote) { if ($font[$length - 1] !== $quote) {
continue; continue;
} }
$font = substr($font, 1, $length - 2); $font = substr($font, 1, $length - 2);
} }
$font = $this->expandCSSEscape($font); $font = $this->expandCSSEscape($font);
// $font is a pure representation of the font name // $font is a pure representation of the font name
if ($allowed_fonts !== null && !isset($allowed_fonts[$font])) { if ($allowed_fonts !== null && !isset($allowed_fonts[$font])) {
continue; continue;
} }
if (ctype_alnum($font) && $font !== '') { if (ctype_alnum($font) && $font !== '') {
// very simple font, allow it in unharmed // very simple font, allow it in unharmed
$final .= $font . ', '; $final .= $font . ', ';
continue; continue;
} }
// bugger out on whitespace. form feed (0C) really // bugger out on whitespace. form feed (0C) really
// shouldn't show up regardless // shouldn't show up regardless
$font = str_replace(array("\n", "\t", "\r", "\x0C"), ' ', $font); $font = str_replace(array("\n", "\t", "\r", "\x0C"), ' ', $font);
// Here, there are various classes of characters which need // Here, there are various classes of characters which need
// to be treated differently: // to be treated differently:
// - Alphanumeric characters are essentially safe. We // - Alphanumeric characters are essentially safe. We
// handled these above. // handled these above.
// - Spaces require quoting, though most parsers will do // - Spaces require quoting, though most parsers will do
// the right thing if there aren't any characters that // the right thing if there aren't any characters that
// can be misinterpreted // can be misinterpreted
// - Dashes rarely occur, but they fairly unproblematic // - Dashes rarely occur, but they fairly unproblematic
// for parsing/rendering purposes. // for parsing/rendering purposes.
// The above characters cover the majority of Western font // The above characters cover the majority of Western font
// names. // names.
// - Arbitrary Unicode characters not in ASCII. Because // - Arbitrary Unicode characters not in ASCII. Because
// most parsers give little thought to Unicode, treatment // most parsers give little thought to Unicode, treatment
// of these codepoints is basically uniform, even for // of these codepoints is basically uniform, even for
// punctuation-like codepoints. These characters can // punctuation-like codepoints. These characters can
// show up in non-Western pages and are supported by most // show up in non-Western pages and are supported by most
// major browsers, for example: " 明朝" is a // major browsers, for example: " 明朝" is a
// legitimate font-name // legitimate font-name
// <http://ja.wikipedia.org/wiki/MS_明朝>. See // <http://ja.wikipedia.org/wiki/MS_明朝>. See
// the CSS3 spec for more examples: // the CSS3 spec for more examples:
// <http://www.w3.org/TR/2011/WD-css3-fonts-20110324/localizedfamilynames.png> // <http://www.w3.org/TR/2011/WD-css3-fonts-20110324/localizedfamilynames.png>
// You can see live samples of these on the Internet: // You can see live samples of these on the Internet:
// <http://www.google.co.jp/search?q=font-family++明朝|ゴシック> // <http://www.google.co.jp/search?q=font-family++明朝|ゴシック>
// However, most of these fonts have ASCII equivalents: // However, most of these fonts have ASCII equivalents:
// for example, 'MS Mincho', and it's considered // for example, 'MS Mincho', and it's considered
// professional to use ASCII font names instead of // professional to use ASCII font names instead of
// Unicode font names. Thanks Takeshi Terada for // Unicode font names. Thanks Takeshi Terada for
// providing this information. // providing this information.
// The following characters, to my knowledge, have not been // The following characters, to my knowledge, have not been
// used to name font names. // used to name font names.
// - Single quote. While theoretically you might find a // - Single quote. While theoretically you might find a
// font name that has a single quote in its name (serving // font name that has a single quote in its name (serving
// as an apostrophe, e.g. Dave's Scribble), I haven't // as an apostrophe, e.g. Dave's Scribble), I haven't
// been able to find any actual examples of this. // been able to find any actual examples of this.
// Internet Explorer's cssText translation (which I // Internet Explorer's cssText translation (which I
// believe is invoked by innerHTML) normalizes any // believe is invoked by innerHTML) normalizes any
// quoting to single quotes, and fails to escape single // quoting to single quotes, and fails to escape single
// quotes. (Note that this is not IE's behavior for all // quotes. (Note that this is not IE's behavior for all
// CSS properties, just some sort of special casing for // CSS properties, just some sort of special casing for
// font-family). So a single quote *cannot* be used // font-family). So a single quote *cannot* be used
// safely in the font-family context if there will be an // safely in the font-family context if there will be an
// innerHTML/cssText translation. Note that Firefox 3.x // innerHTML/cssText translation. Note that Firefox 3.x
// does this too. // does this too.
// - Double quote. In IE, these get normalized to // - Double quote. In IE, these get normalized to
// single-quotes, no matter what the encoding. (Fun // single-quotes, no matter what the encoding. (Fun
// fact, in IE8, the 'content' CSS property gained // fact, in IE8, the 'content' CSS property gained
// support, where they special cased to preserve encoded // support, where they special cased to preserve encoded
// double quotes, but still translate unadorned double // double quotes, but still translate unadorned double
// quotes into single quotes.) So, because their // quotes into single quotes.) So, because their
// fixpoint behavior is identical to single quotes, they // fixpoint behavior is identical to single quotes, they
// cannot be allowed either. Firefox 3.x displays // cannot be allowed either. Firefox 3.x displays
// single-quote style behavior. // single-quote style behavior.
// - Backslashes are reduced by one (so \\ -> \) every // - Backslashes are reduced by one (so \\ -> \) every
// iteration, so they cannot be used safely. This shows // iteration, so they cannot be used safely. This shows
// up in IE7, IE8 and FF3 // up in IE7, IE8 and FF3
// - Semicolons, commas and backticks are handled properly. // - Semicolons, commas and backticks are handled properly.
// - The rest of the ASCII punctuation is handled properly. // - The rest of the ASCII punctuation is handled properly.
// We haven't checked what browsers do to unadorned // We haven't checked what browsers do to unadorned
// versions, but this is not important as long as the // versions, but this is not important as long as the
// browser doesn't /remove/ surrounding quotes (as IE does // browser doesn't /remove/ surrounding quotes (as IE does
// for HTML). // for HTML).
// //
// With these results in hand, we conclude that there are // With these results in hand, we conclude that there are
// various levels of safety: // various levels of safety:
// - Paranoid: alphanumeric, spaces and dashes(?) // - Paranoid: alphanumeric, spaces and dashes(?)
// - International: Paranoid + non-ASCII Unicode // - International: Paranoid + non-ASCII Unicode
// - Edgy: Everything except quotes, backslashes // - Edgy: Everything except quotes, backslashes
// - NoJS: Standards compliance, e.g. sod IE. Note that // - NoJS: Standards compliance, e.g. sod IE. Note that
// with some judicious character escaping (since certain // with some judicious character escaping (since certain
// types of escaping doesn't work) this is theoretically // types of escaping doesn't work) this is theoretically
// OK as long as innerHTML/cssText is not called. // OK as long as innerHTML/cssText is not called.
// We believe that international is a reasonable default // We believe that international is a reasonable default
// (that we will implement now), and once we do more // (that we will implement now), and once we do more
// extensive research, we may feel comfortable with dropping // extensive research, we may feel comfortable with dropping
// it down to edgy. // it down to edgy.
// Edgy: alphanumeric, spaces, dashes, underscores and Unicode. Use of // Edgy: alphanumeric, spaces, dashes, underscores and Unicode. Use of
// str(c)spn assumes that the string was already well formed // str(c)spn assumes that the string was already well formed
// Unicode (which of course it is). // Unicode (which of course it is).
if (strspn($font, $this->mask) !== strlen($font)) { if (strspn($font, $this->mask) !== strlen($font)) {
continue; continue;
} }
// Historical: // Historical:
// In the absence of innerHTML/cssText, these ugly // In the absence of innerHTML/cssText, these ugly
// transforms don't pose a security risk (as \\ and \" // transforms don't pose a security risk (as \\ and \"
// might--these escapes are not supported by most browsers). // might--these escapes are not supported by most browsers).
// We could try to be clever and use single-quote wrapping // We could try to be clever and use single-quote wrapping
// when there is a double quote present, but I have choosen // when there is a double quote present, but I have choosen
// not to implement that. (NOTE: you can reduce the amount // not to implement that. (NOTE: you can reduce the amount
// of escapes by one depending on what quoting style you use) // of escapes by one depending on what quoting style you use)
// $font = str_replace('\\', '\\5C ', $font); // $font = str_replace('\\', '\\5C ', $font);
// $font = str_replace('"', '\\22 ', $font); // $font = str_replace('"', '\\22 ', $font);
// $font = str_replace("'", '\\27 ', $font); // $font = str_replace("'", '\\27 ', $font);
// font possibly with spaces, requires quoting // font possibly with spaces, requires quoting
$final .= "'$font', "; $final .= "'$font', ";
} }
$final = rtrim($final, ', '); $final = rtrim($final, ', ');
if ($final === '') { if ($final === '') {
return false; return false;
} }
return $final; return $final;
} }
} }
// vim: et sw=4 sts=4 // vim: et sw=4 sts=4

@ -1,32 +1,32 @@
<?php <?php
/** /**
* Validates based on {ident} CSS grammar production * Validates based on {ident} CSS grammar production
*/ */
class HTMLPurifier_AttrDef_CSS_Ident extends HTMLPurifier_AttrDef class HTMLPurifier_AttrDef_CSS_Ident extends HTMLPurifier_AttrDef
{ {
/** /**
* @param string $string * @param string $string
* @param HTMLPurifier_Config $config * @param HTMLPurifier_Config $config
* @param HTMLPurifier_Context $context * @param HTMLPurifier_Context $context
* @return bool|string * @return bool|string
*/ */
public function validate($string, $config, $context) public function validate($string, $config, $context)
{ {
$string = trim($string); $string = trim($string);
// early abort: '' and '0' (strings that convert to false) are invalid // early abort: '' and '0' (strings that convert to false) are invalid
if (!$string) { if (!$string) {
return false; return false;
} }
$pattern = '/^(-?[A-Za-z_][A-Za-z_\-0-9]*)$/'; $pattern = '/^(-?[A-Za-z_][A-Za-z_\-0-9]*)$/';
if (!preg_match($pattern, $string)) { if (!preg_match($pattern, $string)) {
return false; return false;
} }
return $string; return $string;
} }
} }
// vim: et sw=4 sts=4 // vim: et sw=4 sts=4

Some files were not shown because too many files have changed in this diff Show More