k-php-serialize 1.2.0 → 1.2.1
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.
- checksums.yaml +4 -4
- data/lib/php_serialize.rb +15 -6
- data/test.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 09dd982fb92ae4337a82442855f5b54c94c6fbeb
|
4
|
+
data.tar.gz: 06d11823f6271c88036f71f408c82f5ef2af48fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0a0c45b0e12441ce2fc65e1a03e3138f4a351b3d6785748f11a30dc06afa8c46d518dbac781a095be0e23f5647bef7c1f6110f3016fb16406c542046fa16b42
|
7
|
+
data.tar.gz: ac0b7a07f168a32d6d61e66c6398eca3cab4715bd104bbc86e429cacbe75090291fc3d17946a4c5d8cefb5374ed6ec32ea417ed72d1ca4a7d2a52ba415d9ad7d
|
data/lib/php_serialize.rb
CHANGED
@@ -199,8 +199,8 @@ module PHP
|
|
199
199
|
classmap ||= {}
|
200
200
|
|
201
201
|
ret = nil
|
202
|
-
original_encoding = string.encoding
|
203
|
-
string = StringIOReader.new(string.force_encoding('BINARY'))
|
202
|
+
original_encoding = string.encoding if string.respond_to?(:encoding)
|
203
|
+
string = StringIOReader.new(string.respond_to?(:force_encoding) ? string.force_encoding('BINARY') : string)
|
204
204
|
while string.string[string.pos, 32] =~ /^(\w+)\|/ # session_name|serialized_data
|
205
205
|
ret ||= {}
|
206
206
|
string.pos += $&.size
|
@@ -238,7 +238,11 @@ private
|
|
238
238
|
|
239
239
|
if array
|
240
240
|
vals.collect! do |key,value|
|
241
|
-
value.
|
241
|
+
if value.respond_to? :force_encoding
|
242
|
+
value.kind_of?(String) ? value.force_encoding(original_encoding) : value
|
243
|
+
else
|
244
|
+
value
|
245
|
+
end
|
242
246
|
end
|
243
247
|
else
|
244
248
|
if assoc
|
@@ -246,8 +250,12 @@ private
|
|
246
250
|
else
|
247
251
|
val = Hash.new
|
248
252
|
vals.each do |key,value|
|
249
|
-
|
250
|
-
|
253
|
+
|
254
|
+
if value.respond_to? :force_encoding
|
255
|
+
key = key.force_encoding(original_encoding) if key.kind_of?(String)
|
256
|
+
value = value.force_encoding(original_encoding) if value.kind_of?(String)
|
257
|
+
end
|
258
|
+
|
251
259
|
val[key] = value
|
252
260
|
end
|
253
261
|
end
|
@@ -292,7 +300,8 @@ private
|
|
292
300
|
|
293
301
|
when 's' # string, s:length:"data";
|
294
302
|
len = string.read_until(':').to_i + 3 # quotes, separator
|
295
|
-
val = string.read(len)[1...-2]
|
303
|
+
val = string.read(len)[1...-2] # read it, kill useless quotes
|
304
|
+
val = val.force_encoding(original_encoding) if val.respond_to?(:force_encoding)
|
296
305
|
|
297
306
|
when 'i' # integer, i:123
|
298
307
|
val = string.read_until(';').to_i
|
data/test.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: k-php-serialize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keitaroh Kobayashi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: "\tThis module provides two methods: PHP.serialize() and PHP.unserialize(),
|
14
14
|
both\n\tof which should be compatible with the similarly named functions in PHP.\n\n\tIt
|