mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-01-16 21:48:14 +01:00
- Modify hash format to be more intuitive
- Add parameter that controls magic quotes processing in loadArrayFromForm git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1107 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
parent
8913239b7f
commit
dea62ffdab
2
NEWS
2
NEWS
@ -26,7 +26,7 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
|
||||
! Configuration form-editing API makes tweaking HTMLPurifier_Config a
|
||||
breeze!
|
||||
! Configuration directives that accept hashes now allow new string
|
||||
format: key1,value1,key2,value2
|
||||
format: key1:value1,key2:value2
|
||||
! ConfigDoc now factored into OOP design
|
||||
- Deprecated and removed EnableRedundantUTF8Cleaning. It didn't even work!
|
||||
. Unit test for ElementDef created, ElementDef behavior modified to
|
||||
|
@ -300,10 +300,12 @@ class HTMLPurifier_Config
|
||||
/**
|
||||
* Loads configuration values from $_GET/$_POST that were posted
|
||||
* via ConfigForm
|
||||
* @param $array $_GET or $_POST array to import
|
||||
* @param $mq_fix Boolean whether or not to enable magic quotes fix
|
||||
* @static
|
||||
*/
|
||||
function loadArrayFromForm($array) {
|
||||
$mq = get_magic_quotes_gpc();
|
||||
function loadArrayFromForm($array, $mq_fix = true) {
|
||||
$mq = get_magic_quotes_gpc() && $mq_fix;
|
||||
foreach ($array as $key => $value) {
|
||||
if (!strncmp($key, 'Null_', 5) && !empty($value)) {
|
||||
unset($array[substr($key, 5)]);
|
||||
|
@ -347,10 +347,12 @@ class HTMLPurifier_ConfigSchema {
|
||||
// remove spaces
|
||||
foreach ($var as $i => $j) $var[$i] = trim($j);
|
||||
if ($type === 'hash') {
|
||||
// key,value,key,value
|
||||
// key:value,key2:value2
|
||||
$nvar = array();
|
||||
for ($i = 0, $c = count($var); $i + 1 < $c; $i += 2) {
|
||||
$nvar[$var[$i]] = $var[$i + 1];
|
||||
foreach ($var as $keypair) {
|
||||
$c = explode(':', $keypair, 2);
|
||||
if (!isset($c[1])) continue;
|
||||
$nvar[$c[0]] = $c[1];
|
||||
}
|
||||
$var = $nvar;
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ class HTMLPurifier_Printer_ConfigForm_default extends HTMLPurifier_Printer {
|
||||
case 'hash':
|
||||
$nvalue = '';
|
||||
foreach ($value as $i => $v) {
|
||||
$nvalue .= "$i,$v,";
|
||||
$nvalue .= "$i:$v,";
|
||||
}
|
||||
$value = $nvalue;
|
||||
break;
|
||||
|
@ -288,8 +288,10 @@ class HTMLPurifier_ConfigSchemaTest extends UnitTestCase
|
||||
$this->assertValid(array(1 => 'moo'), 'hash');
|
||||
$this->assertInvalid(array(0 => 'moo'), 'hash');
|
||||
$this->assertValid('', 'hash', array());
|
||||
$this->assertValid('foo,bar,too,two', 'hash', array('foo' => 'bar', 'too' => 'two'));
|
||||
$this->assertValid('foo,bar,too', 'hash', array('foo' => 'bar'));
|
||||
$this->assertValid('foo:bar,too:two', 'hash', array('foo' => 'bar', 'too' => 'two'));
|
||||
$this->assertValid('foo:bar,too', 'hash', array('foo' => 'bar'));
|
||||
$this->assertValid('foo:bar,', 'hash', array('foo' => 'bar'));
|
||||
$this->assertValid('foo:bar:baz', 'hash', array('foo' => 'bar:baz'));
|
||||
|
||||
$this->assertValid(23, 'mixed');
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user