summaryrefslogtreecommitdiff
path: root/net/phpldapadmin/files/patch-lib_Query.php
blob: 21d5f9b7b8964b27d9cd944112e4767a3f30593a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
--- lib/Query.php.orig	2021-12-12 02:35:51 UTC
+++ lib/Query.php
@@ -87,9 +87,9 @@ class Query extends xmlTemplate {
 					if (in_array($xml_key,$storelower))
 						if (is_array($xml_value))
 							foreach ($xml_value as $index => $value)
-								$xml_value[$index] = strtolower($value);
+								$xml_value[$index] = strtolower((string) $value);
 						else
-							$xml_value = strtolower($xml_value);
+							$xml_value = strtolower((string) $xml_value);
 
 					# Items that must be stored as arrays
 					if (in_array($xml_key,$storearray) && ! is_array($xml_value))
@@ -109,7 +109,7 @@ class Query extends xmlTemplate {
 		# Check we have some manditory items.
 		foreach (array() as $key) {
 			if (! isset($this->$key)
-				|| (! is_array($this->$key) && ! trim($this->$key))) {
+				|| (! is_array($this->$key) && ! trim((string) $this->$key))) {
 
 				$this->setInvalid(sprintf(_('Missing %s in the XML file.'),$key));
 				break;
@@ -138,7 +138,7 @@ class Query extends xmlTemplate {
 			$query['scope'] = get_request('scope','REQUEST',false,'sub');
 			$attrs = get_request('display_attrs','REQUEST');
 
-			$attrs = preg_replace('/\s+/','',$attrs);
+			$attrs = preg_replace('/\s+/','',is_null($attrs)? "":$attrs);
 			if ($attrs)
 				$query['attrs'] = explode(',',$attrs);
 			else
@@ -198,9 +198,9 @@ class Query extends xmlTemplate {
 	public function getDNEncode($url=true) {
 		// @todo Be nice to do all this in 1 location
 		if ($url)
-			return urlencode(preg_replace('/%([0-9a-fA-F]+)/',"%25\\1",$this->dn));
+			return urlencode(preg_replace('/%([0-9a-fA-F]+)/',"%25\\1",is_null($this->dn)? "":$this->dn));
 		else
-			return preg_replace('/%([0-9a-fA-F]+)/',"%25\\1",$this->dn);
+			return preg_replace('/%([0-9a-fA-F]+)/',"%25\\1",is_null($this->dn)? "":$this->dn);
 	}
 
 	public function getAttrSortOrder() {
@@ -216,9 +216,9 @@ class Query extends xmlTemplate {
 				array_push($result,$attribute->getName());
 
 		} else {
-			$display = preg_replace('/,\s+/',',',get_request('orderby','REQUEST',false,'dn'));
+			$display = preg_replace('/,\s+/',',',get_request('orderby','REQUEST',false,is_null('dn')? "":'dn'));
 
-			if (trim($display))
+			if (trim((string) $display))
 				$result = explode(',',$display);
 		}
 
@@ -238,9 +238,9 @@ class Query extends xmlTemplate {
 				array_push($result,$attribute->getName());
 
 		} else {
-			$display = preg_replace('/,\s+/',',',get_request('display_attrs','REQUEST',false,''));
+			$display = preg_replace('/,\s+/',',',get_request('display_attrs','REQUEST',false,is_null('')? "":''));
 
-			if (trim($display))
+			if (trim((string) $display))
 				$result = explode(',',$display);
 		}