Forward porting fixes for iCal escaping and unescaping, and line wrapping.
This commit is contained in:
parent
109178ac6a
commit
c30614bdf6
5 changed files with 89 additions and 9 deletions
|
|
@ -2,6 +2,7 @@
|
|||
- fixed #10574: Creating Calendar Entry
|
||||
- fixed #10522: Metadata value & label problem
|
||||
- fixed #10594: iCal title display error.
|
||||
- fixed #10602: Calendar feed importing extra characters.
|
||||
|
||||
7.7.12
|
||||
- Updated auth to allow sending back of non-text/html mime types.
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ use base 'WebGUI::Asset::Wobject';
|
|||
|
||||
use DateTime;
|
||||
use JSON;
|
||||
use Text::Wrap;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -1741,14 +1742,16 @@ that ; , \ and newlines should be escaped by prepending them with a \.
|
|||
sub wrapIcal {
|
||||
my $self = shift;
|
||||
my $text = shift;
|
||||
|
||||
return $text unless length $text >= 75;
|
||||
|
||||
|
||||
$text =~ s/([,;\\])/\\$1/g;
|
||||
$text =~ s/\n/\\n/g;
|
||||
|
||||
my @text = ($text =~ m/.{1,75}/g);
|
||||
return join "\r\n ",@text;
|
||||
|
||||
{
|
||||
local $Text::Wrap::separator = "\r\n";
|
||||
local $Text::Wrap::columns = 74;
|
||||
$text = Text::Wrap::wrap('', ' ', $text);
|
||||
}
|
||||
return $text;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -528,9 +528,17 @@ sub _icalToMySQL {
|
|||
)->toMysql;
|
||||
}
|
||||
|
||||
=head2 _unwrapIcalText
|
||||
|
||||
This really just unescapes iCal text, handling commas, semi-colons, backslashes
|
||||
and newlines
|
||||
|
||||
=cut
|
||||
|
||||
sub _unwrapIcalText {
|
||||
my $text = shift;
|
||||
$text =~ s/\\([,;\\])/$1/g;
|
||||
$text =~ s/\\n/\n/g;
|
||||
return $text;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,13 +14,45 @@ use lib "$FindBin::Bin/../../lib";
|
|||
|
||||
##The goal of this test is to test the creation of Calendar Wobjects.
|
||||
|
||||
my @icalWrapTests = (
|
||||
{
|
||||
in => 'Text is passed through with no problems',
|
||||
out => 'Text is passed through with no problems',
|
||||
comment => 'Text passed through with no problems',
|
||||
},
|
||||
{
|
||||
in => ',Escape more than one, multiple, commas,',
|
||||
out => '\,Escape more than one\, multiple\, commas\,',
|
||||
comment => 'escape commas',
|
||||
},
|
||||
{
|
||||
in => ';Escape more than one; multiple; semicolons;',
|
||||
out => '\;Escape more than one\; multiple\; semicolons\;',
|
||||
comment => 'escape semicolons',
|
||||
},
|
||||
{
|
||||
in => "lots\nand\nlots\nof\nnewlines\n",
|
||||
out => 'lots\\nand\\nlots\\nof\\nnewlines\\n',
|
||||
comment => 'escape newlines',
|
||||
},
|
||||
{
|
||||
# 1 2 3 4 5 6 7 V
|
||||
#12345678901234567890123456789012345678901234567890123456789012345678901234567890
|
||||
in => "There's not a day goes by I don't feel regret. Not because I'm in here, or because you think I should. I look back on the way I was then: a young, stupid kid who committed that terrible crime. I want to talk to him.",
|
||||
out => "There's not a day goes by I don't feel regret. Not because I'm in here\\,\r\n or because you think I should. I look back on the way I was then: a\r\n young\\, stupid kid who committed that terrible crime. I want to talk to\r\n him.",
|
||||
comment => 'basic wrapping',
|
||||
},
|
||||
);
|
||||
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More tests => 5; # increment this value for each test you create
|
||||
use Test::More;
|
||||
use Test::Deep;
|
||||
use WebGUI::Asset::Wobject::Calendar;
|
||||
use WebGUI::Asset::Event;
|
||||
|
||||
plan tests => 5 + scalar @icalWrapTests;
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
# Do our work in the import node
|
||||
|
|
@ -75,6 +107,20 @@ cmp_deeply(
|
|||
'Variables returned by appendTemplateVarsDateTime'
|
||||
);
|
||||
|
||||
################################################################
|
||||
#
|
||||
# wrapIcal
|
||||
#
|
||||
################################################################
|
||||
|
||||
#Any old calendar will do for these tests.
|
||||
|
||||
foreach my $test (@icalWrapTests) {
|
||||
my ($in, $out, $comment) = @{ $test }{ qw/in out comment/ };
|
||||
my $wrapOut = $cal->wrapIcal($in);
|
||||
is ($wrapOut, $out, $comment);
|
||||
}
|
||||
|
||||
TODO: {
|
||||
local $TODO = "Tests to make later";
|
||||
ok(0, 'Lots more to test');
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ if (!$ENV{WEBGUI_LIVE}) {
|
|||
plan skip_all => 'No website available';
|
||||
}
|
||||
else {
|
||||
plan tests => 10; # increment this value for each test you create
|
||||
plan tests => 14; # increment this value for each test you create
|
||||
}
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
|
@ -54,7 +54,7 @@ my $party = $sender->addChild({
|
|||
className => 'WebGUI::Asset::Event',
|
||||
title => 'WebGUI 100th Anniversary',
|
||||
menuTitle => 'Anniversary',
|
||||
description => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum', ##Set at longer than 72 characters to test for line wrapping
|
||||
description => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum', ##Set at longer than 72 characters to test for line wrapping, and character escaping
|
||||
url => 'webgui_anniversary',
|
||||
startDate => $dt->toDatabaseDate, ##Times and dates have to be entered in UTC
|
||||
endDate => $dt->toDatabaseDate,
|
||||
|
|
@ -108,7 +108,29 @@ is($anniversary->get('groupIdEdit'), $party->get('groupIdEdit'), '... groupIdE
|
|||
is($anniversary->get('url'), $party->get('url').'2', '... url (accounting for duplicate)');
|
||||
is($anniversary->get('description'), $party->get('description'), '... description, checks for line wrapping');
|
||||
|
||||
$party->update({description => "one line\nsecond line"});
|
||||
|
||||
my $instance2 = WebGUI::Workflow::Instance->create($session,
|
||||
{
|
||||
workflowId => $workflow->getId,
|
||||
skipSpectreNotification => 1,
|
||||
}
|
||||
);
|
||||
|
||||
$retVal = $instance2->run();
|
||||
is($retVal, 'complete', 'cleanup: 2nd activity complete');
|
||||
$retVal = $instance2->run();
|
||||
is($retVal, 'done', 'cleanup: 2nd activity is done');
|
||||
$instance1->delete;
|
||||
|
||||
$newEvents = $receiver->getLineage(['children'], { returnObjects => 1, });
|
||||
|
||||
is(scalar @{ $newEvents }, 1, 'reimport does not create new children');
|
||||
$anniversary = pop @{ $newEvents };
|
||||
is($anniversary->get('description'), $party->get('description'), '... description, checks for line unwrapping');
|
||||
|
||||
END {
|
||||
$instance1 && $instance1->delete('skipNotify');
|
||||
$instance2 && $instance2->delete('skipNotify');
|
||||
$workflow && $workflow->delete;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue