Completed
Branch develop (5d7232)
by
unknown
17:50
created
htdocs/societe/class/companybankaccount.class.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	/**
87 87
 	 * @var array  Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
88 88
 	 */
89
-	public $fields=array(
89
+	public $fields = array(
90 90
 		'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>-1,),
91 91
 		'type' => array('type'=>'varchar(32)', 'label'=>'Type', 'enabled'=>'1', 'position'=>15, 'notnull'=>1, 'visible'=>-1,),
92 92
 		'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'picto'=>'company', 'enabled'=>'1', 'position'=>20, 'notnull'=>1, 'visible'=>-1, 'css'=>'maxwidth500 widthcentpercentminusxx', 'csslist'=>'tdoverflowmax150',),
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 	/**
243 243
 	 * @var string external payment site
244 244
 	 */
245
-	public $ext_payment_site;	// Name of the external payment system ('StripeLive', 'StripeTest', 'StancerLive', 'StancerTest', ...)
245
+	public $ext_payment_site; // Name of the external payment system ('StripeLive', 'StripeTest', 'StancerLive', 'StancerTest', ...)
246 246
 
247 247
 	/**
248 248
 	 * @var string comment
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 		}
328 328
 
329 329
 		if (empty($this->datec)) {
330
-			$this->datec=$now;
330
+			$this->datec = $now;
331 331
 		}
332 332
 
333 333
 		// Correct ->default_rib to not set the new account as default, if there is already 1. We want to be sure to have always 1 default for type = 'ban'.
@@ -527,9 +527,9 @@  discard block
 block discarded – undo
527 527
 				$this->rum             = $obj->rum;
528 528
 				$this->frstrecur       = $obj->frstrecur;
529 529
 				$this->date_rum        = $this->db->jdate($obj->date_rum);
530
-				$this->stripe_card_ref = $obj->stripe_card_ref;		// External system payment mode ID
531
-				$this->stripe_account  = $obj->stripe_account;		// External system customer ID
532
-				$this->ext_payment_site= $obj->ext_payment_site;	// External system name ('StripeLive', 'StripeTest', 'StancerLive', 'StancerTest', ...)
530
+				$this->stripe_card_ref = $obj->stripe_card_ref; // External system payment mode ID
531
+				$this->stripe_account  = $obj->stripe_account; // External system customer ID
532
+				$this->ext_payment_site = $obj->ext_payment_site; // External system name ('StripeLive', 'StripeTest', 'StancerLive', 'StancerTest', ...)
533 533
 				$this->last_main_doc   = $obj->last_main_doc;
534 534
 				$this->model_pdf   	   = $obj->model_pdf;
535 535
 			}
Please login to merge, or discard this patch.
htdocs/compta/bank/class/account.class.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -466,13 +466,13 @@  discard block
 block discarded – undo
466 466
 		$sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_url (";
467 467
 		$sql .= "fk_bank";
468 468
 		$sql .= ", url_id";
469
-		$sql .= ", url";		// deprecated
469
+		$sql .= ", url"; // deprecated
470 470
 		$sql .= ", label";
471 471
 		$sql .= ", type";
472 472
 		$sql .= ") VALUES (";
473 473
 		$sql .= " ".((int) $line_id);
474 474
 		$sql .= ", ".((int) $url_id);
475
-		$sql .= ", '".$this->db->escape($url)."'";		// deprecated
475
+		$sql .= ", '".$this->db->escape($url)."'"; // deprecated
476 476
 		$sql .= ", '".$this->db->escape($label)."'";
477 477
 		$sql .= ", '".$this->db->escape($type)."'";
478 478
 		$sql .= ")";
@@ -1462,9 +1462,9 @@  discard block
 block discarded – undo
1462 1462
 		}
1463 1463
 		// show categories for this record only in ajax to not overload lists
1464 1464
 		if (isModEnabled('categorie') && !$nofetch) {
1465
-			require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
1465
+			require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
1466 1466
 			$form = new Form($this->db);
1467
-			$datas['categories'] = '<br>' . $form->showCategories($this->id, Categorie::TYPE_ACCOUNT, 1);
1467
+			$datas['categories'] = '<br>'.$form->showCategories($this->id, Categorie::TYPE_ACCOUNT, 1);
1468 1468
 		}
1469 1469
 
1470 1470
 		return $datas;
@@ -1588,7 +1588,7 @@  discard block
 block discarded – undo
1588 1588
 			$this->error = 'SwiftNotValid';
1589 1589
 		}
1590 1590
 
1591
-		if (! $error) {
1591
+		if (!$error) {
1592 1592
 			return 1;
1593 1593
 		} else {
1594 1594
 			return 0;
@@ -2384,7 +2384,7 @@  discard block
 block discarded – undo
2384 2384
 
2385 2385
 		// Check statement field
2386 2386
 		if (getDolGlobalString('BANK_STATEMENT_REGEX_RULE')) {
2387
-			if (!preg_match('/' . getDolGlobalString('BANK_STATEMENT_REGEX_RULE').'/', $this->num_releve)) {
2387
+			if (!preg_match('/'.getDolGlobalString('BANK_STATEMENT_REGEX_RULE').'/', $this->num_releve)) {
2388 2388
 				$this->errors[] = $langs->trans("ErrorBankStatementNameMustFollowRegex", getDolGlobalString('BANK_STATEMENT_REGEX_RULE'));
2389 2389
 				return -1;
2390 2390
 			}
Please login to merge, or discard this patch.
htdocs/resource/card.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -42,15 +42,15 @@  discard block
 block discarded – undo
42 42
 $ref					= GETPOST('ref', 'alpha');
43 43
 $address				= GETPOST('address', 'alpha');
44 44
 $zip					= GETPOST('zipcode', 'alpha');
45
-$town					= GETPOST('town', 'alpha');
45
+$town = GETPOST('town', 'alpha');
46 46
 $country_id				= GETPOSTINT('country_id');
47
-$state_id				= GETPOSTINT('state_id');
47
+$state_id = GETPOSTINT('state_id');
48 48
 $description			= GETPOST('description', 'restricthtml');
49 49
 $phone					= GETPOST('phone', 'alpha');
50 50
 $email					= GETPOST('email', 'alpha');
51
-$max_users				= GETPOSTINT('max_users');
52
-$confirm				= GETPOST('confirm', 'aZ09');
53
-$fk_code_type_resource	= GETPOST('fk_code_type_resource', 'aZ09');
51
+$max_users = GETPOSTINT('max_users');
52
+$confirm = GETPOST('confirm', 'aZ09');
53
+$fk_code_type_resource = GETPOST('fk_code_type_resource', 'aZ09');
54 54
 
55 55
 // Protection if external user
56 56
 if ($user->socid > 0) {
@@ -105,17 +105,17 @@  discard block
 block discarded – undo
105 105
 				setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Ref")), null, 'errors');
106 106
 				$action = 'create';
107 107
 			} else {
108
-				$object->ref                    = $ref;
109
-				$object->address				= $address;
110
-				$object->zip					= $zip;
111
-				$object->town					= $town;
108
+				$object->ref = $ref;
109
+				$object->address = $address;
110
+				$object->zip = $zip;
111
+				$object->town = $town;
112 112
 				$object->country_id				= $country_id;
113
-				$object->state_id				= $state_id;
113
+				$object->state_id = $state_id;
114 114
 				$object->description			= $description;
115 115
 				$object->phone					= $phone;
116 116
 				$object->email					= $email;
117
-				$object->max_users				= $max_users;
118
-				$object->fk_code_type_resource	= $fk_code_type_resource;
117
+				$object->max_users = $max_users;
118
+				$object->fk_code_type_resource = $fk_code_type_resource;
119 119
 
120 120
 				// Fill array 'array_options' with data from add form
121 121
 				$ret = $extrafields->setOptionalsFromPost(null, $object);
@@ -152,17 +152,17 @@  discard block
 block discarded – undo
152 152
 		if (!$error) {
153 153
 			$res = $object->fetch($id);
154 154
 			if ($res > 0) {
155
-				$object->ref          			= $ref;
156
-				$object->address				= $address;
157
-				$object->zip					= $zip;
158
-				$object->town					= $town;
159
-				$object->country_id             = $country_id;
160
-				$object->state_id				= $state_id;
161
-				$object->description  			= $description;
155
+				$object->ref = $ref;
156
+				$object->address = $address;
157
+				$object->zip = $zip;
158
+				$object->town = $town;
159
+				$object->country_id = $country_id;
160
+				$object->state_id = $state_id;
161
+				$object->description = $description;
162 162
 				$object->phone					= $phone;
163 163
 				$object->email					= $email;
164
-				$object->max_users				= $max_users;
165
-				$object->fk_code_type_resource  = $fk_code_type_resource;
164
+				$object->max_users = $max_users;
165
+				$object->fk_code_type_resource = $fk_code_type_resource;
166 166
 
167 167
 				// Fill array 'array_options' with data from add form
168 168
 				$ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
@@ -253,13 +253,13 @@  discard block
 block discarded – undo
253 253
 		print '</td></tr>';
254 254
 
255 255
 		// Zip / Town
256
-		print '<tr><td>'.$form->editfieldkey('Zip', 'zipcode', '', $object, 0).'</td><td'.($conf->browser->layout == 'phone' ? ' colspan="3"': '').'>';
256
+		print '<tr><td>'.$form->editfieldkey('Zip', 'zipcode', '', $object, 0).'</td><td'.($conf->browser->layout == 'phone' ? ' colspan="3"' : '').'>';
257 257
 		print $formresource->select_ziptown($object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 0, 0, '', 'maxwidth100');
258 258
 		print '</td>';
259 259
 		if ($conf->browser->layout == 'phone') {
260 260
 			print '</tr><tr>';
261 261
 		}
262
-		print '<td>'.$form->editfieldkey('Town', 'town', '', $object, 0).'</td><td'.($conf->browser->layout == 'phone' ? ' colspan="3"': '').'>';
262
+		print '<td>'.$form->editfieldkey('Town', 'town', '', $object, 0).'</td><td'.($conf->browser->layout == 'phone' ? ' colspan="3"' : '').'>';
263 263
 		print $formresource->select_ziptown($object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id'));
264 264
 		print $form->widgetForTranslation("town", $object, $permissiontoadd, 'string', 'alphanohtml', 'maxwidth100 quatrevingtpercent');
265 265
 		print '</td></tr>';
Please login to merge, or discard this patch.
htdocs/resource/class/dolresource.class.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -223,9 +223,9 @@  discard block
 block discarded – undo
223 223
 		$sql .= "note_public,";
224 224
 		$sql .= "note_private";
225 225
 		$sql .= ") VALUES (";
226
-		$sql .= getEntity('resource') . ", ";
226
+		$sql .= getEntity('resource').", ";
227 227
 		foreach ($new_resource_values as $value) {
228
-			$sql .= " " . ((isset($value) && $value > 0) ? "'" . $this->db->escape($value) . "'" : 'NULL') . ",";
228
+			$sql .= " ".((isset($value) && $value > 0) ? "'".$this->db->escape($value)."'" : 'NULL').",";
229 229
 		}
230 230
 		$sql = rtrim($sql, ",");
231 231
 		$sql .= ")";
@@ -233,9 +233,9 @@  discard block
 block discarded – undo
233 233
 		// Database session
234 234
 		$this->db->begin();
235 235
 		try {
236
-			dol_syslog(get_class($this) . "::create", LOG_DEBUG);
236
+			dol_syslog(get_class($this)."::create", LOG_DEBUG);
237 237
 		} catch (Exception $exception) {
238
-			error_log('dol_syslog error: ' . $exception->getMessage());
238
+			error_log('dol_syslog error: '.$exception->getMessage());
239 239
 		}
240 240
 		$resql = $this->db->query($sql);
241 241
 		if (!$resql) {
@@ -247,14 +247,14 @@  discard block
 block discarded – undo
247 247
 			$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
248 248
 			$result = $this->insertExtraFields();
249 249
 			if ($result < 0) {
250
-				$error=-1;
250
+				$error = -1;
251 251
 			}
252 252
 		}
253 253
 
254 254
 		if (!$error && !$no_trigger) {
255 255
 			$result = $this->call_trigger('RESOURCE_CREATE', $user);
256 256
 			if ($result < 0) {
257
-				$error=-1;
257
+				$error = -1;
258 258
 			}
259 259
 		}
260 260
 
@@ -262,9 +262,9 @@  discard block
 block discarded – undo
262 262
 		if ($error) {
263 263
 			foreach ($this->errors as $errmsg) {
264 264
 				try {
265
-					dol_syslog(get_class($this) . "::create " . $errmsg, LOG_ERR);
265
+					dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
266 266
 				} catch (Exception $exception) {
267
-					error_log('dol_syslog error: ' . $exception->getMessage());
267
+					error_log('dol_syslog error: '.$exception->getMessage());
268 268
 				}
269 269
 				$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
270 270
 			}
@@ -971,7 +971,7 @@  discard block
 block discarded – undo
971 971
 		}
972 972
 		$result .= $linkend;
973 973
 
974
-		$hookmanager->initHooks(array($this->element . 'dao'));
974
+		$hookmanager->initHooks(array($this->element.'dao'));
975 975
 		$parameters = array('id'=>$this->id, 'getnomurl' => &$result);
976 976
 		$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
977 977
 		if ($reshook > 0) {
Please login to merge, or discard this patch.
test/phpunit/SecurityTest.php 1 patch
Spacing   +293 added lines, -293 removed lines patch added patch discarded remove patch
@@ -24,32 +24,32 @@  discard block
 block discarded – undo
24 24
  *		\remarks	To run this script as CLI:  phpunit filename.php
25 25
  */
26 26
 
27
-global $conf,$user,$langs,$db;
27
+global $conf, $user, $langs, $db;
28 28
 //define('TEST_DB_FORCE_TYPE','mysql');	// This is to force using mysql driver
29 29
 //require_once 'PHPUnit/Autoload.php';
30 30
 
31
-if (! defined('NOREQUIRESOC')) {
31
+if (!defined('NOREQUIRESOC')) {
32 32
 	define('NOREQUIRESOC', '1');
33 33
 }
34
-if (! defined('NOCSRFCHECK')) {
34
+if (!defined('NOCSRFCHECK')) {
35 35
 	define('NOCSRFCHECK', '1');
36 36
 }
37
-if (! defined('NOTOKENRENEWAL')) {
37
+if (!defined('NOTOKENRENEWAL')) {
38 38
 	define('NOTOKENRENEWAL', '1');
39 39
 }
40
-if (! defined('NOREQUIREMENU')) {
40
+if (!defined('NOREQUIREMENU')) {
41 41
 	define('NOREQUIREMENU', '1'); // If there is no menu to show
42 42
 }
43
-if (! defined('NOREQUIREHTML')) {
43
+if (!defined('NOREQUIREHTML')) {
44 44
 	define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php
45 45
 }
46
-if (! defined('NOREQUIREAJAX')) {
46
+if (!defined('NOREQUIREAJAX')) {
47 47
 	define('NOREQUIREAJAX', '1');
48 48
 }
49
-if (! defined("NOLOGIN")) {
50
-	define("NOLOGIN", '1');       // If this page is public (can be called outside logged session)
49
+if (!defined("NOLOGIN")) {
50
+	define("NOLOGIN", '1'); // If this page is public (can be called outside logged session)
51 51
 }
52
-if (! defined("NOSESSION")) {
52
+if (!defined("NOSESSION")) {
53 53
 	define("NOSESSION", '1');
54 54
 }
55 55
 
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	$user->fetch(1);
64 64
 	$user->getrights();
65 65
 }
66
-$conf->global->MAIN_DISABLE_ALL_MAILS=1;
66
+$conf->global->MAIN_DISABLE_ALL_MAILS = 1;
67 67
 
68 68
 
69 69
 /**
@@ -92,11 +92,11 @@  discard block
 block discarded – undo
92 92
 		parent::__construct($name);
93 93
 
94 94
 		//$this->sharedFixture
95
-		global $conf,$user,$langs,$db;
96
-		$this->savconf=$conf;
97
-		$this->savuser=$user;
98
-		$this->savlangs=$langs;
99
-		$this->savdb=$db;
95
+		global $conf, $user, $langs, $db;
96
+		$this->savconf = $conf;
97
+		$this->savuser = $user;
98
+		$this->savlangs = $langs;
99
+		$this->savdb = $db;
100 100
 
101 101
 		print __METHOD__." db->type=".$db->type." user->id=".$user->id;
102 102
 		//print " - db ".$db->db;
@@ -110,8 +110,8 @@  discard block
 block discarded – undo
110 110
 	 */
111 111
 	public static function setUpBeforeClass(): void
112 112
 	{
113
-		global $conf,$user,$langs,$db;
114
-		$db->begin();	// This is to have all actions inside a transaction even if test launched without suite.
113
+		global $conf, $user, $langs, $db;
114
+		$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
115 115
 
116 116
 		print __METHOD__."\n";
117 117
 	}
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 	 */
124 124
 	public static function tearDownAfterClass(): void
125 125
 	{
126
-		global $conf,$user,$langs,$db;
126
+		global $conf, $user, $langs, $db;
127 127
 		$db->rollback();
128 128
 
129 129
 		// Restore value to a neutral value (it was set to a test value by some tests)
@@ -139,11 +139,11 @@  discard block
 block discarded – undo
139 139
 	 */
140 140
 	protected function setUp(): void
141 141
 	{
142
-		global $conf,$user,$langs,$db;
143
-		$conf=$this->savconf;
144
-		$user=$this->savuser;
145
-		$langs=$this->savlangs;
146
-		$db=$this->savdb;
142
+		global $conf, $user, $langs, $db;
143
+		$conf = $this->savconf;
144
+		$user = $this->savuser;
145
+		$langs = $this->savlangs;
146
+		$db = $this->savdb;
147 147
 
148 148
 		print __METHOD__."\n";
149 149
 	}
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 	public function testSetLang()
167 167
 	{
168 168
 		global $conf;
169
-		$conf=$this->savconf;
169
+		$conf = $this->savconf;
170 170
 
171 171
 		$tmplangs = new Translate('', $conf);
172 172
 
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 		// More on https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet
189 189
 
190 190
 		// Should be OK
191
-		$expectedresult=0;
191
+		$expectedresult = 0;
192 192
 
193 193
 		/*
194 194
 		$test = '';
@@ -196,107 +196,107 @@  discard block
 block discarded – undo
196 196
 		$this->assertGreaterThanOrEqual(0, $result, 'Error on testSqlAndScriptInject kkk');
197 197
 		*/
198 198
 
199
-		$_SERVER["PHP_SELF"]='/DIR WITH SPACE/htdocs/admin/index.php';
200
-		$result=testSqlAndScriptInject($_SERVER["PHP_SELF"], 2);
199
+		$_SERVER["PHP_SELF"] = '/DIR WITH SPACE/htdocs/admin/index.php';
200
+		$result = testSqlAndScriptInject($_SERVER["PHP_SELF"], 2);
201 201
 		$this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for PHP_SELF that should be ok');
202 202
 
203 203
 		$test = 'This is a < inside string with < and > also and tag like <a> before the >';
204
-		$result=testSqlAndScriptInject($test, 0);
204
+		$result = testSqlAndScriptInject($test, 0);
205 205
 		$this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject expected 0b');
206 206
 
207 207
 		$test = 'This is the union of all for the selection of the best';
208
-		$result=testSqlAndScriptInject($test, 0);
208
+		$result = testSqlAndScriptInject($test, 0);
209 209
 		$this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject expected 0c');
210 210
 
211
-		$test='/user/perms.php?id=1&action=addrights&entity=1&rights=123&confirm=yes&token=123456789&updatedmodulename=lmscoursetracking';
212
-		$result=testSqlAndScriptInject($test, 1);
211
+		$test = '/user/perms.php?id=1&action=addrights&entity=1&rights=123&confirm=yes&token=123456789&updatedmodulename=lmscoursetracking';
212
+		$result = testSqlAndScriptInject($test, 1);
213 213
 		print "test=".$test." result=".$result."\n";
214 214
 		$this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject with a valid url');
215 215
 
216 216
 		// Should detect attack
217
-		$expectedresult=1;
217
+		$expectedresult = 1;
218 218
 
219
-		$_SERVER["PHP_SELF"]='/DIR WITH SPACE/htdocs/admin/index.php/<svg>';
220
-		$result=testSqlAndScriptInject($_SERVER["PHP_SELF"], 2);
219
+		$_SERVER["PHP_SELF"] = '/DIR WITH SPACE/htdocs/admin/index.php/<svg>';
220
+		$result = testSqlAndScriptInject($_SERVER["PHP_SELF"], 2);
221 221
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject for PHP_SELF that should detect XSS');
222 222
 
223 223
 		$test = 'select @@version';
224
-		$result=testSqlAndScriptInject($test, 0);
224
+		$result = testSqlAndScriptInject($test, 0);
225 225
 		$this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for SQL1a. Should find an attack on POST param and did not.');
226 226
 
227 227
 		$test = 'select @@version';
228
-		$result=testSqlAndScriptInject($test, 1);
228
+		$result = testSqlAndScriptInject($test, 1);
229 229
 		$this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for SQL1b. Should find an attack on GET param and did not.');
230 230
 
231 231
 		$test = '... update ... set ... =';
232
-		$result=testSqlAndScriptInject($test, 1);
232
+		$result = testSqlAndScriptInject($test, 1);
233 233
 		$this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for SQL2a. Should find an attack on GET param and did not.');
234 234
 
235 235
 		$test = "delete\nfrom";
236
-		$result=testSqlAndScriptInject($test, 1);
236
+		$result = testSqlAndScriptInject($test, 1);
237 237
 		$this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for SQL2b. Should find an attack on GET param and did not.');
238 238
 
239 239
 		$test = 'action=update& ... set ... =';
240
-		$result=testSqlAndScriptInject($test, 1);
240
+		$result = testSqlAndScriptInject($test, 1);
241 241
 		$this->assertEquals(0, $result, 'Error on testSqlAndScriptInject for SQL2b. Should not find an attack on GET param and did.');
242 242
 
243 243
 		$test = '... union ... selection ';
244
-		$result=testSqlAndScriptInject($test, 1);
244
+		$result = testSqlAndScriptInject($test, 1);
245 245
 		$this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for SQL2c. Should find an attack on GET param and did not.');
246 246
 
247 247
 		$test = 'j&#x61;vascript:';
248
-		$result=testSqlAndScriptInject($test, 0);
248
+		$result = testSqlAndScriptInject($test, 0);
249 249
 		$this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for javascript1. Should find an attack and did not.');
250 250
 
251 251
 		$test = 'j&#x61vascript:';
252
-		$result=testSqlAndScriptInject($test, 0);
252
+		$result = testSqlAndScriptInject($test, 0);
253 253
 		$this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for javascript2. Should find an attack and did not.');
254 254
 
255 255
 		$test = 'javascript&colon&#x3B;alert(1)';
256
-		$result=testSqlAndScriptInject($test, 0);
256
+		$result = testSqlAndScriptInject($test, 0);
257 257
 		$this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for javascript2');
258 258
 
259
-		$test="<img src='1.jpg' onerror =javascript:alert('XSS')>";
260
-		$result=testSqlAndScriptInject($test, 0);
259
+		$test = "<img src='1.jpg' onerror =javascript:alert('XSS')>";
260
+		$result = testSqlAndScriptInject($test, 0);
261 261
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa1');
262 262
 
263
-		$test="<img src='1.jpg' onerror =javascript:alert('XSS')>";
264
-		$result=testSqlAndScriptInject($test, 2);
263
+		$test = "<img src='1.jpg' onerror =javascript:alert('XSS')>";
264
+		$result = testSqlAndScriptInject($test, 2);
265 265
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa2');
266 266
 
267
-		$test='<IMG SRC=# onmouseover="alert(1)">';
268
-		$result=testSqlAndScriptInject($test, 0);
267
+		$test = '<IMG SRC=# onmouseover="alert(1)">';
268
+		$result = testSqlAndScriptInject($test, 0);
269 269
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa3');
270
-		$test='<IMG SRC onmouseover="alert(1)">';
271
-		$result=testSqlAndScriptInject($test, 0);
270
+		$test = '<IMG SRC onmouseover="alert(1)">';
271
+		$result = testSqlAndScriptInject($test, 0);
272 272
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa4');
273
-		$test='<IMG onmouseover="alert(1)">';
274
-		$result=testSqlAndScriptInject($test, 0);
273
+		$test = '<IMG onmouseover="alert(1)">';
274
+		$result = testSqlAndScriptInject($test, 0);
275 275
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa5');
276
-		$test='<IMG SRC=/ onerror="alert(1)">';
277
-		$result=testSqlAndScriptInject($test, 0);
276
+		$test = '<IMG SRC=/ onerror="alert(1)">';
277
+		$result = testSqlAndScriptInject($test, 0);
278 278
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa6');
279
-		$test='<IMG SRC=" &#14;  javascript:alert(1);">';
280
-		$result=testSqlAndScriptInject($test, 0);
279
+		$test = '<IMG SRC=" &#14;  javascript:alert(1);">';
280
+		$result = testSqlAndScriptInject($test, 0);
281 281
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa7');
282 282
 
283
-		$test='<IMG SRC=&#106;&#97;&#118;&#97;&#115;&#99;&#114;&#105;&#112;&#116;&#58;&#97;&#108;&#101;&#114;&#116;&#40;&#39;&#88;&#83;&#83;&#39;&#41;>';
284
-		$result=testSqlAndScriptInject($test, 0);
283
+		$test = '<IMG SRC=&#106;&#97;&#118;&#97;&#115;&#99;&#114;&#105;&#112;&#116;&#58;&#97;&#108;&#101;&#114;&#116;&#40;&#39;&#88;&#83;&#83;&#39;&#41;>';
284
+		$result = testSqlAndScriptInject($test, 0);
285 285
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject bbb');
286 286
 
287
-		$test='<SCRIPT SRC=http://xss.rocks/xss.js></SCRIPT>';
288
-		$result=testSqlAndScriptInject($test, 0);
287
+		$test = '<SCRIPT SRC=http://xss.rocks/xss.js></SCRIPT>';
288
+		$result = testSqlAndScriptInject($test, 0);
289 289
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject ccc');
290 290
 
291
-		$test='<IMG SRC="javascript:alert(\'XSS\');">';
292
-		$result=testSqlAndScriptInject($test, 1);
291
+		$test = '<IMG SRC="javascript:alert(\'XSS\');">';
292
+		$result = testSqlAndScriptInject($test, 1);
293 293
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject ddd');
294 294
 
295
-		$test='<IMG """><SCRIPT>alert("XSS")</SCRIPT>">';
296
-		$result=testSqlAndScriptInject($test, 0);
295
+		$test = '<IMG """><SCRIPT>alert("XSS")</SCRIPT>">';
296
+		$result = testSqlAndScriptInject($test, 0);
297 297
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject eee');
298 298
 
299
-		$test='<!-- Google analytics -->
299
+		$test = '<!-- Google analytics -->
300 300
 			<script>
301 301
 			  (function(i,s,o,g,r,a,m){i[\'GoogleAnalyticsObject\']=r;i[r]=i[r]||function(){
302 302
 			  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
@@ -307,60 +307,60 @@  discard block
 block discarded – undo
307 307
 			  ga(\'send\', \'pageview\');
308 308
 
309 309
 			</script>';
310
-		$result=testSqlAndScriptInject($test, 0);
310
+		$result = testSqlAndScriptInject($test, 0);
311 311
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject eee');
312 312
 
313
-		$test="<IMG SRC=\"jav\tascript:alert('XSS');\">";		// Is locked by some browser like chrome because the default directive no-referrer-when-downgrade is sent when requesting the SRC and then refused because of browser protection on img src load without referrer.
314
-		$test="<IMG SRC=\"jav&#x0D;ascript:alert('XSS');\">";	// Same
313
+		$test = "<IMG SRC=\"jav\tascript:alert('XSS');\">"; // Is locked by some browser like chrome because the default directive no-referrer-when-downgrade is sent when requesting the SRC and then refused because of browser protection on img src load without referrer.
314
+		$test = "<IMG SRC=\"jav&#x0D;ascript:alert('XSS');\">"; // Same
315 315
 
316
-		$test='<SCRIPT/XSS SRC="http://xss.rocks/xss.js"></SCRIPT>';
317
-		$result=testSqlAndScriptInject($test, 0);
316
+		$test = '<SCRIPT/XSS SRC="http://xss.rocks/xss.js"></SCRIPT>';
317
+		$result = testSqlAndScriptInject($test, 0);
318 318
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject fff1');
319
-		$test='<SCRIPT/SRC="http://xss.rocks/xss.js"></SCRIPT>';
320
-		$result=testSqlAndScriptInject($test, 0);
319
+		$test = '<SCRIPT/SRC="http://xss.rocks/xss.js"></SCRIPT>';
320
+		$result = testSqlAndScriptInject($test, 0);
321 321
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject fff2');
322 322
 
323 323
 		// This case seems to be filtered by browsers now.
324
-		$test='<BODY onload!#$%&()*~+-_.,:;?@[/|\]^`=alert(1)>';
324
+		$test = '<BODY onload!#$%&()*~+-_.,:;?@[/|\]^`=alert(1)>';
325 325
 		//$result=testSqlAndScriptInject($test, 0);
326 326
 		//$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject ggg');
327 327
 
328
-		$test='<iframe src=http://xss.rocks/scriptlet.html <';
329
-		$result=testSqlAndScriptInject($test, 0);
328
+		$test = '<iframe src=http://xss.rocks/scriptlet.html <';
329
+		$result = testSqlAndScriptInject($test, 0);
330 330
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject hhh');
331 331
 
332
-		$test='Set.constructor`alert\x281\x29```';
333
-		$result=testSqlAndScriptInject($test, 0);
332
+		$test = 'Set.constructor`alert\x281\x29```';
333
+		$result = testSqlAndScriptInject($test, 0);
334 334
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject iii');
335 335
 
336
-		$test="on<!-- ab\nc -->error=alert(1)";
337
-		$result=testSqlAndScriptInject($test, 0);
336
+		$test = "on<!-- ab\nc -->error=alert(1)";
337
+		$result = testSqlAndScriptInject($test, 0);
338 338
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject jjj');
339 339
 
340
-		$test="<img src=x one<a>rror=alert(document.location)";
341
-		$result=testSqlAndScriptInject($test, 0);
340
+		$test = "<img src=x one<a>rror=alert(document.location)";
341
+		$result = testSqlAndScriptInject($test, 0);
342 342
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject kkk');
343 343
 
344
-		$test="<a onpointerdown=alert(document.domain)>XSS</a>";
345
-		$result=testSqlAndScriptInject($test, 0);
344
+		$test = "<a onpointerdown=alert(document.domain)>XSS</a>";
345
+		$result = testSqlAndScriptInject($test, 0);
346 346
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject lll');
347 347
 
348
-		$test='<a onscrollend=alert(1) style="display:block;overflow:auto;border:1px+dashed;width:500px;height:100px;"><br><br><br><br><br><span+id=x>test</span></a>';	// Add the char %F6 into the variable
349
-		$result=testSqlAndScriptInject($test, 0);
348
+		$test = '<a onscrollend=alert(1) style="display:block;overflow:auto;border:1px+dashed;width:500px;height:100px;"><br><br><br><br><br><span+id=x>test</span></a>'; // Add the char %F6 into the variable
349
+		$result = testSqlAndScriptInject($test, 0);
350 350
 		//print "test=".$test." result=".$result."\n";
351 351
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject mmm');
352 352
 
353 353
 
354
-		$test="Text with ' encoded with the numeric html entity converted into text entity &#39; (like when submitted by CKEditor)";
355
-		$result=testSqlAndScriptInject($test, 0);	// result must be 0
354
+		$test = "Text with ' encoded with the numeric html entity converted into text entity &#39; (like when submitted by CKEditor)";
355
+		$result = testSqlAndScriptInject($test, 0); // result must be 0
356 356
 		$this->assertEquals(0, $result, 'Error on testSqlAndScriptInject mmm, result should be 0 and is not');
357 357
 
358
-		$test ='<a href="j&Tab;a&Tab;v&Tab;asc&NewLine;ri&Tab;pt:&lpar;a&Tab;l&Tab;e&Tab;r&Tab;t&Tab;(document.cookie)&rpar;">XSS</a>';
359
-		$result=testSqlAndScriptInject($test, 0);
358
+		$test = '<a href="j&Tab;a&Tab;v&Tab;asc&NewLine;ri&Tab;pt:&lpar;a&Tab;l&Tab;e&Tab;r&Tab;t&Tab;(document.cookie)&rpar;">XSS</a>';
359
+		$result = testSqlAndScriptInject($test, 0);
360 360
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject nnn, result should be >= 1 and is not');
361 361
 
362
-		$test="/dolibarr/htdocs/index.php/".chr('246')."abc";	// Add the char %F6 into the variable
363
-		$result=testSqlAndScriptInject($test, 2);
362
+		$test = "/dolibarr/htdocs/index.php/".chr('246')."abc"; // Add the char %F6 into the variable
363
+		$result = testSqlAndScriptInject($test, 2);
364 364
 		//print "test=".$test." result=".$result."\n";
365 365
 		$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject with a non valid UTF8 char');
366 366
 	}
@@ -372,11 +372,11 @@  discard block
 block discarded – undo
372 372
 	 */
373 373
 	public function testGETPOST()
374 374
 	{
375
-		global $conf,$user,$langs,$db;
376
-		$conf=$this->savconf;
377
-		$user=$this->savuser;
378
-		$langs=$this->savlangs;
379
-		$db=$this->savdb;
375
+		global $conf, $user, $langs, $db;
376
+		$conf = $this->savconf;
377
+		$user = $this->savuser;
378
+		$langs = $this->savlangs;
379
+		$db = $this->savdb;
380 380
 
381 381
 		// Force default mode
382 382
 		$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = 0;
@@ -384,206 +384,206 @@  discard block
 block discarded – undo
384 384
 		$conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = 0;
385 385
 		$conf->global->MAIN_DISALLOW_URL_INTO_DESCRIPTIONS = 0;
386 386
 
387
-		$_COOKIE["id"]=111;
388
-		$_POST["param0"]='A real string with <a href="rrr" title="aa&quot;bb">aaa</a> and " and \' and &amp; inside content';
389
-		$_GET["param1"]="222";
390
-		$_POST["param1"]="333";
391
-		$_GET["param2"]='a/b#e(pr)qq-rr\cc';
392
-		$_GET["param3"]='"&#110;a/b#e(pr)qq-rr\cc';    // Same than param2 + " and &#110;
393
-		$_GET["param4a"]='..&#47;../dir';
394
-		$_GET["param4b"]='..&#92;..\dirwindows';
395
-		$_GET["param5"]="a_1-b";
396
-		$_POST["param6"]="&quot;&gt;<svg o&#110;load='console.log(&quot;123&quot;)'&gt;";
397
-		$_POST["param6b"]='<<<../>../>../svg><<<../>../>../animate =alert(1)>abc';
398
-		$_GET["param7"]='"c:\this is a path~1\aaa&#110; &#x&#x31;&#x31;&#x30;;" abc<bad>def</bad>';
399
-		$_POST["param8a"]="Hacker<svg o&#110;load='console.log(&quot;123&quot;)'";	// html tag is not closed so it is not detected as html tag but is still harmfull
400
-		$_POST['param8b']='<img src=x onerror=alert(document.location) t=';		// this is html obfuscated by non closing tag
401
-		$_POST['param8c']='< with space after is ok';
402
-		$_POST['param8d']='<abc123 is html to clean';
403
-		$_POST['param8e']='<123abc is not html to clean';	// other similar case: '<2021-12-12'
404
-		$_POST['param8f']='abc<<svg <><<animate onbegin=alert(document.domain) a';
405
-		$_POST["param9"]='is_object($object) ? ($object->id < 10 ? round($object->id / 2, 2) : (2 * $user->id) * (int) substr($mysoc->zip, 1, 2)) : \'objnotdefined\'';
406
-		$_POST["param10"]='is_object($object) ? ($object->id < 10 ? round($object->id / 2, 2) : (2 * $user->id) * (int) substr($mysoc->zip, 1, 2)) : \'<abc>objnotdefined\'';
407
-		$_POST["param11"]=' Name <[email protected]> ';
408
-		$_POST["param12"]='<!DOCTYPE html><html>aaa</html>';
409
-		$_POST["param13"]='&#110; &#x6E; &gt; &lt; &quot; <a href=\"j&#x61;vascript:alert(document.domain)\">XSS</a>';
410
-		$_POST["param13b"]='&#110; &#x6E; &gt; &lt; &quot; <a href=\"j&#x61vascript:alert(document.domain)\">XSS</a>';
411
-		$_POST["param14"]="Text with ' encoded with the numeric html entity converted into text entity &#39; (like when submitted by CKEditor)";
412
-		$_POST["param15"]="<img onerror<=alert(document.domain)> src=>0xbeefed";
387
+		$_COOKIE["id"] = 111;
388
+		$_POST["param0"] = 'A real string with <a href="rrr" title="aa&quot;bb">aaa</a> and " and \' and &amp; inside content';
389
+		$_GET["param1"] = "222";
390
+		$_POST["param1"] = "333";
391
+		$_GET["param2"] = 'a/b#e(pr)qq-rr\cc';
392
+		$_GET["param3"] = '"&#110;a/b#e(pr)qq-rr\cc'; // Same than param2 + " and &#110;
393
+		$_GET["param4a"] = '..&#47;../dir';
394
+		$_GET["param4b"] = '..&#92;..\dirwindows';
395
+		$_GET["param5"] = "a_1-b";
396
+		$_POST["param6"] = "&quot;&gt;<svg o&#110;load='console.log(&quot;123&quot;)'&gt;";
397
+		$_POST["param6b"] = '<<<../>../>../svg><<<../>../>../animate =alert(1)>abc';
398
+		$_GET["param7"] = '"c:\this is a path~1\aaa&#110; &#x&#x31;&#x31;&#x30;;" abc<bad>def</bad>';
399
+		$_POST["param8a"] = "Hacker<svg o&#110;load='console.log(&quot;123&quot;)'"; // html tag is not closed so it is not detected as html tag but is still harmfull
400
+		$_POST['param8b'] = '<img src=x onerror=alert(document.location) t='; // this is html obfuscated by non closing tag
401
+		$_POST['param8c'] = '< with space after is ok';
402
+		$_POST['param8d'] = '<abc123 is html to clean';
403
+		$_POST['param8e'] = '<123abc is not html to clean'; // other similar case: '<2021-12-12'
404
+		$_POST['param8f'] = 'abc<<svg <><<animate onbegin=alert(document.domain) a';
405
+		$_POST["param9"] = 'is_object($object) ? ($object->id < 10 ? round($object->id / 2, 2) : (2 * $user->id) * (int) substr($mysoc->zip, 1, 2)) : \'objnotdefined\'';
406
+		$_POST["param10"] = 'is_object($object) ? ($object->id < 10 ? round($object->id / 2, 2) : (2 * $user->id) * (int) substr($mysoc->zip, 1, 2)) : \'<abc>objnotdefined\'';
407
+		$_POST["param11"] = ' Name <[email protected]> ';
408
+		$_POST["param12"] = '<!DOCTYPE html><html>aaa</html>';
409
+		$_POST["param13"] = '&#110; &#x6E; &gt; &lt; &quot; <a href=\"j&#x61;vascript:alert(document.domain)\">XSS</a>';
410
+		$_POST["param13b"] = '&#110; &#x6E; &gt; &lt; &quot; <a href=\"j&#x61vascript:alert(document.domain)\">XSS</a>';
411
+		$_POST["param14"] = "Text with ' encoded with the numeric html entity converted into text entity &#39; (like when submitted by CKEditor)";
412
+		$_POST["param15"] = "<img onerror<=alert(document.domain)> src=>0xbeefed";
413 413
 		//$_POST["param15b"]="<html><head><title>Example HTML</title></head><body><div><p>This is a paragraph.</div><ul><li>Item 1</li><li>Item 2</li></ol></body><html>";
414
-		$_POST["param16"]='<a style="z-index: 1000">abc</a>';
415
-		$_POST["param17"]='<span style="background-image: url(logout.php)">abc</span>';
416
-		$_POST["param18"]='<span style="background-image: url(...?...action=aaa)">abc</span>';
417
-		$_POST["param19"]='<a href="j&Tab;a&Tab;v&Tab;asc&NewLine;ri&Tab;pt:&lpar;alert(document.cookie)&rpar;">XSS</a>';
414
+		$_POST["param16"] = '<a style="z-index: 1000">abc</a>';
415
+		$_POST["param17"] = '<span style="background-image: url(logout.php)">abc</span>';
416
+		$_POST["param18"] = '<span style="background-image: url(...?...action=aaa)">abc</span>';
417
+		$_POST["param19"] = '<a href="j&Tab;a&Tab;v&Tab;asc&NewLine;ri&Tab;pt:&lpar;alert(document.cookie)&rpar;">XSS</a>';
418 418
 		//$_POST["param19"]='<a href="javascript:alert(document.cookie)">XSS</a>';
419 419
 
420 420
 
421 421
 
422
-		$result=GETPOST('id', 'int');              // Must return nothing
422
+		$result = GETPOST('id', 'int'); // Must return nothing
423 423
 		print __METHOD__." result=".$result."\n";
424 424
 		$this->assertEquals('', $result);
425 425
 
426
-		$result=GETPOST("param1", 'int');
426
+		$result = GETPOST("param1", 'int');
427 427
 		print __METHOD__." result=".$result."\n";
428 428
 		$this->assertEquals(222, $result, 'Test on param1 with no 3rd param');
429 429
 
430
-		$result=GETPOST("param1", 'int', 2);
430
+		$result = GETPOST("param1", 'int', 2);
431 431
 		print __METHOD__." result=".$result."\n";
432 432
 		$this->assertEquals(333, $result, 'Test on param1 with 3rd param = 2');
433 433
 
434 434
 		// Test with alpha
435 435
 
436
-		$result=GETPOST("param0", 'alpha');		// a simple format, so " completely removed
436
+		$result = GETPOST("param0", 'alpha'); // a simple format, so " completely removed
437 437
 		$resultexpected = 'A real string with aaa and and \' and & inside content';
438 438
 		print __METHOD__." result=".$result."\n";
439 439
 		$this->assertEquals($resultexpected, $result, 'Test on param0');
440 440
 
441
-		$result=GETPOST("param2", 'alpha');
441
+		$result = GETPOST("param2", 'alpha');
442 442
 		print __METHOD__." result=".$result."\n";
443 443
 		$this->assertEquals($result, $_GET["param2"], 'Test on param2');
444 444
 
445
-		$result=GETPOST("param3", 'alpha');  // Must return string sanitized from char "
445
+		$result = GETPOST("param3", 'alpha'); // Must return string sanitized from char "
446 446
 		print __METHOD__." result=".$result."\n";
447 447
 		$this->assertEquals($result, 'na/b#e(pr)qq-rr\cc', 'Test on param3');
448 448
 
449
-		$result=GETPOST("param4a", 'alpha');  // Must return string sanitized from ../
449
+		$result = GETPOST("param4a", 'alpha'); // Must return string sanitized from ../
450 450
 		print __METHOD__." result=".$result."\n";
451 451
 		$this->assertEquals($result, 'dir');
452 452
 
453
-		$result=GETPOST("param4b", 'alpha');  // Must return string sanitized from ../
453
+		$result = GETPOST("param4b", 'alpha'); // Must return string sanitized from ../
454 454
 		print __METHOD__." result=".$result."\n";
455 455
 		$this->assertEquals($result, 'dirwindows');
456 456
 
457 457
 		// Test with aZ09
458 458
 
459
-		$result=GETPOST("param1", 'aZ09');
459
+		$result = GETPOST("param1", 'aZ09');
460 460
 		print __METHOD__." result=".$result."\n";
461 461
 		$this->assertEquals($result, $_GET["param1"]);
462 462
 
463
-		$result=GETPOST("param2", 'aZ09');  // Must return '' as string contains car not in aZ09 definition
463
+		$result = GETPOST("param2", 'aZ09'); // Must return '' as string contains car not in aZ09 definition
464 464
 		print __METHOD__." result=".$result."\n";
465 465
 		$this->assertEquals($result, '');
466 466
 
467
-		$result=GETPOST("param3", 'aZ09');  // Must return '' as string contains car not in aZ09 definition
467
+		$result = GETPOST("param3", 'aZ09'); // Must return '' as string contains car not in aZ09 definition
468 468
 		print __METHOD__." result=".$result."\n";
469 469
 		$this->assertEquals($result, '');
470 470
 
471
-		$result=GETPOST("param4a", 'aZ09');  // Must return '' as string contains car not in aZ09 definition
471
+		$result = GETPOST("param4a", 'aZ09'); // Must return '' as string contains car not in aZ09 definition
472 472
 		print __METHOD__." result=".$result."\n";
473 473
 		$this->assertEquals('', $result);
474 474
 
475
-		$result=GETPOST("param4b", 'aZ09');  // Must return '' as string contains car not in aZ09 definition
475
+		$result = GETPOST("param4b", 'aZ09'); // Must return '' as string contains car not in aZ09 definition
476 476
 		print __METHOD__." result=".$result."\n";
477 477
 		$this->assertEquals('', $result);
478 478
 
479
-		$result=GETPOST("param5", 'aZ09');
479
+		$result = GETPOST("param5", 'aZ09');
480 480
 		print __METHOD__." result=".$result."\n";
481 481
 		$this->assertEquals($_GET["param5"], $result);
482 482
 
483 483
 		// Test with nohtml
484 484
 
485
-		$result=GETPOST("param6", 'nohtml');
485
+		$result = GETPOST("param6", 'nohtml');
486 486
 		print __METHOD__." result6=".$result."\n";
487 487
 		$this->assertEquals('">', $result);
488 488
 
489 489
 		// Test with alpha = alphanohtml. We must convert the html entities like &#110; and disable all entities
490 490
 
491
-		$result=GETPOST("param6", 'alphanohtml');
491
+		$result = GETPOST("param6", 'alphanohtml');
492 492
 		print __METHOD__." result=".$result."\n";
493 493
 		$this->assertEquals('>', $result);
494 494
 
495
-		$result=GETPOST("param6b", 'alphanohtml');
495
+		$result = GETPOST("param6b", 'alphanohtml');
496 496
 		print __METHOD__." result=".$result."\n";
497 497
 		$this->assertEquals('abc', $result);
498 498
 
499
-		$result=GETPOST("param8a", 'alphanohtml');
499
+		$result = GETPOST("param8a", 'alphanohtml');
500 500
 		print __METHOD__." result=".$result."\n";
501 501
 		$this->assertEquals("Hackersvg onload='console.log(123)'", $result);
502 502
 
503
-		$result=GETPOST("param8b", 'alphanohtml');
503
+		$result = GETPOST("param8b", 'alphanohtml');
504 504
 		print __METHOD__." result=".$result."\n";
505 505
 		$this->assertEquals('img src=x onerror=alert(document.location) t=', $result, 'Test a string with non closing html tag with alphanohtml');
506 506
 
507
-		$result=GETPOST("param8c", 'alphanohtml');
507
+		$result = GETPOST("param8c", 'alphanohtml');
508 508
 		print __METHOD__." result=".$result."\n";
509 509
 		$this->assertEquals($_POST['param8c'], $result, 'Test a string with non closing html tag with alphanohtml');
510 510
 
511
-		$result=GETPOST("param8d", 'alphanohtml');
511
+		$result = GETPOST("param8d", 'alphanohtml');
512 512
 		print __METHOD__." result=".$result."\n";
513 513
 		$this->assertEquals('abc123 is html to clean', $result, 'Test a string with non closing html tag with alphanohtml');
514 514
 
515
-		$result=GETPOST("param8e", 'alphanohtml');
515
+		$result = GETPOST("param8e", 'alphanohtml');
516 516
 		print __METHOD__." result=".$result."\n";
517 517
 		$this->assertEquals($_POST['param8e'], $result, 'Test a string with non closing html tag with alphanohtml');
518 518
 
519
-		$result=GETPOST("param8f", 'alphanohtml');
519
+		$result = GETPOST("param8f", 'alphanohtml');
520 520
 		print __METHOD__." result=".$result."\n";
521 521
 		$this->assertEquals('abcsvg animate onbegin=alert(document.domain) a', $result, 'Test a string with html tag open with several <');
522 522
 
523
-		$result=GETPOST("param9", 'alphanohtml');
523
+		$result = GETPOST("param9", 'alphanohtml');
524 524
 		print __METHOD__." result=".$result."\n";
525 525
 		$this->assertEquals($_POST["param9"], $result);
526 526
 
527
-		$result=GETPOST("param10", 'alphanohtml');
527
+		$result = GETPOST("param10", 'alphanohtml');
528 528
 		print __METHOD__." result=".$result."\n";
529 529
 		$this->assertEquals($_POST["param9"], $result, 'We should get param9 after processing param10');
530 530
 
531
-		$result=GETPOST("param11", 'alphanohtml');
531
+		$result = GETPOST("param11", 'alphanohtml');
532 532
 		print __METHOD__." result=".$result."\n";
533 533
 		$this->assertEquals("Name", $result, 'Test an email string with alphanohtml');
534 534
 
535
-		$result=GETPOST("param13", 'alphanohtml');
535
+		$result = GETPOST("param13", 'alphanohtml');
536 536
 		print __METHOD__." result=".$result."\n";
537 537
 		$this->assertEquals('n n > <  XSS', $result, 'Test that html entities are decoded with alpha');
538 538
 
539 539
 
540 540
 		// Test with alphawithlgt
541 541
 
542
-		$result=GETPOST("param11", 'alphawithlgt');
542
+		$result = GETPOST("param11", 'alphawithlgt');
543 543
 		print __METHOD__." result=".$result."\n";
544 544
 		$this->assertEquals(trim($_POST["param11"]), $result, 'Test an email string with alphawithlgt');
545 545
 
546 546
 
547 547
 		// Test with restricthtml: we must remove html open/close tag and content but not htmlentities (we can decode html entities for ascii chars like &#110;)
548 548
 
549
-		$result=GETPOST("param0", 'restricthtml');
549
+		$result = GETPOST("param0", 'restricthtml');
550 550
 		$resultexpected = 'A real string with <a href="rrr" title="aa&quot;bb">aaa</a> and " and \' and &amp; inside content';
551 551
 		print __METHOD__." result=".$result."\n";
552 552
 		$this->assertEquals($resultexpected, $result, 'Test on param0');
553 553
 
554
-		$result=GETPOST("param6", 'restricthtml');
554
+		$result = GETPOST("param6", 'restricthtml');
555 555
 		print __METHOD__." result for param6=".$result." - before=".$_POST["param6"]."\n";
556 556
 		$this->assertEquals('&quot;&gt;', $result);
557 557
 
558
-		$result=GETPOST("param7", 'restricthtml');
558
+		$result = GETPOST("param7", 'restricthtml');
559 559
 		print __METHOD__." result param7 = ".$result."\n";
560 560
 		$this->assertEquals('"c:\this is a path~1\aaan &#x;;;;" abcdef', $result);
561 561
 
562
-		$result=GETPOST("param8e", 'restricthtml');
562
+		$result = GETPOST("param8e", 'restricthtml');
563 563
 		print __METHOD__." result param8e = ".$result."\n";
564 564
 		$this->assertEquals('', $result);
565 565
 
566
-		$result=GETPOST("param12", 'restricthtml');
566
+		$result = GETPOST("param12", 'restricthtml');
567 567
 		print __METHOD__." result=".$result."\n";
568 568
 		$this->assertEquals(trim($_POST["param12"]), $result, 'Test a string with DOCTYPE and restricthtml');
569 569
 
570
-		$result=GETPOST("param13", 'restricthtml');
570
+		$result = GETPOST("param13", 'restricthtml');
571 571
 		print __METHOD__." result=".$result."\n";
572 572
 		$this->assertEquals('n n &gt; &lt; &quot; <a href=\"alert(document.domain)\">XSS</a>', $result, 'Test 13 that HTML entities are decoded with restricthtml, but only for common alpha chars');
573 573
 
574
-		$result=GETPOST("param13b", 'restricthtml');
574
+		$result = GETPOST("param13b", 'restricthtml');
575 575
 		print __METHOD__." result=".$result."\n";
576 576
 		$this->assertEquals('n n &gt; &lt; &quot; <a href=\"alert(document.domain)\">XSS</a>', $result, 'Test 13b that HTML entities are decoded with restricthtml, but only for common alpha chars');
577 577
 
578
-		$result=GETPOST("param14", 'restricthtml');
578
+		$result = GETPOST("param14", 'restricthtml');
579 579
 		print __METHOD__." result=".$result."\n";
580 580
 		$this->assertEquals("Text with ' encoded with the numeric html entity converted into text entity &#39; (like when submitted by CKEditor)", $result, 'Test 14');
581 581
 
582
-		$result=GETPOST("param15", 'restricthtml');		// param15 = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string
582
+		$result = GETPOST("param15", 'restricthtml'); // param15 = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string
583 583
 		print __METHOD__." result=".$result."\n";
584
-		$this->assertEquals("<img onerror=alert(document.domain) src=>0xbeefed", $result, 'Test 15');	// The GETPOST return a harmull string
584
+		$this->assertEquals("<img onerror=alert(document.domain) src=>0xbeefed", $result, 'Test 15'); // The GETPOST return a harmull string
585 585
 
586
-		$result=GETPOST("param19", 'restricthtml');
586
+		$result = GETPOST("param19", 'restricthtml');
587 587
 		print __METHOD__." result=".$result."\n";
588 588
 		$this->assertEquals('<a href="&lpar;alert(document.cookie)&rpar;">XSS</a>', $result, 'Test 19');
589 589
 
@@ -594,22 +594,22 @@  discard block
 block discarded – undo
594 594
 		$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = 0;
595 595
 
596 596
 		//$_POST["param0"] = 'A real string with <a href="rrr" title="aabb">aaa</a> and " inside content';
597
-		$result=GETPOST("param0", 'restricthtml');
597
+		$result = GETPOST("param0", 'restricthtml');
598 598
 		$resultexpected = 'A real string with <a href="rrr" title=\'aa"bb\'>aaa</a> and " and \' and &amp; inside content';
599 599
 		print __METHOD__." result for param0=".$result."\n";
600 600
 		$this->assertEquals($resultexpected, $result, 'Test on param0');
601 601
 
602
-		$result=GETPOST("param15", 'restricthtml');		// param15 = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string
602
+		$result = GETPOST("param15", 'restricthtml'); // param15 = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string
603 603
 		print __METHOD__." result for param15=".$result."\n";
604 604
 		//$this->assertEquals('InvalidHTMLStringCantBeCleaned', $result, 'Test 15b');   // With some PHP and libxml version, we got this result when parsing invalid HTML, but ...
605 605
 		//$this->assertEquals('<img onerror> src=&gt;0xbeefed', $result, 'Test 15b');	// ... on other PHP and libxml versions, we got a HTML that has been cleaned
606 606
 
607
-		$result=GETPOST("param6", 'restricthtml');		// param6 = "&quot;&gt;<svg o&#110;load='console.log(&quot;123&quot;)'&gt;"
607
+		$result = GETPOST("param6", 'restricthtml'); // param6 = "&quot;&gt;<svg o&#110;load='console.log(&quot;123&quot;)'&gt;"
608 608
 		print __METHOD__." result for param6=".$result." - before=".$_POST["param6"]."\n";
609 609
 		//$this->assertEquals('InvalidHTMLStringCantBeCleaned', $result, 'Test 15b');   // With some PHP and libxml version, we got this result when parsing invalid HTML, but ...
610 610
 		//$this->assertEquals('"&gt;', $result);										// ... on other PHP and libxml versions, we got a HTML that has been cleaned
611 611
 
612
-		$result=GETPOST("param7", 'restricthtml');		// param7 = "c:\this is a path~1\aaa&#110; &#x&#x31;&#x31;&#x30;;" abc<bad>def</bad>
612
+		$result = GETPOST("param7", 'restricthtml'); // param7 = "c:\this is a path~1\aaa&#110; &#x&#x31;&#x31;&#x30;;" abc<bad>def</bad>
613 613
 		print __METHOD__." result param7 = ".$result."\n";
614 614
 		//$this->assertEquals('InvalidHTMLStringCantBeCleaned', $result, 'Test 15b');   // With some PHP and libxml version, we got this result when parsing invalid HTML, but ...
615 615
 		//$this->assertEquals('"c:\this is a path~1\aaan 110;" abcdef', $result);		// ... on other PHP and libxml versions, we got a HTML that has been cleaned
@@ -621,19 +621,19 @@  discard block
 block discarded – undo
621 621
 			$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = 0;
622 622
 			$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = 1;
623 623
 
624
-			$result=GETPOST("param0", 'restricthtml');
624
+			$result = GETPOST("param0", 'restricthtml');
625 625
 			$resultexpected = 'A real string with <a href="rrr" title="aa&quot;bb">aaa</a> and " and \' and & inside content';
626 626
 			print __METHOD__." result for param0=".$result."\n";
627 627
 			$this->assertEquals($resultexpected, $result, 'Test on param0');
628 628
 
629
-			$result=GETPOST("param15", 'restricthtml');		// param15 = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string
629
+			$result = GETPOST("param15", 'restricthtml'); // param15 = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string
630 630
 			print __METHOD__." result=".$result."\n";
631 631
 
632
-			$result=GETPOST("param6", 'restricthtml');
632
+			$result = GETPOST("param6", 'restricthtml');
633 633
 			print __METHOD__." result for param6=".$result." - before=".$_POST["param6"]."\n";
634 634
 			$this->assertEquals('"&gt;', $result);
635 635
 
636
-			$result=GETPOST("param7", 'restricthtml');
636
+			$result = GETPOST("param7", 'restricthtml');
637 637
 			print __METHOD__." result param7 = ".$result."\n";
638 638
 			$this->assertEquals('"c:\this is a path~1\aaan &amp;#x110;" abcdef', $result);
639 639
 		}
@@ -645,19 +645,19 @@  discard block
 block discarded – undo
645 645
 			$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = 1;
646 646
 			$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = 1;
647 647
 
648
-			$result=GETPOST("param0", 'restricthtml');
648
+			$result = GETPOST("param0", 'restricthtml');
649 649
 			$resultexpected = 'A real string with <a href="rrr" title=\'aa"bb\'>aaa</a> and " and \' and & inside content';
650 650
 			print __METHOD__." result for param0=".$result."\n";
651 651
 			$this->assertEquals($resultexpected, $result, 'Test on param0');
652 652
 
653
-			$result=GETPOST("param15", 'restricthtml');		// param15 = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string
653
+			$result = GETPOST("param15", 'restricthtml'); // param15 = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string
654 654
 			print __METHOD__." result=".$result."\n";
655 655
 
656
-			$result=GETPOST("param6", 'restricthtml');
656
+			$result = GETPOST("param6", 'restricthtml');
657 657
 			print __METHOD__." result for param6=".$result." - before=".$_POST["param6"]."\n";
658 658
 			$this->assertEquals('"&gt;', $result);
659 659
 
660
-			$result=GETPOST("param7", 'restricthtml');
660
+			$result = GETPOST("param7", 'restricthtml');
661 661
 			print __METHOD__." result param7 = ".$result."\n";
662 662
 			$this->assertEquals('"c:\this is a path~1\aaan 110;" abcdef', $result);
663 663
 		}
@@ -669,19 +669,19 @@  discard block
 block discarded – undo
669 669
 		unset($conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY);
670 670
 		$conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = 1;
671 671
 
672
-		$result=GETPOST("param15", 'restricthtml');
672
+		$result = GETPOST("param15", 'restricthtml');
673 673
 		print __METHOD__." result=".$result."\n";
674 674
 		$this->assertEquals('<img src="">0xbeefed', $result, 'Test 15c');
675 675
 
676
-		$result=GETPOST('param16', 'restricthtml');
676
+		$result = GETPOST('param16', 'restricthtml');
677 677
 		print __METHOD__." result=".$result."\n";
678 678
 		$this->assertEquals('<a style=" 1000">abc</a>', $result, 'Test tag a with forbidden attribute z-index');
679 679
 
680
-		$result=GETPOST('param17', 'restricthtml');
680
+		$result = GETPOST('param17', 'restricthtml');
681 681
 		print __METHOD__." result=".$result."\n";
682 682
 		$this->assertEquals('<span style="background-image: url()">abc</span>', $result, 'Test anytag with a forbidden value for attribute');
683 683
 
684
-		$result=GETPOST('param18', 'restricthtml');
684
+		$result = GETPOST('param18', 'restricthtml');
685 685
 		print __METHOD__." result=".$result."\n";
686 686
 		$this->assertEquals('<span style="background-image: url(...?...aaa)">abc</span>', $result, 'Test anytag with a forbidden value for attribute');
687 687
 
@@ -690,75 +690,75 @@  discard block
 block discarded – undo
690 690
 
691 691
 		// Special test for GETPOST of backtopage, backtolist or backtourl parameter
692 692
 
693
-		$_POST["backtopage"]='//www.google.com';
694
-		$result=GETPOST("backtopage");
693
+		$_POST["backtopage"] = '//www.google.com';
694
+		$result = GETPOST("backtopage");
695 695
 		print __METHOD__." result=".$result."\n";
696 696
 		$this->assertEquals('www.google.com', $result, 'Test for backtopage param');
697 697
 
698
-		$_POST["backtopage"]='https:https://www.google.com';
699
-		$result=GETPOST("backtopage");
698
+		$_POST["backtopage"] = 'https:https://www.google.com';
699
+		$result = GETPOST("backtopage");
700 700
 		print __METHOD__." result=".$result."\n";
701 701
 		$this->assertEquals('www.google.com', $result, 'Test for backtopage param');
702 702
 
703
-		$_POST["backtolist"]='::HTTPS://www.google.com';
704
-		$result=GETPOST("backtolist");
703
+		$_POST["backtolist"] = '::HTTPS://www.google.com';
704
+		$result = GETPOST("backtolist");
705 705
 		print __METHOD__." result=".$result."\n";
706 706
 		$this->assertEquals('www.google.com', $result, 'Test for backtopage param');
707 707
 
708
-		$_POST["backtopage"]='http:www.google.com';
709
-		$result=GETPOST("backtopage");
708
+		$_POST["backtopage"] = 'http:www.google.com';
709
+		$result = GETPOST("backtopage");
710 710
 		print __METHOD__." result=".$result."\n";
711 711
 		$this->assertEquals('httpwww.google.com', $result, 'Test for backtopage param');
712 712
 
713
-		$_POST["backtopage"]='/mydir/mypage.php?aa=a%10a';
714
-		$result=GETPOST("backtopage");
713
+		$_POST["backtopage"] = '/mydir/mypage.php?aa=a%10a';
714
+		$result = GETPOST("backtopage");
715 715
 		print __METHOD__." result=".$result."\n";
716 716
 		$this->assertEquals('/mydir/mypage.php?aa=a%10a', $result, 'Test for backtopage param');
717 717
 
718
-		$_POST["backtopage"]='javascripT&javascript#javascriptxjavascript3a alert(1)';
719
-		$result=GETPOST("backtopage");
718
+		$_POST["backtopage"] = 'javascripT&javascript#javascriptxjavascript3a alert(1)';
719
+		$result = GETPOST("backtopage");
720 720
 		print __METHOD__." result=".$result."\n";
721 721
 		$this->assertEquals('x3aalert(1)', $result, 'Test for backtopage param');
722 722
 
723 723
 
724 724
 		$conf->global->MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT = 3;
725
-		$_POST["pagecontentwithlinks"]='<img src="aaa"><img src="bbb"><img src="/ccc"><span style="background: url(/ddd)"></span>';
726
-		$result=GETPOST("pagecontentwithlinks", 'restricthtml');
725
+		$_POST["pagecontentwithlinks"] = '<img src="aaa"><img src="bbb"><img src="/ccc"><span style="background: url(/ddd)"></span>';
726
+		$result = GETPOST("pagecontentwithlinks", 'restricthtml');
727 727
 		print __METHOD__." result=".$result."\n";
728 728
 		$this->assertEquals('ErrorTooManyLinksIntoHTMLString', $result, 'Test on limit on GETPOST fails');
729 729
 
730 730
 		// Test that img src="data:..." is excluded from the count of external links
731 731
 		$conf->global->MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT = 3;
732
-		$_POST["pagecontentwithlinks"]='<img src="data:abc"><img src="bbb"><img src="/ccc"><span style="background: url(/ddd)"></span>';
733
-		$result=GETPOST("pagecontentwithlinks", 'restricthtml');
732
+		$_POST["pagecontentwithlinks"] = '<img src="data:abc"><img src="bbb"><img src="/ccc"><span style="background: url(/ddd)"></span>';
733
+		$result = GETPOST("pagecontentwithlinks", 'restricthtml');
734 734
 		print __METHOD__." result=".$result."\n";
735 735
 		$this->assertEquals('<img src="data:abc"><img src="bbb"><img src="/ccc"><span style="background: url(/ddd)"></span>', $result, 'Test on limit on GETPOST fails');
736 736
 
737 737
 		$conf->global->MAIN_DISALLOW_URL_INTO_DESCRIPTIONS = 2;
738 738
 
739 739
 		// Test that no links is allowed
740
-		$_POST["pagecontentwithlinks"]='<img src="data:abc"><img src="bbb"><img src="/ccc"><span style="background: url(/ddd)"></span>';
741
-		$result=GETPOST("pagecontentwithlinks", 'restricthtml');
740
+		$_POST["pagecontentwithlinks"] = '<img src="data:abc"><img src="bbb"><img src="/ccc"><span style="background: url(/ddd)"></span>';
741
+		$result = GETPOST("pagecontentwithlinks", 'restricthtml');
742 742
 		print __METHOD__." result=".$result."\n";
743 743
 		$this->assertEquals('ErrorHTMLLinksNotAllowed', $result, 'Test on limit on MAIN_DISALLOW_URL_INTO_DESCRIPTIONS = 2 (no links allowed)');
744 744
 
745 745
 		$conf->global->MAIN_DISALLOW_URL_INTO_DESCRIPTIONS = 1;
746 746
 
747 747
 		// Test that links on wrapper or local url are allowed
748
-		$_POST["pagecontentwithnowrapperlinks"]='<img src="data:abc"><img src="bbb"><img src="/ccc"><span style="background: url(/ddd)"></span>';
749
-		$result=GETPOST("pagecontentwithnowrapperlinks", 'restricthtml');
748
+		$_POST["pagecontentwithnowrapperlinks"] = '<img src="data:abc"><img src="bbb"><img src="/ccc"><span style="background: url(/ddd)"></span>';
749
+		$result = GETPOST("pagecontentwithnowrapperlinks", 'restricthtml');
750 750
 		print __METHOD__." result=".$result."\n";
751 751
 		$this->assertEquals('<img src="data:abc"><img src="bbb"><img src="/ccc"><span style="background: url(/ddd)"></span>', $result, 'Test on MAIN_DISALLOW_URL_INTO_DESCRIPTIONS = 1 (links on data or relative links ar allowed)');
752 752
 
753 753
 		// Test that links not on wrapper and not data are disallowed
754
-		$_POST["pagecontentwithnowrapperlinks"]='<img src="https://aaa">';
755
-		$result=GETPOST("pagecontentwithnowrapperlinks", 'restricthtml');
754
+		$_POST["pagecontentwithnowrapperlinks"] = '<img src="https://aaa">';
755
+		$result = GETPOST("pagecontentwithnowrapperlinks", 'restricthtml');
756 756
 		print __METHOD__." result=".$result."\n";
757 757
 		$this->assertEquals('ErrorHTMLExternalLinksNotAllowed', $result, 'Test on MAIN_DISALLOW_URL_INTO_DESCRIPTIONS = 1 (no links to http allowed)');
758 758
 
759 759
 		// Test that links not on wrapper and not data are disallowed
760
-		$_POST["pagecontentwithnowrapperlinks"]='<span style="background: url(http://ddd)"></span>';
761
-		$result=GETPOST("pagecontentwithnowrapperlinks", 'restricthtml');
760
+		$_POST["pagecontentwithnowrapperlinks"] = '<span style="background: url(http://ddd)"></span>';
761
+		$result = GETPOST("pagecontentwithnowrapperlinks", 'restricthtml');
762 762
 		print __METHOD__." result=".$result."\n";
763 763
 		$this->assertEquals('ErrorHTMLExternalLinksNotAllowed', $result, 'Test on MAIN_DISALLOW_URL_INTO_DESCRIPTIONS = 1 (no links to http allowed)');
764 764
 
@@ -772,15 +772,15 @@  discard block
 block discarded – undo
772 772
 	 */
773 773
 	public function testEncodeDecode()
774 774
 	{
775
-		$stringtotest="This is a string to test encode/decode. This is a string to test encode/decode. This is a string to test encode/decode.";
775
+		$stringtotest = "This is a string to test encode/decode. This is a string to test encode/decode. This is a string to test encode/decode.";
776 776
 
777
-		$encodedstring=dol_encode($stringtotest);
778
-		$decodedstring=dol_decode($encodedstring);
777
+		$encodedstring = dol_encode($stringtotest);
778
+		$decodedstring = dol_decode($encodedstring);
779 779
 		print __METHOD__." encodedstring=".$encodedstring." ".base64_encode($stringtotest)."\n";
780 780
 		$this->assertEquals($stringtotest, $decodedstring, 'Use dol_encode/decode with no parameter');
781 781
 
782
-		$encodedstring=dol_encode($stringtotest, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');
783
-		$decodedstring=dol_decode($encodedstring, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');
782
+		$encodedstring = dol_encode($stringtotest, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');
783
+		$decodedstring = dol_decode($encodedstring, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');
784 784
 		print __METHOD__." encodedstring=".$encodedstring." ".base64_encode($stringtotest)."\n";
785 785
 		$this->assertEquals($stringtotest, $decodedstring, 'Use dol_encode/decode with a key parameter');
786 786
 
@@ -799,7 +799,7 @@  discard block
 block discarded – undo
799 799
 		$this->assertEquals('a &colon; b " c \' d &apos; e é', $decodedstring, 'Function did not sanitize correclty');
800 800
 
801 801
 		$stringtotest = 'a &colon; b &quot; c &#039; d &apos; e &eacute;';
802
-		$decodedstring = dol_html_entity_decode($stringtotest, ENT_QUOTES|ENT_HTML5);
802
+		$decodedstring = dol_html_entity_decode($stringtotest, ENT_QUOTES | ENT_HTML5);
803 803
 		$this->assertEquals('a : b " c \' d \' e é', $decodedstring, 'Function did not sanitize correclty');
804 804
 
805 805
 		return 0;
@@ -863,21 +863,21 @@  discard block
 block discarded – undo
863 863
 	{
864 864
 		global $conf;
865 865
 
866
-		$genpass1=getRandomPassword(true);				// Should be a string return by dol_hash (if no option set, will be md5)
866
+		$genpass1 = getRandomPassword(true); // Should be a string return by dol_hash (if no option set, will be md5)
867 867
 		print __METHOD__." genpass1=".$genpass1."\n";
868 868
 		$this->assertEquals(strlen($genpass1), 32);
869 869
 
870
-		$genpass1=getRandomPassword(true, array('I'));	// Should be a string return by dol_hash (if no option set, will be md5)
870
+		$genpass1 = getRandomPassword(true, array('I')); // Should be a string return by dol_hash (if no option set, will be md5)
871 871
 		print __METHOD__." genpass1=".$genpass1."\n";
872 872
 		$this->assertEquals(strlen($genpass1), 32);
873 873
 
874
-		$conf->global->USER_PASSWORD_GENERATED='None';
875
-		$genpass2=getRandomPassword(false);				// Should return an empty string
874
+		$conf->global->USER_PASSWORD_GENERATED = 'None';
875
+		$genpass2 = getRandomPassword(false); // Should return an empty string
876 876
 		print __METHOD__." genpass2=".$genpass2."\n";
877 877
 		$this->assertEquals($genpass2, '');
878 878
 
879
-		$conf->global->USER_PASSWORD_GENERATED='Standard';
880
-		$genpass3=getRandomPassword(false);				// Should return a password of 12 chars
879
+		$conf->global->USER_PASSWORD_GENERATED = 'Standard';
880
+		$genpass3 = getRandomPassword(false); // Should return a password of 12 chars
881 881
 		print __METHOD__." genpass3=".$genpass3."\n";
882 882
 		$this->assertEquals(strlen($genpass3), 12);
883 883
 
@@ -891,16 +891,16 @@  discard block
 block discarded – undo
891 891
 	 */
892 892
 	public function testRestrictedArea()
893 893
 	{
894
-		global $conf,$user,$langs,$db;
895
-		$conf=$this->savconf;
896
-		$user=$this->savuser;
897
-		$langs=$this->savlangs;
898
-		$db=$this->savdb;
894
+		global $conf, $user, $langs, $db;
895
+		$conf = $this->savconf;
896
+		$user = $this->savuser;
897
+		$langs = $this->savlangs;
898
+		$db = $this->savdb;
899 899
 
900 900
 		//$dummyuser=new User($db);
901 901
 		//$result=restrictedArea($dummyuser,'societe');
902 902
 
903
-		$result=restrictedArea($user, 'societe');
903
+		$result = restrictedArea($user, 'societe');
904 904
 		$this->assertEquals(1, $result);
905 905
 	}
906 906
 
@@ -918,42 +918,42 @@  discard block
 block discarded – undo
918 918
 		$url = 'ftp://mydomain.com';
919 919
 		$tmp = getURLContent($url);
920 920
 		print __METHOD__." url=".$url."\n";
921
-		$this->assertRegExp("/not supported/", $tmp['curl_error_msg'], "Should disable ftp connection");	// Test error if return does not contains 'not supported'
921
+		$this->assertRegExp("/not supported/", $tmp['curl_error_msg'], "Should disable ftp connection"); // Test error if return does not contains 'not supported'
922 922
 
923
-		$url = 'https://www.dolibarr.fr';	// This is a redirect 301 page
924
-		$tmp = getURLContent($url, 'GET', '', 0);	// We do NOT follow
923
+		$url = 'https://www.dolibarr.fr'; // This is a redirect 301 page
924
+		$tmp = getURLContent($url, 'GET', '', 0); // We do NOT follow
925 925
 		print __METHOD__." url=".$url."\n";
926 926
 		$this->assertEquals(301, (empty($tmp['http_code']) ? 0 : $tmp['http_code']), 'Should GET url 301 response');
927 927
 
928
-		$url = 'https://www.dolibarr.fr';	// This is a redirect 301 page
929
-		$tmp = getURLContent($url);		// We DO follow a page with return 300 so result should be 200
928
+		$url = 'https://www.dolibarr.fr'; // This is a redirect 301 page
929
+		$tmp = getURLContent($url); // We DO follow a page with return 300 so result should be 200
930 930
 		print __METHOD__." url=".$url."\n";
931 931
 		$this->assertEquals(200, (empty($tmp['http_code']) ? 0 : $tmp['http_code']), 'Should GET url 301 with a follow -> 200 but we get '.(empty($tmp['http_code']) ? 0 : $tmp['http_code']));
932 932
 
933 933
 		$url = 'http://localhost';
934
-		$tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0);		// Only external URL
934
+		$tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL
935 935
 		print __METHOD__." url=".$url."\n";
936
-		$this->assertEquals(400, (empty($tmp['http_code']) ? 0 : $tmp['http_code']), 'Should GET url to '.$url.' that resolves to a local URL');	// Test we receive an error because localtest.me is not an external URL
936
+		$this->assertEquals(400, (empty($tmp['http_code']) ? 0 : $tmp['http_code']), 'Should GET url to '.$url.' that resolves to a local URL'); // Test we receive an error because localtest.me is not an external URL
937 937
 
938 938
 		$url = 'http://127.0.0.1';
939
-		$tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0);		// Only external URL
939
+		$tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL
940 940
 		print __METHOD__." url=".$url."\n";
941
-		$this->assertEquals(400, (empty($tmp['http_code']) ? 0 : $tmp['http_code']), 'Should GET url to '.$url.' that is a local URL');	// Test we receive an error because 127.0.0.1 is not an external URL
941
+		$this->assertEquals(400, (empty($tmp['http_code']) ? 0 : $tmp['http_code']), 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because 127.0.0.1 is not an external URL
942 942
 
943 943
 		$url = 'http://127.0.2.1';
944
-		$tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0);		// Only external URL
944
+		$tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL
945 945
 		print __METHOD__." url=".$url."\n";
946
-		$this->assertEquals(400, (empty($tmp['http_code']) ? 0 : $tmp['http_code']), 'Should GET url to '.$url.' that is a local URL');	// Test we receive an error because 127.0.2.1 is not an external URL
946
+		$this->assertEquals(400, (empty($tmp['http_code']) ? 0 : $tmp['http_code']), 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because 127.0.2.1 is not an external URL
947 947
 
948 948
 		$url = 'https://169.254.0.1';
949
-		$tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0);		// Only external URL
949
+		$tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL
950 950
 		print __METHOD__." url=".$url."\n";
951
-		$this->assertEquals(400, (empty($tmp['http_code']) ? 0 : $tmp['http_code']), 'Should GET url to '.$url.' that is a local URL');	// Test we receive an error because 169.254.0.1 is not an external URL
951
+		$this->assertEquals(400, (empty($tmp['http_code']) ? 0 : $tmp['http_code']), 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because 169.254.0.1 is not an external URL
952 952
 
953 953
 		$url = 'http://[::1]';
954
-		$tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0);		// Only external URL
954
+		$tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL
955 955
 		print __METHOD__." url=".$url."\n";
956
-		$this->assertEquals(400, (empty($tmp['http_code']) ? 0 : $tmp['http_code']), 'Should GET url to '.$url.' that is a local URL');	// Test we receive an error because [::1] is not an external URL
956
+		$this->assertEquals(400, (empty($tmp['http_code']) ? 0 : $tmp['http_code']), 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because [::1] is not an external URL
957 957
 
958 958
 		/*$url = 'localtest.me';
959 959
 		 $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0);		// Only external URL
@@ -962,9 +962,9 @@  discard block
 block discarded – undo
962 962
 		 */
963 963
 
964 964
 		$url = 'http://192.0.0.192';
965
-		$tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0);		// Only external URL but on an IP in blacklist
965
+		$tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL but on an IP in blacklist
966 966
 		print __METHOD__." url=".$url." tmp['http_code'] = ".(empty($tmp['http_code']) ? 0 : $tmp['http_code'])."\n";
967
-		$this->assertEquals(400, (empty($tmp['http_code']) ? 0 : $tmp['http_code']), 'Access should be refused and was not');	// Test we receive an error because ip is in blacklist
967
+		$this->assertEquals(400, (empty($tmp['http_code']) ? 0 : $tmp['http_code']), 'Access should be refused and was not'); // Test we receive an error because ip is in blacklist
968 968
 
969 969
 		return 0;
970 970
 	}
@@ -976,22 +976,22 @@  discard block
 block discarded – undo
976 976
 	 */
977 977
 	public function testDolSanitizeUrl()
978 978
 	{
979
-		global $conf,$user,$langs,$db;
980
-		$conf=$this->savconf;
981
-		$user=$this->savuser;
982
-		$langs=$this->savlangs;
983
-		$db=$this->savdb;
979
+		global $conf, $user, $langs, $db;
980
+		$conf = $this->savconf;
981
+		$user = $this->savuser;
982
+		$langs = $this->savlangs;
983
+		$db = $this->savdb;
984 984
 
985 985
 		$test = 'javascripT&javascript#x3a alert(1)';
986
-		$result=dol_sanitizeUrl($test);
986
+		$result = dol_sanitizeUrl($test);
987 987
 		$this->assertEquals('x3a alert(1)', $result, 'Test on dol_sanitizeUrl A');
988 988
 
989 989
 		$test = 'javajavascriptscript&cjavascriptolon;alert(1)';
990
-		$result=dol_sanitizeUrl($test);
990
+		$result = dol_sanitizeUrl($test);
991 991
 		$this->assertEquals('alert(1)', $result, 'Test on dol_sanitizeUrl B');
992 992
 
993 993
 		$test = '/javas:cript/google.com';
994
-		$result=dol_sanitizeUrl($test);
994
+		$result = dol_sanitizeUrl($test);
995 995
 		$this->assertEquals('google.com', $result, 'Test on dol_sanitizeUrl C');
996 996
 	}
997 997
 
@@ -1002,26 +1002,26 @@  discard block
 block discarded – undo
1002 1002
 	 */
1003 1003
 	public function testDolSanitizeEmail()
1004 1004
 	{
1005
-		global $conf,$user,$langs,$db;
1006
-		$conf=$this->savconf;
1007
-		$user=$this->savuser;
1008
-		$langs=$this->savlangs;
1009
-		$db=$this->savdb;
1005
+		global $conf, $user, $langs, $db;
1006
+		$conf = $this->savconf;
1007
+		$user = $this->savuser;
1008
+		$langs = $this->savlangs;
1009
+		$db = $this->savdb;
1010 1010
 
1011 1011
 		$test = '[email protected] <My name>, [email protected] <Another name>';
1012
-		$result=dol_sanitizeEmail($test);
1012
+		$result = dol_sanitizeEmail($test);
1013 1013
 		$this->assertEquals($test, $result, 'Test on dol_sanitizeEmail A');
1014 1014
 
1015 1015
 		$test = "[email protected] <My name>,\[email protected] <Another name>";
1016
-		$result=dol_sanitizeEmail($test);
1016
+		$result = dol_sanitizeEmail($test);
1017 1017
 		$this->assertEquals('[email protected] <My name>,[email protected] <Another name>', $result, 'Test on dol_sanitizeEmail B');
1018 1018
 
1019 1019
 		$test = '[email protected] <My name>,\[email protected] <Another name>';
1020
-		$result=dol_sanitizeEmail($test);
1020
+		$result = dol_sanitizeEmail($test);
1021 1021
 		$this->assertEquals('[email protected] <My name>,[email protected] <Another name>', $result, 'Test on dol_sanitizeEmail C');
1022 1022
 
1023 1023
 		$test = '[email protected] <My name>, "bcc:bbb"@mycompany.com <Another name>';
1024
-		$result=dol_sanitizeEmail($test);
1024
+		$result = dol_sanitizeEmail($test);
1025 1025
 		$this->assertEquals('[email protected] <My name>, [email protected] <Another name>', $result, 'Test on dol_sanitizeEmail D');
1026 1026
 	}
1027 1027
 
@@ -1032,19 +1032,19 @@  discard block
 block discarded – undo
1032 1032
 	 */
1033 1033
 	public function testDolSanitizeFileName()
1034 1034
 	{
1035
-		global $conf,$user,$langs,$db;
1036
-		$conf=$this->savconf;
1037
-		$user=$this->savuser;
1038
-		$langs=$this->savlangs;
1039
-		$db=$this->savdb;
1035
+		global $conf, $user, $langs, $db;
1036
+		$conf = $this->savconf;
1037
+		$user = $this->savuser;
1038
+		$langs = $this->savlangs;
1039
+		$db = $this->savdb;
1040 1040
 
1041 1041
 		//$dummyuser=new User($db);
1042 1042
 		//$result=restrictedArea($dummyuser,'societe');
1043 1043
 
1044
-		$result=dol_sanitizeFileName('bad file | evilaction');
1044
+		$result = dol_sanitizeFileName('bad file | evilaction');
1045 1045
 		$this->assertEquals('bad file _ evilaction', $result);
1046 1046
 
1047
-		$result=dol_sanitizeFileName('bad file -evilparam --evilparam ---evilparam ----evilparam');
1047
+		$result = dol_sanitizeFileName('bad file -evilparam --evilparam ---evilparam ----evilparam');
1048 1048
 		$this->assertEquals('bad file _evilparam _evilparam _evilparam _evilparam', $result);
1049 1049
 	}
1050 1050
 
@@ -1055,17 +1055,17 @@  discard block
 block discarded – undo
1055 1055
 	 */
1056 1056
 	public function testDolEval()
1057 1057
 	{
1058
-		global $conf,$user,$langs,$db;
1059
-		$conf=$this->savconf;
1060
-		$user=$this->savuser;
1061
-		$langs=$this->savlangs;
1062
-		$db=$this->savdb;
1058
+		global $conf, $user, $langs, $db;
1059
+		$conf = $this->savconf;
1060
+		$user = $this->savuser;
1061
+		$langs = $this->savlangs;
1062
+		$db = $this->savdb;
1063 1063
 
1064
-		$result=dol_eval('1==1', 1, 0);
1064
+		$result = dol_eval('1==1', 1, 0);
1065 1065
 		print "result1 = ".$result."\n";
1066 1066
 		$this->assertTrue($result);
1067 1067
 
1068
-		$result=dol_eval('1==2', 1, 0);
1068
+		$result = dol_eval('1==2', 1, 0);
1069 1069
 		print "result2 = ".$result."\n";
1070 1070
 		$this->assertFalse($result);
1071 1071
 
@@ -1073,7 +1073,7 @@  discard block
 block discarded – undo
1073 1073
 		include_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
1074 1074
 
1075 1075
 		$s = '(($reloadedobj = new Task($db)) && ($reloadedobj->fetchNoCompute($object->id) > 0) && ($secondloadedobj = new Project($db)) && ($secondloadedobj->fetchNoCompute($reloadedobj->fk_project) > 0)) ? $secondloadedobj->ref : "Parent project not found"';
1076
-		$result=dol_eval($s, 1, 1, '2');
1076
+		$result = dol_eval($s, 1, 1, '2');
1077 1077
 		print "result3 = ".$result."\n";
1078 1078
 		$this->assertEquals('Parent project not found', $result);
1079 1079
 
@@ -1114,48 +1114,48 @@  discard block
 block discarded – undo
1114 1114
 		print "result12 = ".$result."\n";
1115 1115
 		$this->assertStringContainsString('Bad string syntax to evaluate', $result);
1116 1116
 
1117
-		$result=dol_eval("90402.38+267678+0", 1, 1, 1);
1117
+		$result = dol_eval("90402.38+267678+0", 1, 1, 1);
1118 1118
 		print "result13 = ".$result."\n";
1119 1119
 		$this->assertEquals('358080.38', $result);
1120 1120
 
1121
-		global $leftmenu;	// Used into strings to eval
1121
+		global $leftmenu; // Used into strings to eval
1122 1122
 
1123 1123
 		$leftmenu = 'AAA';
1124
-		$result=dol_eval('$conf->currency && preg_match(\'/^(AAA|BBB)/\',$leftmenu)', 1, 1, '1');
1124
+		$result = dol_eval('$conf->currency && preg_match(\'/^(AAA|BBB)/\',$leftmenu)', 1, 1, '1');
1125 1125
 		print "result = ".$result."\n";
1126 1126
 		$this->assertTrue($result);
1127 1127
 
1128 1128
 		// Same with a value that does not match
1129 1129
 		$leftmenu = 'XXX';
1130
-		$result=dol_eval('$conf->currency && preg_match(\'/^(AAA|BBB)/\',$leftmenu)', 1, 1, '1');
1130
+		$result = dol_eval('$conf->currency && preg_match(\'/^(AAA|BBB)/\',$leftmenu)', 1, 1, '1');
1131 1131
 		print "result14 = ".$result."\n";
1132 1132
 		$this->assertFalse($result);
1133 1133
 
1134 1134
 		$leftmenu = 'AAA';
1135
-		$result=dol_eval('$conf->currency && isStringVarMatching(\'leftmenu\', \'(AAA|BBB)\')', 1, 1, '1');
1135
+		$result = dol_eval('$conf->currency && isStringVarMatching(\'leftmenu\', \'(AAA|BBB)\')', 1, 1, '1');
1136 1136
 		print "result15 = ".$result."\n";
1137 1137
 		$this->assertTrue($result);
1138 1138
 
1139 1139
 		$leftmenu = 'XXX';
1140
-		$result=dol_eval('$conf->currency && isStringVarMatching(\'leftmenu\', \'(AAA|BBB)\')', 1, 1, '1');
1140
+		$result = dol_eval('$conf->currency && isStringVarMatching(\'leftmenu\', \'(AAA|BBB)\')', 1, 1, '1');
1141 1141
 		print "result16 = ".$result."\n";
1142 1142
 		$this->assertFalse($result);
1143 1143
 
1144 1144
 		$string = '(isModEnabled("agenda") || isModEnabled("resource")) && getDolGlobalInt("MAIN_FEATURES_LEVEL") >= 0 && preg_match(\'/^(admintools|all|XXX)/\', $leftmenu)';
1145
-		$result=dol_eval($string, 1, 1, '1');
1145
+		$result = dol_eval($string, 1, 1, '1');
1146 1146
 		print "result17 = ".$result."\n";
1147 1147
 		$this->assertTrue($result);
1148 1148
 
1149
-		$result=dol_eval('1 && getDolGlobalInt("doesnotexist1") && $conf->global->MAIN_FEATURES_LEVEL', 1, 0);	// Should return false and not a 'Bad string syntax to evaluate ...'
1149
+		$result = dol_eval('1 && getDolGlobalInt("doesnotexist1") && $conf->global->MAIN_FEATURES_LEVEL', 1, 0); // Should return false and not a 'Bad string syntax to evaluate ...'
1150 1150
 		print "result18 = ".$result."\n";
1151 1151
 		$this->assertFalse($result);
1152 1152
 
1153
-		$a='ab';
1153
+		$a = 'ab';
1154 1154
 		$result = (string) dol_eval("(\$a.'s')", 1, 0);
1155 1155
 		print "result19 = ".$result."\n";
1156 1156
 		$this->assertStringContainsString('Bad string syntax to evaluate', $result);
1157 1157
 
1158
-		$leftmenu='abs';
1158
+		$leftmenu = 'abs';
1159 1159
 		$result = (string) dol_eval('$leftmenu(-5)', 1, 0);
1160 1160
 		print "result20 = ".$result."\n";
1161 1161
 		$this->assertStringContainsString('Bad string syntax to evaluate', $result);
@@ -1173,12 +1173,12 @@  discard block
 block discarded – undo
1173 1173
 		global $conf;
1174 1174
 
1175 1175
 		// Set options for cleaning data
1176
-		$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = 0;	// disabled, does not work on HTML5 and some libxml versions
1176
+		$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = 0; // disabled, does not work on HTML5 and some libxml versions
1177 1177
 		// Enabled option MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY if possible
1178 1178
 		if (extension_loaded('tidy') && class_exists("tidy")) {
1179 1179
 			$conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = 1;
1180 1180
 		}
1181
-		$conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = 0;	// disabled, does not work on HTML5 and some libxml versions
1181
+		$conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = 0; // disabled, does not work on HTML5 and some libxml versions
1182 1182
 
1183 1183
 
1184 1184
 
@@ -1191,7 +1191,7 @@  discard block
 block discarded – undo
1191 1191
 		//$result = dol_escape_htmltag(dol_htmlwithnojs(dol_string_onlythesehtmltags(dol_htmlentitiesbr($stringtotest), 1, 1, 1, 0)), 1, 1, 'common', 0, 1);
1192 1192
 		$result = dolPrintHTML($stringtotest);
1193 1193
 		print __METHOD__." result=".$result."\n";
1194
-		$this->assertEquals($stringfixed, $result, 'Error');    // Expected '' because should failed because login 'auto' does not exists
1194
+		$this->assertEquals($stringfixed, $result, 'Error'); // Expected '' because should failed because login 'auto' does not exists
1195 1195
 
1196 1196
 
1197 1197
 		// For a string that is already HTML (contains HTML tags) with special tags but badly formatted
@@ -1240,24 +1240,24 @@  discard block
 block discarded – undo
1240 1240
 	 */
1241 1241
 	public function testCheckLoginPassEntity()
1242 1242
 	{
1243
-		$login=checkLoginPassEntity('loginbidon', 'passwordbidon', 1, array('dolibarr'));
1243
+		$login = checkLoginPassEntity('loginbidon', 'passwordbidon', 1, array('dolibarr'));
1244 1244
 		print __METHOD__." login=".$login."\n";
1245 1245
 		$this->assertEquals($login, '');
1246 1246
 
1247
-		$login=checkLoginPassEntity('admin', 'passwordbidon', 1, array('dolibarr'));
1247
+		$login = checkLoginPassEntity('admin', 'passwordbidon', 1, array('dolibarr'));
1248 1248
 		print __METHOD__." login=".$login."\n";
1249 1249
 		$this->assertEquals($login, '');
1250 1250
 
1251
-		$login=checkLoginPassEntity('admin', 'admin', 1, array('dolibarr'));            // Should works because admin/admin exists
1251
+		$login = checkLoginPassEntity('admin', 'admin', 1, array('dolibarr')); // Should works because admin/admin exists
1252 1252
 		print __METHOD__." login=".$login."\n";
1253 1253
 		$this->assertEquals($login, 'admin', 'The test to check if pass of user "admin" is "admin" has failed');
1254 1254
 
1255
-		$login=checkLoginPassEntity('admin', 'admin', 1, array('http','dolibarr'));    // Should work because of second authentication method
1255
+		$login = checkLoginPassEntity('admin', 'admin', 1, array('http', 'dolibarr')); // Should work because of second authentication method
1256 1256
 		print __METHOD__." login=".$login."\n";
1257 1257
 		$this->assertEquals($login, 'admin');
1258 1258
 
1259
-		$login=checkLoginPassEntity('admin', 'admin', 1, array('forceuser'));
1259
+		$login = checkLoginPassEntity('admin', 'admin', 1, array('forceuser'));
1260 1260
 		print __METHOD__." login=".$login."\n";
1261
-		$this->assertEquals('', $login, 'Error');    // Expected '' because should failed because login 'auto' does not exists
1261
+		$this->assertEquals('', $login, 'Error'); // Expected '' because should failed because login 'auto' does not exists
1262 1262
 	}
1263 1263
 }
Please login to merge, or discard this patch.