vpim 0.602 → 0.604
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES +8 -0
- data/lib/vpim/vcard.rb +8 -8
- data/lib/vpim/version.rb +2 -2
- data/test/test_vcard.rb +52 -0
- metadata +2 -2
data/CHANGES
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
|
+
0.604 - 2008-03-13
|
|
2
|
+
|
|
3
|
+
- Fixed a bug with lower-case UTF-16 encoded cards not being detected properly.
|
|
4
|
+
|
|
5
|
+
- Skip over invalidly encoded vCard fields when enumerating them.
|
|
6
|
+
|
|
7
|
+
|
|
1
8
|
0.602 - 2008-03-12
|
|
2
9
|
|
|
3
10
|
- Updated reminder utility to work with iCal 3.
|
|
11
|
+
|
|
4
12
|
- Reworked gem to include tests, samples, and binaries.
|
|
5
13
|
|
|
6
14
|
|
data/lib/vpim/vcard.rb
CHANGED
|
@@ -586,7 +586,7 @@ module Vpim
|
|
|
586
586
|
|
|
587
587
|
# Return line for a field
|
|
588
588
|
def f2l(field) #:nodoc:
|
|
589
|
-
Line.decode(@@decode, self, field)
|
|
589
|
+
Line.decode(@@decode, self, field) rescue nil
|
|
590
590
|
end
|
|
591
591
|
|
|
592
592
|
# With no block, returns an Array of Line. If +name+ is specified, the
|
|
@@ -662,7 +662,7 @@ module Vpim
|
|
|
662
662
|
def Vcard.decode(card)
|
|
663
663
|
if card.respond_to? :to_str
|
|
664
664
|
string = card.to_str
|
|
665
|
-
elsif card.
|
|
665
|
+
elsif card.respond_to? :read
|
|
666
666
|
string = card.read(nil)
|
|
667
667
|
else
|
|
668
668
|
raise ArgumentError, "Vcard.decode cannot be called with a #{card.type}"
|
|
@@ -679,9 +679,9 @@ module Vpim
|
|
|
679
679
|
arr = string.unpack('v*')
|
|
680
680
|
arr.shift
|
|
681
681
|
string = arr.pack('U*')
|
|
682
|
-
when /^\
|
|
682
|
+
when /^\x00B/i
|
|
683
683
|
string = string.unpack('n*').pack('U*')
|
|
684
|
-
when
|
|
684
|
+
when /^B\x00/i
|
|
685
685
|
string = string.unpack('v*').pack('U*')
|
|
686
686
|
end
|
|
687
687
|
|
|
@@ -769,11 +769,11 @@ module Vpim
|
|
|
769
769
|
end
|
|
770
770
|
|
|
771
771
|
if fields.first
|
|
772
|
-
|
|
772
|
+
line = Line.decode(@@decode, self, fields.first) rescue nil
|
|
773
773
|
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
774
|
+
if line
|
|
775
|
+
return line.value
|
|
776
|
+
end
|
|
777
777
|
end
|
|
778
778
|
|
|
779
779
|
nil
|
data/lib/vpim/version.rb
CHANGED
data/test/test_vcard.rb
CHANGED
|
@@ -729,5 +729,57 @@ END:VCARD
|
|
|
729
729
|
assert_equal(note, card.note)
|
|
730
730
|
end
|
|
731
731
|
|
|
732
|
+
def test_empty_tel
|
|
733
|
+
cin = <<___
|
|
734
|
+
BEGIN:VCARD
|
|
735
|
+
TEL;HOME;FAX:
|
|
736
|
+
END:VCARD
|
|
737
|
+
___
|
|
738
|
+
|
|
739
|
+
card = Vpim::Vcard.decode(cin).first
|
|
740
|
+
assert_equal(card.telephone, nil)
|
|
741
|
+
assert_equal(card.telephone('HOME'), nil)
|
|
742
|
+
assert_equal([], card.telephones)
|
|
743
|
+
|
|
744
|
+
end
|
|
745
|
+
|
|
746
|
+
|
|
747
|
+
def utf_name_test(c)
|
|
748
|
+
|
|
749
|
+
begin
|
|
750
|
+
card = Vpim::Vcard.decode(c).first
|
|
751
|
+
assert_equal("name", card.name.family)
|
|
752
|
+
rescue
|
|
753
|
+
$!.message << " #{c.inspect}"
|
|
754
|
+
raise
|
|
755
|
+
end
|
|
756
|
+
end
|
|
757
|
+
|
|
758
|
+
def be(s)
|
|
759
|
+
s.unpack('U*').pack('n*')
|
|
760
|
+
end
|
|
761
|
+
def le(s)
|
|
762
|
+
s.unpack('U*').pack('v*')
|
|
763
|
+
end
|
|
764
|
+
|
|
765
|
+
def test_utf_heuristics
|
|
766
|
+
bom = "\xEF\xBB\xBF"
|
|
767
|
+
dat = "BEGIN:VCARD\nN:name\nEND:VCARD\n"
|
|
768
|
+
utf_name_test(bom+dat)
|
|
769
|
+
utf_name_test(bom+dat.downcase)
|
|
770
|
+
utf_name_test(dat)
|
|
771
|
+
utf_name_test(dat.downcase)
|
|
772
|
+
|
|
773
|
+
utf_name_test(be(bom+dat))
|
|
774
|
+
utf_name_test(be(bom+dat.downcase))
|
|
775
|
+
utf_name_test(be(dat))
|
|
776
|
+
utf_name_test(be(dat.downcase))
|
|
777
|
+
|
|
778
|
+
utf_name_test(le(bom+dat))
|
|
779
|
+
utf_name_test(le(bom+dat.downcase))
|
|
780
|
+
utf_name_test(le(dat))
|
|
781
|
+
utf_name_test(le(dat.downcase))
|
|
782
|
+
end
|
|
783
|
+
|
|
732
784
|
end
|
|
733
785
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: vpim
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: "0.
|
|
4
|
+
version: "0.604"
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sam Roberts
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date: 2008-03-
|
|
12
|
+
date: 2008-03-13 00:00:00 -07:00
|
|
13
13
|
default_executable:
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|