Skip to content

Commit

Permalink
Fixes [\#5 state:resolved milestone:"0.0.11"]
Browse files Browse the repository at this point in the history
  • Loading branch information
rubyredrick committed May 23, 2009
1 parent 78feceb commit 2bcce46
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
6 changes: 3 additions & 3 deletions lib/ri_cal/property_value/text.rb
Expand Up @@ -26,9 +26,9 @@ def ruby_value
end

def self.convert(parent, string) #:nodoc:
ical_str = string.gsub(/\n|,|;/) {|match|
if match == "\n"
'\n'
ical_str = string.gsub(/\n\r?|\r\n?|,|;|\\/) {|match|
if ["\n", "\r", "\n\r", "\r\n"].include?(match)
'\\n'
else
"\\#{match}"
end
Expand Down
6 changes: 3 additions & 3 deletions spec/ri_cal/component/event_spec.rb
Expand Up @@ -310,12 +310,12 @@ def unfold(string)
unfold(@it.export).should match(/^DTSTART;VALUE=DATE:20090422$/)
end

it "should properly fold on export" do
@it.description = "Weather report looks nice, 80 degrees and partly cloudy, so following Michael's suggestion, let's meet at the food court at Crossroads:\n\nhttp://www.shopcrossroadsplaza.c...\n"
it "should properly fold on export when the description contains a carriage return" do
@it.description = "Weather report looks nice, 80 degrees and partly cloudy, so following Michael's suggestion, let's meet at the food court at Crossroads:\n\rhttp://www.shopcrossroadsplaza.c...\n"
export_string = @it.export
export_string.should match(%r(^DESCRIPTION:Weather report looks nice\\, 80 degrees and partly cloudy\\, so$))
export_string.should match(%r(^ following Michael's suggestion\\, let's meet at the food court at Crossr$))
export_string.should match(%r(^ oads:\\n\\nhttp://www.shopcrossroadsplaza\.c\.\.\.\\n$))
export_string.should match(%r(^ oads:\\nhttp://www\.shopcrossroadsplaza.c\.\.\.\\n$))
end
end

Expand Down
24 changes: 18 additions & 6 deletions spec/ri_cal/property_value/text_spec.rb
Expand Up @@ -3,11 +3,23 @@
require File.join(File.dirname(__FILE__), %w[.. .. spec_helper])

describe RiCal::PropertyValue::Text do

it "should handle escapes according to RFC2445 Sec 4.3.11 p 45" do
expected = "this\\ has\, \nescaped\;\n\\x characters"
it = RiCal::PropertyValue::Text.new(nil, :value => 'this\\ has\, \nescaped\;\N\x characters')
it.ruby_value.should == expected

context ".ruby_value" do

it "should handle escapes according to RFC2445 Sec 4.3.11 p 45" do
expected = "this\\ has\, \nescaped\;\n\\x characters"
it = RiCal::PropertyValue::Text.new(nil, :value => 'this\\ has\, \nescaped\;\N\x characters')
it.ruby_value.should == expected
end
end

context ".convert" do

it "should handle escapes according to RFC2445 Sec 4.3.11 p 45" do
expected = ':this has\, \nescaped\;\n characters\ncr\nnlcr\ncrnl'
it = RiCal::PropertyValue::Text.convert(nil, "this\ has, \nescaped;\n characters\rcr\n\rnlcr\r\ncrnl")
it.to_s.should == expected
end
end

end

0 comments on commit 2bcce46

Please sign in to comment.