Browse code

browse.php, search.php, includes/corefunctions.php: further security patches...

Clarissa Walker authored on 2026/10/28 21:09:01
Showing 3 changed files
... ...
@@ -211,7 +211,7 @@ if($type) {
211 211
 	$termsList = array();
212 212
 	foreach($termArray as $term => $value) {
213 213
 		if($term == "submit" || $term == "go" || $term == "offset" || $term == "type" || ($term != "complete" && empty($value))) continue;
214
-		$termsList[$term] = "$term=".(is_array($value) ? implode(",", array_map('htmlspecialchars', $value)) : htmlspecialchars($value, ENT_QUOTES));
214
+		$termsList[$term] = "$term=".(is_array($value) ? implode(",", array_map(function($v) { return htmlspecialchars($v, ENT_QUOTES); }, $value)) : htmlspecialchars($value, ENT_QUOTES));
215 215
 	}
216 216
 	$terms = "type=$type".(count($termsList) ? "&" : "").implode("&", $termsList);
217 217
 // End query strings
... ...
@@ -97,7 +97,7 @@ function descript($text) {
97 97
 
98 98
 	// remove any attribute starting with "on" or xmlns
99 99
 
100
-	$text = preg_replace('#(<[^>]+[\\"\'\s])(on[a-z]+|xmlns)[^>]*>#iU', ">", $text);
100
+	$text = preg_replace('#(<[^>]+[\\"\'\s])(on[a-z]+\s*=|xmlns)[^>]*>#iU', ">", $text);
101 101
 
102 102
 	// remove javascript: and vbscript: protocol
103 103
 	
... ...
@@ -575,7 +575,7 @@ function search($storyquery, $countquery, $pagelink = "search.php?", $pagetitle
575 575
 		$terms = array();
576 576
 		foreach($termArray as $term => $value) {
577 577
 			if($term == "submit" || $term == "go" || $term == "offset" || ($term != "complete" && empty($value))) continue;
578
-			$terms[] = "$term=".(is_array($value) ? implode(",", array_map('htmlspecialchars', $value)) : htmlspecialchars($value, ENT_QUOTES));
578
+			$terms[] = "$term=".(is_array($value) ? implode(",", array_map(function($v) { return htmlspecialchars($v, ENT_QUOTES); }, $value)) : htmlspecialchars($value, ENT_QUOTES));
579 579
 		}
580 580
 		$terms = implode("&amp;", $terms);
581 581
 		$terms .= "&amp;";
... ...
@@ -236,7 +236,7 @@ if(isset($_POST['submit']) || isset($_GET['offset'])) {
236 236
 	$termsList = array();
237 237
 	foreach($termArray as $term => $value) {
238 238
 		if($term == "submit" || $term == "wordhigh" || $term == "wordlow" || empty($value) || $term == "formname" || $term == "searchtype") continue;
239
-		$termsList[$term] = "$term=".(is_array($value) ? implode(",", array_map('htmlspecialchars', $value)) : htmlspecialchars($value, ENT_QUOTES));
239
+		$termsList[$term] = "$term=".(is_array($value) ? implode(",", array_map(function($v) { return htmlspecialchars($v, ENT_QUOTES); }, $value)) : htmlspecialchars($value, ENT_QUOTES));
240 240
 	}
241 241
 	$terms = implode("&amp;", $termsList);
242 242
 	if(!empty($scountquery)) {