mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-08-03 20:58:11 +02:00
[1.3.0] Some housekeeping after the last commit
- Add a few missing unit tests - Allow for spaces between comma separated strings to be transformed into arrays - smoketests/printDefinition.php now has documentation, links to more documentation and a friendly user-interface git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@579 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
@@ -260,7 +260,13 @@ class HTMLPurifier_ConfigSchema {
|
|||||||
case 'list':
|
case 'list':
|
||||||
case 'hash':
|
case 'hash':
|
||||||
case 'lookup':
|
case 'lookup':
|
||||||
if (is_string($var)) $var = explode(',',$var);
|
if (is_string($var)) {
|
||||||
|
// simplistic string to array method that only works
|
||||||
|
// for simple lists of tag names or alphanumeric characters
|
||||||
|
$var = explode(',',$var);
|
||||||
|
// remove spaces
|
||||||
|
foreach ($var as $i => $j) $var[$i] = trim($j);
|
||||||
|
}
|
||||||
if (!is_array($var)) break;
|
if (!is_array($var)) break;
|
||||||
$keys = array_keys($var);
|
$keys = array_keys($var);
|
||||||
if ($keys === array_keys($keys)) {
|
if ($keys === array_keys($keys)) {
|
||||||
|
@@ -54,8 +54,17 @@ echo '<?xml version="1.0" encoding="UTF-8" ?>';
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>HTML Purifier Printer Smoketest</h1>
|
<h1>HTML Purifier Printer Smoketest</h1>
|
||||||
<p>Pretty-print an object and see how it turns out.</p>
|
<p>Pretty-print a definition and check out its contents. You can
|
||||||
|
also twiddle with the configuration settings to see how a directive
|
||||||
|
influences the internal behavior of the object.</p>
|
||||||
<h2>Modify configuration</h2>
|
<h2>Modify configuration</h2>
|
||||||
|
|
||||||
|
<p>You can specify an array by typing in a comma-separated
|
||||||
|
list of items, HTML Purifier will take care of the rest (including
|
||||||
|
transformation into a real array list or a lookup table). If a
|
||||||
|
directive can be set to null, that usually means that the feature
|
||||||
|
is disabled when it is null (not that, say, no tags are allowed).</p>
|
||||||
|
|
||||||
<form id="edit-config" method="get" action="printDefinition.php">
|
<form id="edit-config" method="get" action="printDefinition.php">
|
||||||
<table>
|
<table>
|
||||||
<?php
|
<?php
|
||||||
@@ -79,19 +88,24 @@ echo '<?xml version="1.0" encoding="UTF-8" ?>';
|
|||||||
$allow_null = $config->def->info['HTML'][$key]->allow_null;
|
$allow_null = $config->def->info['HTML'][$key]->allow_null;
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<th>%<?php echo $directive; ?></th>
|
<th>
|
||||||
|
<a href="http://hp.jpsband.org/live/configdoc/plain.html#<?php echo $directive ?>">
|
||||||
|
%<?php echo $directive; ?>
|
||||||
|
</a>
|
||||||
|
</th>
|
||||||
<td>
|
<td>
|
||||||
<?php if (is_bool($value)) { ?>
|
<?php if (is_bool($value)) { ?>
|
||||||
<input type="checkbox" name="<?php echo $directive; ?>" value="1"<?php if ($value) { ?> checked="checked"<?php } ?> />
|
Yes <input type="radio" name="<?php echo $directive; ?>" value="1"<?php if ($value) { ?> checked="checked"<?php } ?> />
|
||||||
|
No <input type="radio" name="<?php echo $directive; ?>" value="0"<?php if (!$value) { ?> checked="checked"<?php } ?> />
|
||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
<?php if($allow_null) { ?>
|
<?php if($allow_null) { ?>
|
||||||
Null <input
|
Null/Disabled <input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
value="1"
|
value="1"
|
||||||
onclick="toggleWriteability('<?php echo $directive ?>',checked)"
|
onclick="toggleWriteability('<?php echo $directive ?>',checked)"
|
||||||
name="Null_<?php echo $directive; ?>"
|
name="Null_<?php echo $directive; ?>"
|
||||||
<?php if ($value === null) { ?> checked="checked"<?php } ?>
|
<?php if ($value === null) { ?> checked="checked"<?php } ?>
|
||||||
/> or
|
/> or <br />
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
|
@@ -284,6 +284,11 @@ class HTMLPurifier_ConfigSchemaTest extends UnitTestCase
|
|||||||
$this->assertInvalid(array(0 => 'moo'), 'hash');
|
$this->assertInvalid(array(0 => 'moo'), 'hash');
|
||||||
$this->assertValid(array(1 => 'moo'), 'hash');
|
$this->assertValid(array(1 => 'moo'), 'hash');
|
||||||
$this->assertValid(23, 'mixed');
|
$this->assertValid(23, 'mixed');
|
||||||
|
$this->assertValid('foo,bar, cow', 'list', array('foo', 'bar', 'cow'));
|
||||||
|
$this->assertValid('foo,bar', 'lookup', array('foo' => true, 'bar' => true));
|
||||||
|
$this->assertValid('true', 'bool', true);
|
||||||
|
$this->assertValid('false', 'bool', false);
|
||||||
|
$this->assertValid('1', 'bool', true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -106,6 +106,20 @@ class HTMLPurifier_ConfigTest extends UnitTestCase
|
|||||||
$this->assertError('Value is of invalid type');
|
$this->assertError('Value is of invalid type');
|
||||||
$this->assertNoErrors();
|
$this->assertNoErrors();
|
||||||
|
|
||||||
|
// grab a namespace
|
||||||
|
$config->set('Attr', 'Key', 0xBEEF);
|
||||||
|
$this->assertIdentical(
|
||||||
|
$config->getBatch('Attr'),
|
||||||
|
array(
|
||||||
|
'Key' => 0xBEEF
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// grab a non-existant namespace
|
||||||
|
$config->getBatch('FurnishedGoods');
|
||||||
|
$this->assertError('Cannot retrieve undefined namespace');
|
||||||
|
$this->assertNoErrors();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_getDefinition() {
|
function test_getDefinition() {
|
||||||
|
Reference in New Issue
Block a user