fixes #4571 Helper::clean() returns null if passed empty array or string.

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6759 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
gwoo 2008-05-05 14:41:15 +00:00
parent 0628b24760
commit 3263c0bc81
2 changed files with 15 additions and 0 deletions

View file

@ -213,6 +213,9 @@ class Helper extends Overloadable {
*/
function clean($output) {
$this->__reset();
if (empty($output)) {
return null;
}
if (is_array($output)) {
foreach ($output as $key => $value) {
$return[$key] = $this->clean($value);

View file

@ -337,6 +337,18 @@ class HelperTest extends UnitTestCase {
$this->assertEqual($result, 100);
}
function testClean() {
$result = $this->Helper->clean(array());
$this->assertEqual($result, null);
$result = $this->Helper->clean(array('<script>with something</script>', '<applet>something else</applet>'));
$this->assertEqual($result, array('with something', 'something else'));
$result = $this->Helper->clean('<script>with something</script>');
$this->assertEqual($result, 'with something');
}
function tearDown() {
unset($this->Helper, $this->View);
ClassRegistry::flush();