From cf0abe538a50ecec30bf7a2fd81cd7794278745f Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Fri, 22 Nov 2024 10:57:01 -0500 Subject: [PATCH] Additional updates for processwire/processwire-issues#1467 --- wire/core/WireTextTools.php | 3 ++- .../Fieldtype/FieldtypeComments/FieldtypeComments.module | 5 ++--- .../Fieldtype/FieldtypeRepeater/InputfieldRepeater.module | 2 +- .../InputfieldPageTable/InputfieldPageTable.module | 2 +- wire/modules/Textformatter/TextformatterEntities.module | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/wire/core/WireTextTools.php b/wire/core/WireTextTools.php index 9d74ab30..9f8633fb 100644 --- a/wire/core/WireTextTools.php +++ b/wire/core/WireTextTools.php @@ -905,7 +905,7 @@ class WireTextTools extends Wire { * - `has` (bool): Specify true to only return true or false if it has tags (default=false). * - `tagOpen` (string): The required opening tag character(s), default is '{' * - `tagClose` (string): The required closing tag character(s), default is '}' - * @return array|bool + * @return array|bool Always returns array unless you specify the `has` option as true. * @since 3.0.126 * */ @@ -918,6 +918,7 @@ class WireTextTools extends Wire { ); $options = array_merge($defaults, $options); + $str = (string) $str; $tags = array(); $pos1 = strpos($str, $options['tagOpen']); diff --git a/wire/modules/Fieldtype/FieldtypeComments/FieldtypeComments.module b/wire/modules/Fieldtype/FieldtypeComments/FieldtypeComments.module index 95256a67..fe703fa2 100644 --- a/wire/modules/Fieldtype/FieldtypeComments/FieldtypeComments.module +++ b/wire/modules/Fieldtype/FieldtypeComments/FieldtypeComments.module @@ -300,12 +300,12 @@ class FieldtypeComments extends FieldtypeMulti { // assign code and subcode if(!$comment->code || !$comment->subcode) { $rand = new WireRandom(); - if(!strlen($comment->code)) { + if(!strlen("$comment->code")) { // code: visible to admin only $code = $rand->alphanumeric(128); $comment->code = $code; } - if(!strlen($comment->subcode)) { + if(!strlen("$comment->subcode")) { // subcode: may be visible to commenter $subcode = $rand->alphanumeric(40); $comment->subcode = $subcode; @@ -2555,4 +2555,3 @@ class FieldtypeComments extends FieldtypeMulti { } } - diff --git a/wire/modules/Fieldtype/FieldtypeRepeater/InputfieldRepeater.module b/wire/modules/Fieldtype/FieldtypeRepeater/InputfieldRepeater.module index 5ece7819..551a4784 100644 --- a/wire/modules/Fieldtype/FieldtypeRepeater/InputfieldRepeater.module +++ b/wire/modules/Fieldtype/FieldtypeRepeater/InputfieldRepeater.module @@ -263,7 +263,7 @@ class InputfieldRepeater extends Inputfield implements InputfieldItemList { $fields = $this->wire()->fields; $items = $this->attr('value'); - $item = count($items) ? $items->first() : null; + $item = wireCount($items) ? $items->first() : null; $templateId = $this->field ? (int) $this->field->get('template_id') : 0; $template = $templateId ? $this->wire()->templates->get($templateId) : null; diff --git a/wire/modules/Inputfield/InputfieldPageTable/InputfieldPageTable.module b/wire/modules/Inputfield/InputfieldPageTable/InputfieldPageTable.module index 7e1d8e60..c8fd65b9 100644 --- a/wire/modules/Inputfield/InputfieldPageTable/InputfieldPageTable.module +++ b/wire/modules/Inputfield/InputfieldPageTable/InputfieldPageTable.module @@ -518,7 +518,7 @@ class InputfieldPageTable extends Inputfield { $value = (string) $object; } - $value = $this->wire()->sanitizer->entities(strip_tags($value)); + $value = $this->wire()->sanitizer->entities(strip_tags("$value")); $value = nl2br($value); return $value; diff --git a/wire/modules/Textformatter/TextformatterEntities.module b/wire/modules/Textformatter/TextformatterEntities.module index 36216574..0697bfbf 100644 --- a/wire/modules/Textformatter/TextformatterEntities.module +++ b/wire/modules/Textformatter/TextformatterEntities.module @@ -26,9 +26,9 @@ class TextformatterEntities extends Textformatter { public function format(&$str) { if($this->charset === '') $this->charset = $this->wire()->config->dbCharset; if(stripos($this->charset, 'utf8') === 0) { - $str = htmlspecialchars($str, ENT_QUOTES, 'UTF-8'); + $str = htmlspecialchars("$str", ENT_QUOTES, 'UTF-8'); } else { - $str = htmlspecialchars($str, ENT_QUOTES); + $str = htmlspecialchars("$str", ENT_QUOTES); } } }