Forward porting fixes for iCal escaping and unescaping, and line wrapping.

This commit is contained in:
Colin Kuskie 2009-07-01 22:18:57 +00:00
parent 109178ac6a
commit c30614bdf6
5 changed files with 89 additions and 9 deletions

View file

@ -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;
}
#----------------------------------------------------------------------------

View file

@ -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;
}