Fix a bug where html2text dropped the last word. Added tests.
This commit is contained in:
parent
c452f92224
commit
3535e8ddb4
3 changed files with 29 additions and 3 deletions
|
|
@ -1,6 +1,6 @@
|
|||
7.7.5
|
||||
- Adding StoryManager.
|
||||
- fixed #10223: Calendar List View Ignores Event Permissions (dhelsten)
|
||||
- fixed #10226: html2text dropping text
|
||||
|
||||
7.7.4
|
||||
- rfe: Extend DateTime for Week-Nrs (#9151)
|
||||
|
|
|
|||
|
|
@ -227,7 +227,7 @@ my $text = "";
|
|||
my $inside = {};
|
||||
|
||||
sub html2text {
|
||||
my $html = shift;
|
||||
my $html = shift . " ";
|
||||
$text = "";
|
||||
$inside = {};
|
||||
my $tagHandler = sub {
|
||||
|
|
|
|||
28
t/HTML.t
28
t/HTML.t
|
|
@ -96,7 +96,28 @@ my @macroParamSets = (
|
|||
},
|
||||
);
|
||||
|
||||
my $numTests = scalar @filterSets + scalar @macroParamSets;
|
||||
my @htmlTextSets = (
|
||||
{
|
||||
inputText => q|I wish I could tell you that Andy fought the good fight.|,
|
||||
output => q|I wish I could tell you that Andy fought the good fight.|,
|
||||
comment => 'bare text',
|
||||
},
|
||||
{
|
||||
inputText => q|The man likes to play chess; let's get him some rocks. |,
|
||||
output => q|The man likes to play chess; let's get him some rocks.|,
|
||||
comment => 'bare text with ending space has that space removed',
|
||||
},
|
||||
{
|
||||
inputText => q|<p>Do you enjoy working in the laundry?</p>|,
|
||||
output => qq|\nDo you enjoy working in the laundry?\n|,
|
||||
comment => 'text in paragraph tag nested inside newlines',
|
||||
},
|
||||
);
|
||||
|
||||
my $numTests = scalar @filterSets
|
||||
+ scalar @macroParamSets
|
||||
+ scalar @htmlTextSets
|
||||
;
|
||||
|
||||
plan tests => $numTests;
|
||||
|
||||
|
|
@ -109,3 +130,8 @@ foreach my $testSet (@macroParamSets) {
|
|||
WebGUI::HTML::makeParameterSafe(\$testSet->{inputText});
|
||||
is($testSet->{inputText}, $testSet->{output}, $testSet->{comment});
|
||||
}
|
||||
|
||||
foreach my $testSet (@htmlTextSets) {
|
||||
my $text = WebGUI::HTML::html2text($testSet->{inputText});
|
||||
is($text, $testSet->{output}, $testSet->{comment});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue