From b88fcd180c1d358baa2cf2346d0bb7e02fded20a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edi=20Modri=C4=87?= Date: Wed, 31 Jul 2019 04:50:43 +0200 Subject: [PATCH 1/5] Replace curly braces with square brackets in string offsets (#224) --- library/HTMLPurifier/ChildDef/Custom.php | 2 +- library/HTMLPurifier/Encoder.php | 2 +- library/HTMLPurifier/TagTransform/Font.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/library/HTMLPurifier/ChildDef/Custom.php b/library/HTMLPurifier/ChildDef/Custom.php index 128132e9..f515888a 100644 --- a/library/HTMLPurifier/ChildDef/Custom.php +++ b/library/HTMLPurifier/ChildDef/Custom.php @@ -45,7 +45,7 @@ class HTMLPurifier_ChildDef_Custom extends HTMLPurifier_ChildDef protected function _compileRegex() { $raw = str_replace(' ', '', $this->dtd_regex); - if ($raw{0} != '(') { + if ($raw[0] != '(') { $raw = "($raw)"; } $el = '[#a-zA-Z0-9_.-]+'; diff --git a/library/HTMLPurifier/Encoder.php b/library/HTMLPurifier/Encoder.php index b94f1754..40a24266 100644 --- a/library/HTMLPurifier/Encoder.php +++ b/library/HTMLPurifier/Encoder.php @@ -159,7 +159,7 @@ class HTMLPurifier_Encoder $len = strlen($str); for ($i = 0; $i < $len; $i++) { - $in = ord($str{$i}); + $in = ord($str[$i]); $char .= $str[$i]; // append byte to char if (0 == $mState) { // When mState is zero we expect either a US-ASCII character diff --git a/library/HTMLPurifier/TagTransform/Font.php b/library/HTMLPurifier/TagTransform/Font.php index 7853d90b..768c9b15 100644 --- a/library/HTMLPurifier/TagTransform/Font.php +++ b/library/HTMLPurifier/TagTransform/Font.php @@ -75,7 +75,7 @@ class HTMLPurifier_TagTransform_Font extends HTMLPurifier_TagTransform if (isset($attr['size'])) { // normalize large numbers if ($attr['size'] !== '') { - if ($attr['size']{0} == '+' || $attr['size']{0} == '-') { + if ($attr['size'][0] == '+' || $attr['size'][0] == '-') { $size = (int)$attr['size']; if ($size < -2) { $attr['size'] = '-2'; From 029d1df5e3b6829839fbd6ea873ddf02bb034415 Mon Sep 17 00:00:00 2001 From: Mateusz Turcza Date: Fri, 9 Aug 2019 15:45:41 +0200 Subject: [PATCH 2/5] Fix PHP 5.4 and 5.5 builds on Travis CI (#227) --- .travis.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index bf92db94..0b27c832 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,16 @@ language: php php: - - '5.4' - - '5.5' - '5.6' - '7.0' - '7.1' - '7.2' - '7.3' +matrix: + include: + - php: '5.4' + dist: trusty + - php: '5.5' + dist: trusty before_script: - git clone --depth=50 https://github.com/ezyang/simpletest.git - cp test-settings.travis.php test-settings.php From ab2887e423936c5f2f422c4462bc4ad1f382f712 Mon Sep 17 00:00:00 2001 From: Mateusz Turcza Date: Fri, 9 Aug 2019 23:01:13 +0200 Subject: [PATCH 3/5] Fix DOM Lexer for PHP versions older than 5.4 (#225) --- library/HTMLPurifier/Lexer/DOMLex.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/library/HTMLPurifier/Lexer/DOMLex.php b/library/HTMLPurifier/Lexer/DOMLex.php index b573426d..ca5f25b8 100644 --- a/library/HTMLPurifier/Lexer/DOMLex.php +++ b/library/HTMLPurifier/Lexer/DOMLex.php @@ -74,7 +74,12 @@ class HTMLPurifier_Lexer_DOMLex extends HTMLPurifier_Lexer } set_error_handler(array($this, 'muteErrorHandler')); - $doc->loadHTML($html, $options); + // loadHTML() fails on PHP 5.3 when second parameter is given + if ($options) { + $doc->loadHTML($html, $options); + } else { + $doc->loadHTML($html); + } restore_error_handler(); $body = $doc->getElementsByTagName('html')->item(0)-> // From c6ca293eab531add17726609a6a783c66611001a Mon Sep 17 00:00:00 2001 From: Witold Wasiczko Date: Thu, 12 Sep 2019 02:25:44 +0200 Subject: [PATCH 4/5] Add support for PHP 7.4 (#230) * Add php7.4 * 7.4 cannot fail * Disallow failures --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 0b27c832..7c8c111b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,7 @@ php: - '7.1' - '7.2' - '7.3' + - '7.4snapshot' matrix: include: - php: '5.4' From 06b3fc4cf4bcebf5ffb877a8ef047d7b85daa513 Mon Sep 17 00:00:00 2001 From: Mateusz Turcza Date: Fri, 25 Oct 2019 16:07:38 +0200 Subject: [PATCH 5/5] Fix phpdoc params in HTMLModule::addElement() and Bool attr (#233) --- library/HTMLPurifier/AttrDef/HTML/Bool.php | 4 ++-- library/HTMLPurifier/HTMLModule.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/library/HTMLPurifier/AttrDef/HTML/Bool.php b/library/HTMLPurifier/AttrDef/HTML/Bool.php index dea15d2c..be3bbc8d 100644 --- a/library/HTMLPurifier/AttrDef/HTML/Bool.php +++ b/library/HTMLPurifier/AttrDef/HTML/Bool.php @@ -7,7 +7,7 @@ class HTMLPurifier_AttrDef_HTML_Bool extends HTMLPurifier_AttrDef { /** - * @type bool + * @type string */ protected $name; @@ -17,7 +17,7 @@ class HTMLPurifier_AttrDef_HTML_Bool extends HTMLPurifier_AttrDef public $minimized = true; /** - * @param bool $name + * @param bool|string $name */ public function __construct($name = false) { diff --git a/library/HTMLPurifier/HTMLModule.php b/library/HTMLPurifier/HTMLModule.php index bb3a9230..6d898f80 100644 --- a/library/HTMLPurifier/HTMLModule.php +++ b/library/HTMLPurifier/HTMLModule.php @@ -132,9 +132,9 @@ class HTMLPurifier_HTMLModule * @param string $element Name of element to add * @param string|bool $type What content set should element be registered to? * Set as false to skip this step. - * @param string $contents Allowed children in form of: + * @param string|HTMLPurifier_ChildDef $contents Allowed children in form of: * "$content_model_type: $content_model" - * @param array $attr_includes What attribute collections to register to + * @param array|string $attr_includes What attribute collections to register to * element? * @param array $attr What unique attributes does the element define? * @see HTMLPurifier_ElementDef:: for in-depth descriptions of these parameters.