CFPropertyList 2.0.11 → 2.0.12
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/lib/rbBinaryCFPropertyList.rb +42 -14
- data/lib/rbCFPropertyList.rb +1 -1
- data/lib/rbCFTypes.rb +1 -1
- data/lib/rbXMLCFPropertyList.rb +1 -1
- metadata +3 -8
@@ -141,7 +141,15 @@ module CFPropertyList
|
|
141
141
|
val = val[0]
|
142
142
|
when 3
|
143
143
|
hiword,loword = buff.unpack("NN")
|
144
|
-
|
144
|
+
if (hiword & 0x80000000) != 0
|
145
|
+
# 8 byte integers are always signed, and are negative when bit 63 is
|
146
|
+
# set. Decoding into either a Fixnum or Bignum is tricky, however,
|
147
|
+
# because the size of a Fixnum varies among systems, and Ruby
|
148
|
+
# doesn't consider the number to be negative, and won't sign extend.
|
149
|
+
val = -(2**63 - ((hiword & 0x7fffffff) << 32 | loword))
|
150
|
+
else
|
151
|
+
val = hiword << 32 | loword
|
152
|
+
end
|
145
153
|
end
|
146
154
|
|
147
155
|
return CFInteger.new(val);
|
@@ -226,8 +234,15 @@ module CFPropertyList
|
|
226
234
|
def Binary.charset_strlen(str,charset="UTF-8")
|
227
235
|
return str.length if str.respond_to?("encode")
|
228
236
|
|
229
|
-
|
230
|
-
|
237
|
+
utf8_str = Iconv.conv("UTF-8",charset,str)
|
238
|
+
size = utf8_str.scan(/./mu).size
|
239
|
+
|
240
|
+
# UTF-16 code units in the range D800-DBFF are the beginning of
|
241
|
+
# a surrogate pair, and count as one additional character for
|
242
|
+
# length calculation.
|
243
|
+
str.split('').each_slice(2) { |pair| size += 1 if ("\xd8".."\xdb").include?(pair[0]) } if charset =~ /^UTF-16/
|
244
|
+
|
245
|
+
return size
|
231
246
|
end
|
232
247
|
|
233
248
|
# Read a unicode string value, coded as UTF-16BE
|
@@ -374,11 +389,16 @@ module CFPropertyList
|
|
374
389
|
|
375
390
|
# calculate how many bytes are needed to save +count+
|
376
391
|
def Binary.bytes_needed(count)
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
nbytes
|
381
|
-
|
392
|
+
if count < 2**8
|
393
|
+
nbytes = 1
|
394
|
+
elsif count < 2**16
|
395
|
+
nbytes = 2
|
396
|
+
elsif count < 2**32
|
397
|
+
nbytes = 4
|
398
|
+
elsif count < 2**64
|
399
|
+
nbytes = 8
|
400
|
+
else
|
401
|
+
raise CFFormatError.new("Data size too large: #{count}")
|
382
402
|
end
|
383
403
|
|
384
404
|
return nbytes
|
@@ -388,12 +408,20 @@ module CFPropertyList
|
|
388
408
|
def Binary.int_bytes(int)
|
389
409
|
intbytes = ""
|
390
410
|
|
391
|
-
if(int
|
392
|
-
|
393
|
-
|
394
|
-
|
411
|
+
if(int >= 0) then
|
412
|
+
if (int <= 0xFF) then
|
413
|
+
intbytes = "\x10"+[int].pack("c") # 1 byte integer
|
414
|
+
elsif(int <= 0xFFFF) then
|
415
|
+
intbytes = "\x11"+[int].pack("n") # 2 byte integer
|
416
|
+
elsif(int <= 0xFFFFFFFF) then
|
417
|
+
intbytes = "\x12"+[int].pack("N") # 4 byte integer
|
418
|
+
elsif(int <= 0x7FFFFFFFFFFFFFFF)
|
419
|
+
intbytes = "\x13"+[int >> 32, int & 0xFFFFFFFF].pack("NN") # 8 byte integer
|
420
|
+
else
|
421
|
+
raise CFFormatError.new("Integer too large: #{int}")
|
422
|
+
end
|
395
423
|
else
|
396
|
-
intbytes = "\
|
424
|
+
intbytes = "\x13"+[int >> 32, int & 0xFFFFFFFF].pack("NN") # 8 byte integer
|
397
425
|
end
|
398
426
|
|
399
427
|
return intbytes;
|
@@ -519,8 +547,8 @@ module CFPropertyList
|
|
519
547
|
end
|
520
548
|
|
521
549
|
if(utf16) then
|
522
|
-
bdata = Binary.type_bytes("6",Binary.charset_strlen(val,"UTF-8")) # 6 is 0110, unicode string (utf16be)
|
523
550
|
val = Binary.charset_convert(val,"UTF-8","UTF-16BE")
|
551
|
+
bdata = Binary.type_bytes("6",Binary.charset_strlen(val,"UTF-16BE")) # 6 is 0110, unicode string (utf16be)
|
524
552
|
|
525
553
|
val.force_encoding("ASCII-8BIT") if val.respond_to?("encode")
|
526
554
|
@object_table[saved_object_count] = bdata + val
|
data/lib/rbCFPropertyList.rb
CHANGED
@@ -109,7 +109,7 @@ module CFPropertyList
|
|
109
109
|
return CFBoolean.new(object)
|
110
110
|
elsif(object.is_a?(String)) then
|
111
111
|
return object.blob? ? CFData.new(object, CFData::DATA_RAW) : CFString.new(object)
|
112
|
-
elsif(object.
|
112
|
+
elsif(object.respond_to?(:read)) then
|
113
113
|
return CFData.new(object.read(), CFData::DATA_RAW)
|
114
114
|
elsif(object.is_a?(Time) || object.is_a?(DateTime) || object.is_a?(Date)) then
|
115
115
|
return CFDate.new(object)
|
data/lib/rbCFTypes.rb
CHANGED
@@ -166,7 +166,7 @@ module CFPropertyList
|
|
166
166
|
|
167
167
|
# get base64 encoded value
|
168
168
|
def encoded_value
|
169
|
-
@value ||= Base64.encode64(@raw_value)
|
169
|
+
@value ||= "\n#{Base64.encode64(@raw_value).gsub("\n", '').scan(/.{1,76}/).join("\n")}\n"
|
170
170
|
end
|
171
171
|
|
172
172
|
# get base64 decoded value
|
data/lib/rbXMLCFPropertyList.rb
CHANGED
@@ -37,7 +37,7 @@ module CFPropertyList
|
|
37
37
|
|line|
|
38
38
|
str1 << line
|
39
39
|
unless(first) then
|
40
|
-
str1 << "<!DOCTYPE plist PUBLIC \"-//Apple
|
40
|
+
str1 << "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n" if line =~ /^\s*<\?xml/
|
41
41
|
end
|
42
42
|
|
43
43
|
first = true
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: CFPropertyList
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 25
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 2
|
8
7
|
- 0
|
9
|
-
-
|
10
|
-
version: 2.0.
|
8
|
+
- 12
|
9
|
+
version: 2.0.12
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Christian Kruse
|
@@ -15,7 +14,7 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2010-08
|
17
|
+
date: 2010-09-08 00:00:00 +02:00
|
19
18
|
default_executable:
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
@@ -26,7 +25,6 @@ dependencies:
|
|
26
25
|
requirements:
|
27
26
|
- - ">="
|
28
27
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 19
|
30
28
|
segments:
|
31
29
|
- 1
|
32
30
|
- 1
|
@@ -42,7 +40,6 @@ dependencies:
|
|
42
40
|
requirements:
|
43
41
|
- - ">="
|
44
42
|
- !ruby/object:Gem::Version
|
45
|
-
hash: 3
|
46
43
|
segments:
|
47
44
|
- 0
|
48
45
|
- 7
|
@@ -80,7 +77,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
80
77
|
requirements:
|
81
78
|
- - ">="
|
82
79
|
- !ruby/object:Gem::Version
|
83
|
-
hash: 3
|
84
80
|
segments:
|
85
81
|
- 0
|
86
82
|
version: "0"
|
@@ -89,7 +85,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
85
|
requirements:
|
90
86
|
- - ">="
|
91
87
|
- !ruby/object:Gem::Version
|
92
|
-
hash: 3
|
93
88
|
segments:
|
94
89
|
- 0
|
95
90
|
version: "0"
|