Skip Menu |

This queue is for tickets about the Data-ICal CPAN distribution.

Report information
The Basics
Id: 17191
Status: resolved
Priority: 0/
Queue: Data-ICal

People
Owner: Nobody in particular
Requestors: mark [...] summersault.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.05
Fixed in: (no value)



Subject: PATCH: Values weren't be quoted per the ICal spec.
Values weren't being quoted according to the ICal spec. Code, tests, docs and a pointer to the key part of the spec are attached to addressed that. Thanks for this module! It seems to be best option for writing out ics files. Mark
Subject: proper_quoting.patch
--- /root/.cpan/build/Data-ICal-0.05/t/01.simplegen.t Wed Jul 27 10:47:10 2005 +++ t/01.simplegen.t Fri Jan 20 16:14:25 2006 @@ -80,7 +80,7 @@ $event->add_properties( summary => 'Awesome party', - description => 'at my place!', + description => 'at my place,\nOn 5th St.', ); ok($s->add_entry($event)); @@ -97,7 +97,7 @@ URL:http://example.com/todo1 END:VTODO BEGIN:VEVENT -DESCRIPTION:at my place! +DESCRIPTION:at my place\,\\nOn 5th St. SUMMARY:Awesome party END:VEVENT END:VCALENDAR diff -rN -u old-mark/perllib/Data/ICal/Property.pm new-mark/perllib/Data/ICal/Property.pm --- old-mark/perllib/Data/ICal/Property.pm 2006-01-20 16:00:26.000000000 -0500 +++ new-mark/perllib/Data/ICal/Property.pm 2006-01-20 16:13:24.000000000 -0500 @@ -7,6 +7,8 @@ use Carp; +our $VERSION = '0.06'; + =head1 NAME Data::ICal::Property - Represents a property on an entry in an iCalendar file @@ -75,7 +77,7 @@ my $self = shift; my $string = uc( $self->key ) . $self->_parameters_as_string . ":" - . $self->value . "\n"; + . $self->_value_as_string . "\n"; # Assumption: the only place in an iCalendar that needs folding are property # lines @@ -84,6 +86,33 @@ =begin private +=head2 _value_as_string + +Returns the property's value as a string. + +Values are quoted according the ICal spec: +L<http://www.kanzaki.com/docs/ical/text.html>. + +=end private + +=cut + +sub _value_as_string { + my $self = shift; + my $value = $self->value(); + + $value =~ s/\/\\/gs; + $value =~ s/;/\;/gs; + $value =~ s/,/\,/gs; + $value =~ s/\n/\\n/gs; + $value =~ s/\\N/\\N/gs; + + return $value; + +} + +=begin private + =head2 _parameters_as_string Returns the property's parameters as a string. Properties are sorted alphabetically
Ok, so I didn't have enough tests the first time, and the quoting issue wasn't completely fixed. The attached patch supercedes the last, including beefier tests and better code. Mark
--- /root/.cpan/build/Data-ICal-0.05/t/01.simplegen.t Wed Jul 27 10:47:10 2005 +++ t/01.simplegen.t Fri Jan 20 16:36:16 2006 @@ -62,7 +62,7 @@ BEGIN:VTODO COMMENT:a first comment COMMENT:a second comment -SUMMARY:This one trumps number two, even though weird capitalization! +SUMMARY:This one trumps number two\\, even though weird capitalization! URL:http://example.com/todo1 END:VTODO END:VCALENDAR @@ -80,7 +80,7 @@ $event->add_properties( summary => 'Awesome party', - description => 'at my place!', + description => 'at my \ place,\nOn 5th St.;', ); ok($s->add_entry($event)); @@ -93,11 +93,11 @@ BEGIN:VTODO COMMENT:a first comment COMMENT:a second comment -SUMMARY:This one trumps number two, even though weird capitalization! +SUMMARY:This one trumps number two\\, even though weird capitalization! URL:http://example.com/todo1 END:VTODO BEGIN:VEVENT -DESCRIPTION:at my place! +DESCRIPTION:at my \\ place\\,\\nOn 5th St.\\; SUMMARY:Awesome party END:VEVENT END:VCALENDAR diff -rN -u old-mark/perllib/Data/ICal/Property.pm new-mark-1/perllib/Data/ICal/Property.pm --- old-mark/perllib/Data/ICal/Property.pm 2006-01-20 16:41:29.000000000 -0500 +++ new-mark-1/perllib/Data/ICal/Property.pm 2006-01-20 16:37:04.000000000 -0500 @@ -7,6 +7,8 @@ use Carp; +our $VERSION = '0.06'; + =head1 NAME Data::ICal::Property - Represents a property on an entry in an iCalendar file @@ -75,7 +77,7 @@ my $self = shift; my $string = uc( $self->key ) . $self->_parameters_as_string . ":" - . $self->value . "\n"; + . $self->_value_as_string . "\n"; # Assumption: the only place in an iCalendar that needs folding are property # lines @@ -84,6 +86,33 @@ =begin private +=head2 _value_as_string + +Returns the property's value as a string. + +Values are quoted according the ICal spec: +L<http://www.kanzaki.com/docs/ical/text.html>. + +=end private + +=cut + +sub _value_as_string { + my $self = shift; + my $value = $self->value(); + + $value =~ s/\\/\\/gs; + $value =~ s/\Q;/\\;/gs; + $value =~ s/,/\\,/gs; + $value =~ s/\n/\\n/gs; + $value =~ s/\\N/\\N/gs; + + return $value; + +} + +=begin private + =head2 _parameters_as_string Returns the property's parameters as a string. Properties are sorted alphabetically
Subject: Re: [rt.cpan.org #17191] PATCH: Values weren't be quoted per the ICal spec.
Date: Tue, 24 Jan 2006 15:46:07 +0100
To: bug-Data-ICal [...] rt.cpan.org
From: Jesse Vincent <jesse [...] fsck.com>
Thanks. Applied.