icalendar 2.7.0 → 2.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b22d9bc37f8f10ba08d5b8aa155dfb1b97a9876c800c547271f43ce15f09b89d
4
- data.tar.gz: 91260efab7eafc852e509258fa0163cd1ac2c41352b9482fcae85a45547fa325
3
+ metadata.gz: fbeadc87a1316894e02896fd63e7f7644a1ab5bf3a542b0d5a02c59aabf2d603
4
+ data.tar.gz: 3aaf09d7984fed57644d091fa76285084d9fbf3568e6078939e7887d6f44f50a
5
5
  SHA512:
6
- metadata.gz: a6466ed9d1ae91fd9007b42a8d9001879e601ea5f03c338fceb5dcda03b3b32e27ca115cb3a359560b9c04c8944891a174d3bade9596f84d2ca12808dad3046d
7
- data.tar.gz: a587f1166316ad6a87602d3026144c3d3e9ca09a6d3ef2a40a0664aa77cd497817894df6d53503f6cdcfd95a99fcc2e66c6a8688af19870de2a199cf9b47511d
6
+ metadata.gz: e6134ff7d12c820d7ee10a316108c1d7a9db274cccd366b93a49fa491931038edd78eb37789a24962cc6370c83fd34d67508dd24b574e8d1fa235e815c1fa22d
7
+ data.tar.gz: 0bad8ab7548493a133686dab3a6d36a58aeecddb8642da83cef5a2184d0d08e97dc59307fc6fdd9574935319044ccb5ffa50f9c936aa60e5637a2430e78eb446
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 2.7.1 2021-03-14
2
+ * Recover from bad line-wrapping code that splits in the middle of Unicode code points
3
+ * Add a verbose option to the Parser to quiet some of the chattier log entries
4
+
1
5
  === 2.7.0 2020-09-12
2
6
  * Handle custom component names, with and without X- prefix
3
7
  * Fix Component lookup to avoid namespace collisions
data/README.md CHANGED
@@ -220,7 +220,8 @@ end
220
220
  iCalendar has some basic support for creating VTIMEZONE blocks from timezone information pulled from `tzinfo`.
221
221
  You must require `tzinfo` support manually to take advantage.
222
222
 
223
- iCalendar has been tested and works with `tzinfo` versions 0.3 and 1.x
223
+ iCalendar has been tested and works with `tzinfo` versions 0.3, 1.x, and 2.x. The `tzinfo-data` gem may also
224
+ be required depending on your version of `tzinfo` and potentially your operating system.
224
225
 
225
226
  #### Example ####
226
227
 
data/lib/icalendar.rb CHANGED
@@ -33,3 +33,4 @@ require 'icalendar/freebusy'
33
33
  require 'icalendar/timezone'
34
34
  require 'icalendar/calendar'
35
35
  require 'icalendar/parser'
36
+ require 'icalendar/version'
@@ -11,9 +11,10 @@ module Icalendar
11
11
  attr_accessor :parent
12
12
 
13
13
  def self.parse(source)
14
- parser = Parser.new(source)
15
- parser.component_class = self
16
- parser.parse
14
+ _parse source
15
+ rescue ArgumentError
16
+ source.rewind if source.respond_to?(:rewind)
17
+ _parse Parser.clean_bad_wrapping(source)
17
18
  end
18
19
 
19
20
  def initialize(name, ical_name = nil)
@@ -101,6 +102,14 @@ module Icalendar
101
102
  end
102
103
  collection.empty? ? nil : collection.join.chomp("\r\n")
103
104
  end
105
+
106
+ class << self
107
+ private def _parse(source)
108
+ parser = Parser.new(source)
109
+ parser.component_class = self
110
+ parser.parse
111
+ end
112
+ end
104
113
  end
105
114
 
106
115
  end
@@ -4,9 +4,24 @@ module Icalendar
4
4
 
5
5
  class Parser
6
6
  attr_writer :component_class
7
- attr_reader :source, :strict, :timezone_store
7
+ attr_reader :source, :strict, :timezone_store, :verbose
8
8
 
