Skip to content

Commit

Permalink
[FIX] Do Not Remove '0' As RTE Element Content
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasWeinert committed Oct 26, 2021
1 parent 47c688d commit 5f5304a
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/system/papaya_strings.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,15 @@ public static function escapeHTMLTags($str, $nl2br = FALSE) {
switch ($itemChar) {
case '<' : //tag or comment starts
$tagsAmount++;
if (!empty($buffer)) {
if ($buffer !== '') {
if ($nl2br) {
$result .= preg_replace("((?:\r\n)|(?:\n\r)|[\r\n])", "<br />\n", $buffer);
$result .= preg_replace("(\r\n|\n\r|[\r\n])", "<br />\n", $buffer);
} else {
$result .= $buffer;
}
}
$buffer = '';
if (substr($str, $nextItemPos, 4) == '<!--') {
if (substr($str, $nextItemPos, 4) === '<!--') {
$offset = $nextItemPos + 4;
$status = 4;
} else {
Expand All @@ -150,7 +150,7 @@ public static function escapeHTMLTags($str, $nl2br = FALSE) {
}
break;
case '>' : //tag ends
if (!empty($buffer)) {
if ($buffer !== '') {
$result .= '<'.str_replace($replace, $replaceWith, $buffer).'>';
}
$buffer = '';
Expand All @@ -159,16 +159,16 @@ public static function escapeHTMLTags($str, $nl2br = FALSE) {
break;
case '"' : //double quote attribute starts or ends
$buffer .= $itemChar;
$status = ($status == 1) ? 2 : 1;
$status = ($status === 1) ? 2 : 1;
$offset = $nextItemPos + 1;
break;
case "'" : //single quote attribute starts or ends
$buffer .= $itemChar;
$status = ($status == 1) ? 3 : 1;
$status = ($status === 1) ? 3 : 1;
$offset = $nextItemPos + 1;
break;
case '-' : //comment ends
if (!empty($buffer)) {
if ($buffer !== '') {
$result .= '<!--'.$buffer.'-->';
}
$buffer = '';
Expand All @@ -178,11 +178,11 @@ public static function escapeHTMLTags($str, $nl2br = FALSE) {
}
} while (FALSE !== $nextItemPos);
$buffer .= substr($str, $offset);
if ((!empty($buffer)) && $status == 0) {
if ($buffer !== '' && $status === 0) {
$result .= $buffer;
}
if ($tagsAmount == 0 && $nl2br == TRUE) {
$result = preg_replace("((?:\r\n)|(?:\n\r)|[\r\n])", "<br />\n", $buffer);
if ($tagsAmount === 0 && $nl2br === TRUE) {
$result = preg_replace("(\r\n|\n\r|[\r\n])", "<br />\n", $buffer);
}
return $result;
}
Expand Down Expand Up @@ -800,4 +800,3 @@ public static function fgetcsv(
return $ret;
}
}

0 comments on commit 5f5304a

Please sign in to comment.