0
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2024-11-09 23:28:42 +00:00

Allow empty sections in string hashes; previously they were left undefined.

Signed-off-by: Edward Z. Yang <edwardzyang@thewritingpot.com>
This commit is contained in:
Edward Z. Yang 2008-07-04 21:26:26 -04:00
parent aa0fdeee30
commit a227cb483a
4 changed files with 5 additions and 1 deletions

2
NEWS
View File

@ -31,6 +31,8 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
for more interesting filter-backtracking for more interesting filter-backtracking
. New HTMLPurifier_Injector->rewind() functionality, allows injectors to rewind . New HTMLPurifier_Injector->rewind() functionality, allows injectors to rewind
index to reprocess tokens. index to reprocess tokens.
. StringHashParser now allows for multiline sections with "empty" content;
previously the section would remain undefined.
3.1.1, released 2008-06-19 3.1.1, released 2008-06-19
# %URI.Munge now, by default, does not munge resources (for example, <img src="">) # %URI.Munge now, by default, does not munge resources (for example, <img src="">)

View File

@ -78,6 +78,7 @@ class HTMLPurifier_StringHashParser
if (strncmp('--', $line, 2) === 0) { if (strncmp('--', $line, 2) === 0) {
// Multiline declaration // Multiline declaration
$state = trim($line, '- '); $state = trim($line, '- ');
if (!isset($ret[$state])) $ret[$state] = '';
continue; continue;
} elseif (!$state) { } elseif (!$state) {
$single = true; $single = true;
@ -94,7 +95,6 @@ class HTMLPurifier_StringHashParser
$single = false; $single = false;
$state = false; $state = false;
} else { } else {
if (!isset($ret[$state])) $ret[$state] = '';
$ret[$state] .= "$line\n"; $ret[$state] .= "$line\n";
} }
} while (!feof($fh)); } while (!feof($fh));

View File

@ -4,5 +4,6 @@ CHAIN-ME: 2
--DESCRIPTION-- --DESCRIPTION--
Multiline Multiline
stuff stuff
--EMPTY--
--FOR-WHO-- --FOR-WHO--
Single multiline Single multiline

View File

@ -29,6 +29,7 @@ class HTMLPurifier_StringHashParserTest extends UnitTestCase
'TYPE' => 'string', 'TYPE' => 'string',
'CHAIN-ME' => '2', 'CHAIN-ME' => '2',
'DESCRIPTION' => "Multiline\nstuff\n", 'DESCRIPTION' => "Multiline\nstuff\n",
'EMPTY' => '',
'FOR-WHO' => "Single multiline\n", 'FOR-WHO' => "Single multiline\n",
)); ));
} }