9
- def initialize(source, strict = false)
9
+ def self.clean_bad_wrapping(source)
10
+ content = if source.respond_to? :read
11
+ source.read
12
+ elsif source.respond_to? :to_s
13
+ source.to_s
14
+ else
15
+ msg = 'Icalendar::Parser.clean_bad_wrapping must be called with a String or IO object'
16
+ Icalendar.fatal msg
17
+ fail ArgumentError, msg
18
+ end
19
+ encoding = content.encoding
20
+ content.force_encoding(Encoding::ASCII_8BIT)
21
+ content.gsub(/\r?\n[ \t]/, "").force_encoding(encoding)
22
+ end
23
+
24
+ def initialize(source, strict = false, verbose = false)
10
25
  if source.respond_to? :gets
11
26
  @source = source
12
27
  elsif source.respond_to? :to_s
@@ -18,6 +33,7 @@ module Icalendar
18
33
  end
19
34
  read_in_data
20
35
  @strict = strict
36
+ @verbose = verbose
21
37
  @timezone_store = TimezoneStore.new
22
38
  end
23
39
 
@@ -49,7 +65,7 @@ module Icalendar
49
65
  Icalendar.logger.error "No method \"#{method_name}\" for component #{component}"
50
66
  raise nme
51
67
  else
52
- Icalendar.logger.warn "No method \"#{method_name}\" for component #{component}. Appending to custom."
68
+ Icalendar.logger.warn "No method \"#{method_name}\" for component #{component}. Appending to custom." if verbose?
53
69
  component.append_custom_property prop_name, prop_value
54
70
  end
55
71
  end
@@ -93,6 +109,10 @@ module Icalendar
93
109
  !!@strict
94
110
  end
95
111
 
112
+ def verbose?
113
+ @verbose
114
+ end
115
+
96
116
  private
97
117
 
98
118
  def component_class
@@ -1,5 +1,5 @@
1
1
  module Icalendar
2
2
 
3
- VERSION = '2.7.0'
3
+ VERSION = '2.7.1'
4
4
 
5
5
  end
@@ -170,4 +170,13 @@ END:VCALENDAR
170
170
  expect(subject.ip_method).to eq 'PUBLISH'
171
171
  end
172
172
  end
173
+
174
+ describe '.parse' do
175
+ let(:source) { File.read File.join(File.dirname(__FILE__), 'fixtures', 'bad_wrapping.ics') }
176
+
177
+ it 'correctly parses a bad file' do
178
+ actual = described_class.parse(source)
179
+ expect(actual[0]).to be_a(described_class)
180
+ end
181
+ end
173
182
  end
@@ -0,0 +1,14 @@
1
+ BEGIN:VCALENDAR
2
+ VERSION:2.0
3
+ PRODID:manual
4
+ CALSCALE:GREGORIAN
5
+ BEGIN:VEVENT
6
+ DTSTAMP:20200902T223352Z
7
+ UID:6e7d7fe5-6735-4cdd-bfe4-761dfcecd7a7
8
+ DTSTART;VALUE=DATE:20200902
9
+ DTEND;VALUE=DATE:20200903
10
+ DESCRIPTION:Event description that puts a UTF-8 multi-octet sequence right�
11
+ �here.
12
+ SUMMARY:UTF-8 multi-octet sequence test
13
+ END:VEVENT
14
+ END:VCALENDAR
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: icalendar
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.0
4
+ version: 2.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Ahearn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-12 00:00:00.000000000 Z
11
+ date: 2021-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ice_cube
@@ -210,6 +210,7 @@ files:
210
210
  - spec/calendar_spec.rb
211
211
  - spec/downcased_hash_spec.rb
212
212
  - spec/event_spec.rb
213
+ - spec/fixtures/bad_wrapping.ics
213
214
  - spec/fixtures/custom_component.ics
214
215
  - spec/fixtures/event.ics
215
216
  - spec/fixtures/nondefault_values.ics
@@ -262,7 +263,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
262
263
  - !ruby/object:Gem::Version
263
264
  version: '0'
264
265
  requirements: []
265
- rubygems_version: 3.1.2
266
+ rubygems_version: 3.2.11
266
267
  signing_key:
267
268
  specification_version: 4
268
269
  summary: A ruby implementation of the iCalendar specification (RFC-5545).
@@ -271,6 +272,7 @@ test_files:
271
272
  - spec/calendar_spec.rb
272
273
  - spec/downcased_hash_spec.rb
273
274
  - spec/event_spec.rb
275
+ - spec/fixtures/bad_wrapping.ics
274
276
  - spec/fixtures/custom_component.ics
275
277
  - spec/fixtures/event.ics
276
278
  - spec/fixtures/nondefault_values.ics