Ticket #1431 (closed defect: fixed)

Opened 4 months ago

Last modified 4 months ago

Code that does not make sense

Reported by: sci2tech Assigned to:
Priority: trivial Milestone: ispCP ω 1.0.0 - RC6
Component: Frontend (GUI) Version: ispCP ω 1.0.0 - RC5
Severity: Easy Keywords:
Cc:

Description

In gui/include/ispcp-lib.php:

if ($_REQUEST && !defined('OVERRIDE_PURIFIER')) {
	$config = HTMLPurifier_Config::createDefault();
	$config->set('HTML', 'TidyLevel', 'none'); // XSS cleaning
	$purifier = new HTMLPurifier($config);
	//$purifier = HTMLPurifier::getInstance();
	foreach ($_GET as $i) {
		$i	= $purifier->purify($i);
	}
	foreach ($_POST as $i) {
		$i	= $purifier->purify($i);
	}
	foreach ($_REQUEST as $i) {
		$i	= $purifier->purify($i);
	}
}

HTMLpurifier->purify does not take a reference as input and even it was $i could not be a valid reference to data that supposed to be cleaned, so even after purifying the argument it is not clear the value of $_GET/_POST/_REQUEST test like this:

	$_POST['test']='<script>alert(1)</script>';
	foreach ($_POST as $key=>$i) {
		echo "before: $i<br>\n";
		$i	= $purifier->purify($i);
		echo "after: $i<br>\n";
		echo "POST after: $_POST[$key]<br>\n";
	}

Maybe this code should look like:

	foreach ($_GET as $key=>$i) {
		$_GET[$key] = $purifier->purify($i);
	}
	foreach ($_POST as $key=>$i) {
		$_GET[$key] = $purifier->purify($i);
	}
	foreach ($_COOKIE as $key=>$i) {//$_REQUEST as it contains a mix of GET, POST and COOKIE data
		$_COOKIE[$key] = $purifier->purify($i); 
	}

Attachments

Change History

07/19/08 19:40:19 changed by sci2tech

Sorry, copy paste error: Should look like:

	foreach ($_GET as $key=>$i) {
		$_GET[$key] = $purifier->purify($i);
	}
	foreach ($_POST as $key=>$i) {
		$_POST[$key] = $purifier->purify($i);
	}
	foreach ($_COOKIE as $key=>$i) {//$_REQUEST as it contains a mix of GET, POST and COOKIE data
		$_COOKIE[$key] = $purifier->purify($i); 
	}

or even better:

$_GET=$purifier->purifyArray($_GET);
$_POST=$purifier->purifyArray($_POST);
$_COOKIE=$purifier->purifyArray($_COOKIE);

07/19/08 20:12:51 changed by rats

  • status changed from new to closed.
  • resolution set to fixed.
  • milestone changed from Working to ispCP ω 1.0.0 - RC6.

jaja

07/20/08 09:09:05 changed by rats

Warning: preg_match() expects parameter 2 to be string, array given in /var/www/ispcp/gui/include/htmlpurifier/HTMLPurifier/Lexer.php on line 263

Warning: preg_match() expects parameter 2 to be string, array given in /var/www/ispcp/gui/include/htmlpurifier/HTMLPurifier/Encoder.php on line 54

Notice: Array to string conversion in /var/www/ispcp/gui/include/htmlpurifier/HTMLPurifier/Encoder.php on line 72

Notice: Undefined offset: 0 in /var/www/ispcp/gui/include/htmlpurifier/HTMLPurifier/Encoder.php on line 74

Notice: Undefined offset: 0 in /var/www/ispcp/gui/include/htmlpurifier/HTMLPurifier/Encoder.php on line 75

Notice: Undefined offset: 1 in /var/www/ispcp/gui/include/htmlpurifier/HTMLPurifier/Encoder.php on line 74

Notice: Undefined offset: 1 in /var/www/ispcp/gui/include/htmlpurifier/HTMLPurifier/Encoder.php on line 75

Notice: Undefined offset: 2 in /var/www/ispcp/gui/include/htmlpurifier/HTMLPurifier/Encoder.php on line 74

Notice: Undefined offset: 2 in /var/www/ispcp/gui/include/htmlpurifier/HTMLPurifier/Encoder.php on line 75

Notice: Undefined offset: 3 in /var/www/ispcp/gui/include/htmlpurifier/HTMLPurifier/Encoder.php on line 74

Notice: Undefined offset: 3 in /var/www/ispcp/gui/include/htmlpurifier/HTMLPurifier/Encoder.php on line 75

Notice: Undefined offset: 4 in /var/www/ispcp/gui/include/htmlpurifier/HTMLPurifier/Encoder.php on line 74

Notice: Undefined offset: 4 in /var/www/ispcp/gui/include/htmlpurifier/HTMLPurifier/Encoder.php on line 75

and this works? dunno!


Add/Change #1431 (Code that does not make sense)




Action