From 132ab498b57b0588a6fdf0e06182aa0aefdf984d Mon Sep 17 00:00:00 2001
From: pezcurrel
Date: Sun, 25 Aug 2024 17:51:20 +0200
Subject: [PATCH] =?UTF-8?q?Big=20revision=20of=20the=20=E2=80=9Cstrip?=
=?UTF-8?q?=E2=80=9D=20function:=20now=20it=20strips=20more,=20so=20bad=20?=
=?UTF-8?q?html=20in=20instances=E2=80=99=20extended=20descriptions=20is?=
=?UTF-8?q?=20less=20likely=20to=20break=20results=20pages?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
web/site/instances.php | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/web/site/instances.php b/web/site/instances.php
index d1afced..e79aa27 100644
--- a/web/site/instances.php
+++ b/web/site/instances.php
@@ -965,21 +965,23 @@ function nullyp($str) {
function strip($str,$uri) {
if (nullemp($str)) return(null);
- $str=preg_replace('##is','',$str);// strip all inline css styles definitions
- $str=preg_replace('#" to "
"
+ $str=preg_replace('#]*>#i','',$str);
+ $str=preg_replace('#]*href="(?![a-zA-Z]+://)([^"]+)#i','','
'],$str);
- $str=preg_replace(['#
#i','#
#i','#
#i','#',''],$str);
+ //$str=preg_replace(['#
#i','#
#i','#
#i','#',''],$str);
$str=preg_replace(['##i','##i','##i','##i'],['','','',''],$str);
- $str=preg_replace('#\s*
#is','',$str);
- $str=strip_tags($str,'
');
- // all this part below is to try and assign the css "nobott" css class to a possible closing /
//,
- // to avoid the useless and UGLY last bottom-margin :-))
- $str=preg_replace('#^\s*#m','',$str);// strip all spaces from empty lines
- $str=preg_replace('#[\r\n]#',' ',$str);// strip all "wrap chars"
- $str=preg_replace('#(|||
)#i','$1'.N,$str);// now add a newline after every and so on
- $str=rtrim($str);// trim the newline at the end of the whole text block in order for the next preg_replace to match against $ as end of the whole text block
- $str=preg_replace(['#]*>(.*)
$#i', '#]*>(.*)
$#i', '#$#i', '#]*>(.*)
$#i'],['$1
', '$1
', '', '$1
'],$str);
+ $str=preg_replace('#]*>\s*
#is','',$str);
+ $str=preg_replace(['#]*>(.*)
#i','#]>(.*)
#i'],['
$1
','
$1
'],$str);
+ $str=strip_tags($str,'
');
+ $str=preg_replace('#<([^>]*)\s(style|class)="[^"]*"([^>]*)>#i','<$1$3>',$str);
+ $str=preg_replace(['#]*>#i','##i'],['
','
'],$str);
+ $str=preg_replace(['#<([ou])l[^>]*>#i','#([ou])l>#i'],['
<$1l class="nobott">','$1l>
'],$str);
+ $str=preg_replace(['#
\s+
#i','#^(
)+#i','#(
){3,}#i','#(
)+$#i','#([ou])l>\s*(
)+#i','#
\s*(
)+#i'],['
','','
','','$1l>
','
'],$str);
+ // this part below is to try and assign the css "nobott" css class to a possible closing /, to avoid the useless and UGLY last bottom-margin :-)
+ $str=preg_replace(['#]*>(.*)
$#i','#$#i'],['$1
',''],$str);
return $str;
}