From 2349599aa88e9c7f29889c73c6fb75b7420b0966 Mon Sep 17 00:00:00 2001
From: Ryan Cramer
Date: Thu, 29 Jun 2023 15:10:43 -0400
Subject: [PATCH] Fix issue processwire/processwire-issues#1770
---
wire/core/MarkupFieldtype.php | 3 ++-
wire/core/Sanitizer.php | 20 +++++++++++++-------
2 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/wire/core/MarkupFieldtype.php b/wire/core/MarkupFieldtype.php
index 23c85b3b..664c4648 100644
--- a/wire/core/MarkupFieldtype.php
+++ b/wire/core/MarkupFieldtype.php
@@ -127,7 +127,8 @@ class MarkupFieldtype extends WireData implements Module {
}
return $this->arrayToString($a, false);
} else {
- $value = $value->explode($property, array('getMethod' => 'getFormatted'));
+ $getMethod = strpos($property, '}') ? 'getText' : 'getFormatted';
+ $value = $value->explode($property, array('getMethod' => $getMethod));
}
$valid = true;
diff --git a/wire/core/Sanitizer.php b/wire/core/Sanitizer.php
index ed18f593..a0554af6 100644
--- a/wire/core/Sanitizer.php
+++ b/wire/core/Sanitizer.php
@@ -1970,13 +1970,19 @@ class Sanitizer extends Wire {
if(strpos($value, '<') !== false) {
// tag replacements before strip_tags()
- $regex =
- '!<(?:' .
- '/?(?:ul|ol|p|h\d|div)(?:>|\s[^><]*)' .
- '|' .
- '(?:br[\s/]*)' .
- ')>!is';
- $value = preg_replace($regex, $newline, $value);
+ if(stripos($value, '') || stripos($value, '')) {
+ $regex = '!<(?:/?(?:ul|ol)(?:>|\s[^><]*))>!i';
+ $value = preg_replace($regex, '', $value);
+ }
+ if(stripos($value, '
') || stripos($value, '')) {
+ $regex =
+ '!<(?:' .
+ '/?(?:p|h\d|div)(?:>|\s[^><]*)' .
+ '|' .
+ '(?:br[\s/]*)' .
+ ')>!is';
+ $value = preg_replace($regex, $newline, $value);
+ }
if(stripos($value, '')) {
$value = preg_replace('!\s*