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