bson 4.8.2 → 4.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/ext/bson/bson-endian.h +1 -1
- data/ext/bson/bson-native.h +1 -1
- data/ext/bson/bytebuf.c +1 -1
- data/ext/bson/endian.c +1 -1
- data/ext/bson/init.c +1 -1
- data/ext/bson/read.c +67 -19
- data/ext/bson/util.c +1 -1
- data/ext/bson/write.c +1 -1
- data/lib/bson.rb +1 -1
- data/lib/bson/active_support.rb +1 -1
- data/lib/bson/array.rb +7 -2
- data/lib/bson/binary.rb +1 -1
- data/lib/bson/boolean.rb +9 -2
- data/lib/bson/code.rb +1 -1
- data/lib/bson/code_with_scope.rb +9 -2
- data/lib/bson/config.rb +1 -1
- data/lib/bson/date.rb +1 -1
- data/lib/bson/date_time.rb +1 -1
- data/lib/bson/decimal128.rb +1 -1
- data/lib/bson/decimal128/builder.rb +1 -1
- data/lib/bson/document.rb +1 -1
- data/lib/bson/environment.rb +2 -1
- data/lib/bson/error.rb +4 -0
- data/lib/bson/ext_json.rb +1 -1
- data/lib/bson/false_class.rb +1 -1
- data/lib/bson/float.rb +1 -1
- data/lib/bson/hash.rb +7 -2
- data/lib/bson/int32.rb +1 -1
- data/lib/bson/int64.rb +1 -1
- data/lib/bson/integer.rb +1 -1
- data/lib/bson/json.rb +1 -1
- data/lib/bson/max_key.rb +1 -1
- data/lib/bson/min_key.rb +1 -1
- data/lib/bson/nil_class.rb +1 -1
- data/lib/bson/object.rb +1 -1
- data/lib/bson/object_id.rb +1 -1
- data/lib/bson/open_struct.rb +1 -1
- data/lib/bson/regexp.rb +1 -1
- data/lib/bson/registry.rb +1 -1
- data/lib/bson/specialized.rb +1 -1
- data/lib/bson/string.rb +1 -1
- data/lib/bson/symbol.rb +1 -1
- data/lib/bson/time.rb +1 -1
- data/lib/bson/time_with_zone.rb +1 -1
- data/lib/bson/timestamp.rb +1 -1
- data/lib/bson/true_class.rb +1 -1
- data/lib/bson/undefined.rb +1 -1
- data/lib/bson/version.rb +2 -2
- data/spec/bson/array_spec.rb +1 -1
- data/spec/bson/binary_spec.rb +1 -1
- data/spec/bson/binary_uuid_spec.rb +1 -1
- data/spec/bson/boolean_spec.rb +1 -1
- data/spec/bson/code_spec.rb +1 -1
- data/spec/bson/code_with_scope_spec.rb +1 -1
- data/spec/bson/date_spec.rb +1 -1
- data/spec/bson/date_time_spec.rb +1 -1
- data/spec/bson/decimal128_spec.rb +1 -1
- data/spec/bson/document_spec.rb +1 -1
- data/spec/bson/false_class_spec.rb +1 -1
- data/spec/bson/float_spec.rb +1 -1
- data/spec/bson/hash_spec.rb +1 -1
- data/spec/bson/int32_spec.rb +1 -1
- data/spec/bson/int64_spec.rb +1 -1
- data/spec/bson/integer_spec.rb +1 -1
- data/spec/bson/json_spec.rb +1 -1
- data/spec/bson/max_key_spec.rb +1 -1
- data/spec/bson/min_key_spec.rb +1 -1
- data/spec/bson/nil_class_spec.rb +1 -1
- data/spec/bson/object_id_spec.rb +1 -1
- data/spec/bson/object_spec.rb +1 -1
- data/spec/bson/open_struct_spec.rb +1 -1
- data/spec/bson/regexp_spec.rb +1 -1
- data/spec/bson/registry_spec.rb +1 -1
- data/spec/bson/string_spec.rb +1 -1
- data/spec/bson/symbol_spec.rb +1 -1
- data/spec/bson/time_spec.rb +1 -1
- data/spec/bson/time_with_zone_spec.rb +1 -1
- data/spec/bson/timestamp_spec.rb +1 -1
- data/spec/bson/true_class_spec.rb +1 -1
- data/spec/bson/undefined_spec.rb +1 -1
- data/spec/bson_spec.rb +1 -1
- data/spec/runners/common_driver.rb +1 -1
- data/spec/runners/corpus.rb +13 -10
- data/spec/runners/corpus_legacy.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/spec_tests/data/corpus/top.json +0 -4
- data/spec/support/shared_examples.rb +1 -1
- metadata +92 -115
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- metadata.gz.sig +0 -1
data/lib/bson/hash.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2009-
|
1
|
+
# Copyright (C) 2009-2020 MongoDB Inc.
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -108,7 +108,8 @@ module BSON
|
|
108
108
|
buffer.get_hash(**options)
|
109
109
|
else
|
110
110
|
hash = Document.allocate
|
111
|
-
|
111
|
+
start_position = buffer.read_position
|
112
|
+
expected_byte_size = buffer.get_int32
|
112
113
|
while (type = buffer.get_byte) != NULL_BYTE
|
113
114
|
field = buffer.get_cstring
|
114
115
|
cls = BSON::Registry.get(type, field)
|
@@ -121,6 +122,10 @@ module BSON
|
|
121
122
|
end
|
122
123
|
hash.store(field, value)
|
123
124
|
end
|
125
|
+
actual_byte_size = buffer.read_position - start_position
|
126
|
+
if actual_byte_size != expected_byte_size
|
127
|
+
raise Error::BSONDecodeError, "Expected hash to take #{expected_byte_size} bytes but it took #{actual_byte_size} bytes"
|
128
|
+
end
|
124
129
|
hash
|
125
130
|
end
|
126
131
|
end
|
data/lib/bson/int32.rb
CHANGED
data/lib/bson/int64.rb
CHANGED
data/lib/bson/integer.rb
CHANGED
data/lib/bson/json.rb
CHANGED
data/lib/bson/max_key.rb
CHANGED
data/lib/bson/min_key.rb
CHANGED
data/lib/bson/nil_class.rb
CHANGED
data/lib/bson/object.rb
CHANGED
data/lib/bson/object_id.rb
CHANGED
data/lib/bson/open_struct.rb
CHANGED
data/lib/bson/regexp.rb
CHANGED
data/lib/bson/registry.rb
CHANGED
data/lib/bson/specialized.rb
CHANGED
data/lib/bson/string.rb
CHANGED
data/lib/bson/symbol.rb
CHANGED
data/lib/bson/time.rb
CHANGED
data/lib/bson/time_with_zone.rb
CHANGED
data/lib/bson/timestamp.rb
CHANGED
data/lib/bson/true_class.rb
CHANGED
data/lib/bson/undefined.rb
CHANGED
data/lib/bson/version.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2009-
|
1
|
+
# Copyright (C) 2009-2020 MongoDB Inc.
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -13,5 +13,5 @@
|
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
15
|
module BSON
|
16
|
-
VERSION = "4.
|
16
|
+
VERSION = "4.9.0".freeze
|
17
17
|
end
|
data/spec/bson/array_spec.rb
CHANGED
data/spec/bson/binary_spec.rb
CHANGED
data/spec/bson/boolean_spec.rb
CHANGED
data/spec/bson/code_spec.rb
CHANGED
data/spec/bson/date_spec.rb
CHANGED
data/spec/bson/date_time_spec.rb
CHANGED
data/spec/bson/document_spec.rb
CHANGED
data/spec/bson/float_spec.rb
CHANGED
data/spec/bson/hash_spec.rb
CHANGED
data/spec/bson/int32_spec.rb
CHANGED
data/spec/bson/int64_spec.rb
CHANGED
data/spec/bson/integer_spec.rb
CHANGED
data/spec/bson/json_spec.rb
CHANGED
data/spec/bson/max_key_spec.rb
CHANGED
data/spec/bson/min_key_spec.rb
CHANGED
data/spec/bson/nil_class_spec.rb
CHANGED
data/spec/bson/object_id_spec.rb
CHANGED
data/spec/bson/object_spec.rb
CHANGED
data/spec/bson/regexp_spec.rb
CHANGED
data/spec/bson/registry_spec.rb
CHANGED
data/spec/bson/string_spec.rb
CHANGED
data/spec/bson/symbol_spec.rb
CHANGED
data/spec/bson/time_spec.rb
CHANGED
data/spec/bson/timestamp_spec.rb
CHANGED
data/spec/bson/undefined_spec.rb
CHANGED
data/spec/bson_spec.rb
CHANGED
data/spec/runners/corpus.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2016-
|
1
|
+
# Copyright (C) 2016-2020 MongoDB Inc.
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -91,10 +91,19 @@ module BSON
|
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
|
+
class TestBase
|
95
|
+
|
96
|
+
private
|
97
|
+
|
98
|
+
def decode_hex(obj)
|
99
|
+
[ obj ].pack('H*')
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
94
103
|
# Represents a single BSON Corpus test.
|
95
104
|
#
|
96
105
|
# @since 4.2.0
|
97
|
-
class ValidTest
|
106
|
+
class ValidTest < TestBase
|
98
107
|
extend Forwardable
|
99
108
|
|
100
109
|
# Instantiate the new Test.
|
@@ -151,19 +160,13 @@ module BSON
|
|
151
160
|
def relaxed_extjson_doc
|
152
161
|
relaxed_extjson && ::JSON.parse(relaxed_extjson)
|
153
162
|
end
|
154
|
-
|
155
|
-
private
|
156
|
-
|
157
|
-
def decode_hex(obj)
|
158
|
-
[ obj ].pack('H*')
|
159
|
-
end
|
160
163
|
end
|
161
164
|
|
162
|
-
class DecodeErrorTest
|
165
|
+
class DecodeErrorTest < TestBase
|
163
166
|
def initialize(spec, test_params)
|
164
167
|
@spec = spec
|
165
168
|
@description = test_params['description']
|
166
|
-
@bson = test_params['bson']
|
169
|
+
@bson = decode_hex(test_params['bson'])
|
167
170
|
end
|
168
171
|
|
169
172
|
attr_reader :description, :bson
|