From 323117599e5b23f0ec15838b0c2a54e536fe5e9a Mon Sep 17 00:00:00 2001 From: Michael Lenaghan Date: Sun, 21 Apr 2024 12:50:06 -0400 Subject: [PATCH 1/2] Fixes #28 --- TextformatterHannaCode.module | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/TextformatterHannaCode.module b/TextformatterHannaCode.module index 2a49b2e..0c12a0b 100644 --- a/TextformatterHannaCode.module +++ b/TextformatterHannaCode.module @@ -228,9 +228,14 @@ class TextformatterHannaCode extends Textformatter implements ConfigurableModule $closeHTML = $matches[3][$key]; if($consume && $openHTML == $closeHTML) { - $this->value = str_replace($matches[0][$key], $replacement, $this->value); + $original = $matches[0][$key]; } else { - $this->value = str_replace("$openTag$expression$closeTag", $replacement, $this->value); + $original = "$openTag$expression$closeTag"; + } + $originalLen = strlen($original); + $originalPos = strpos($this->value, $original); + if ($originalPos != false) { + $this->value = substr_replace($this->value, $replacement, $originalPos, $originalLen); } } From 138bfcbbefb52458576fbcf9beffb678855cf68e Mon Sep 17 00:00:00 2001 From: Michael Lenaghan Date: Sun, 26 Oct 2025 19:16:12 -0400 Subject: [PATCH 2/2] Use strict comparison. --- TextformatterHannaCode.module | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TextformatterHannaCode.module b/TextformatterHannaCode.module index 0c12a0b..2fbd832 100644 --- a/TextformatterHannaCode.module +++ b/TextformatterHannaCode.module @@ -234,7 +234,7 @@ class TextformatterHannaCode extends Textformatter implements ConfigurableModule } $originalLen = strlen($original); $originalPos = strpos($this->value, $original); - if ($originalPos != false) { + if ($originalPos !== false) { $this->value = substr_replace($this->value, $replacement, $originalPos, $originalLen); } }