google-protobuf 4.28.0.rc.1-x86_64-darwin → 4.28.0.rc.2-x86_64-darwin
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.
Potentially problematic release.
This version of google-protobuf might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/ext/google/protobuf_c/convert.c +37 -13
- data/lib/google/3.0/protobuf_c.bundle +0 -0
- data/lib/google/3.1/protobuf_c.bundle +0 -0
- data/lib/google/3.2/protobuf_c.bundle +0 -0
- data/lib/google/3.3/protobuf_c.bundle +0 -0
- data/lib/google/protobuf/ffi/internal/convert.rb +11 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb114de08a2c6982e4b62fca64a3bed2a747d9cf6ae8b9fa25791f527e6df660
|
4
|
+
data.tar.gz: d380a076ab891b5bd8ac3631141da00b089e1f173aa51dafb7c6c357b25a36e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78cfb8262fed527c566b9d9763604488fec6fb7d0d85bcff7bf7615340d09e26f80143ee292a7126354a10c92259b7e91b6fa0f0c4c62872d3d533326b489384
|
7
|
+
data.tar.gz: 9dd367e08f3cae18996a1f5a33acf1cab4232abe8149a0ede73c233ea00397fc60ea6118904f7416efe074b5cf2a07af821399b0a554c25eff18a5c2949e21df
|
@@ -104,6 +104,41 @@ unknownval:
|
|
104
104
|
rb_raise(rb_eRangeError, "Unknown symbol value for enum field '%s'.", name);
|
105
105
|
}
|
106
106
|
|
107
|
+
VALUE Convert_CheckStringUtf8(VALUE str) {
|
108
|
+
VALUE utf8 = rb_enc_from_encoding(rb_utf8_encoding());
|
109
|
+
|
110
|
+
if (rb_obj_encoding(str) == utf8) {
|
111
|
+
// Note: Just because a string is marked as having UTF-8 encoding does
|
112
|
+
// not mean that it is *valid* UTF-8. We have to check separately
|
113
|
+
// whether it is valid.
|
114
|
+
if (rb_enc_str_coderange(str) == ENC_CODERANGE_BROKEN) {
|
115
|
+
// TODO: For now
|
116
|
+
// we only warn for this case. We will remove the warning and throw an
|
117
|
+
// exception below in the 30.x release
|
118
|
+
|
119
|
+
rb_warn(
|
120
|
+
"String is invalid UTF-8. This will be an error in a future "
|
121
|
+
"version.");
|
122
|
+
// VALUE exc = rb_const_get_at(
|
123
|
+
// rb_cEncoding, rb_intern("InvalidByteSequenceError"));
|
124
|
+
// rb_raise(exc, "String is invalid UTF-8");
|
125
|
+
}
|
126
|
+
} else {
|
127
|
+
// Note: this will not duplicate underlying string data unless
|
128
|
+
// necessary.
|
129
|
+
//
|
130
|
+
// This will throw an exception if the conversion cannot be performed:
|
131
|
+
// - Encoding::UndefinedConversionError if certain characters cannot be
|
132
|
+
// converted to UTF-8.
|
133
|
+
// - Encoding::InvalidByteSequenceError if certain characters were invalid
|
134
|
+
// in the source encoding.
|
135
|
+
str = rb_str_encode(str, utf8, 0, Qnil);
|
136
|
+
PBRUBY_ASSERT(rb_enc_str_coderange(str) != ENC_CODERANGE_BROKEN);
|
137
|
+
}
|
138
|
+
|
139
|
+
return str;
|
140
|
+
}
|
141
|
+
|
107
142
|
upb_MessageValue Convert_RubyToUpb(VALUE value, const char* name,
|
108
143
|
TypeInfo type_info, upb_Arena* arena) {
|
109
144
|
upb_MessageValue ret;
|
@@ -137,8 +172,7 @@ upb_MessageValue Convert_RubyToUpb(VALUE value, const char* name,
|
|
137
172
|
}
|
138
173
|
break;
|
139
174
|
}
|
140
|
-
case kUpb_CType_String:
|
141
|
-
VALUE utf8 = rb_enc_from_encoding(rb_utf8_encoding());
|
175
|
+
case kUpb_CType_String:
|
142
176
|
if (rb_obj_class(value) == rb_cSymbol) {
|
143
177
|
value = rb_funcall(value, rb_intern("to_s"), 0);
|
144
178
|
} else if (!rb_obj_is_kind_of(value, rb_cString)) {
|
@@ -147,19 +181,9 @@ upb_MessageValue Convert_RubyToUpb(VALUE value, const char* name,
|
|
147
181
|
rb_class2name(CLASS_OF(value)));
|
148
182
|
}
|
149
183
|
|
150
|
-
|
151
|
-
// Note: this will not duplicate underlying string data unless
|
152
|
-
// necessary.
|
153
|
-
value = rb_str_encode(value, utf8, 0, Qnil);
|
154
|
-
|
155
|
-
if (rb_enc_str_coderange(value) == ENC_CODERANGE_BROKEN) {
|
156
|
-
rb_raise(rb_eEncodingError, "String is invalid UTF-8");
|
157
|
-
}
|
158
|
-
}
|
159
|
-
|
184
|
+
value = Convert_CheckStringUtf8(value);
|
160
185
|
ret.str_val = Convert_StringData(value, arena);
|
161
186
|
break;
|
162
|
-
}
|
163
187
|
case kUpb_CType_Bytes: {
|
164
188
|
VALUE bytes = rb_enc_from_encoding(rb_ascii8bit_encoding());
|
165
189
|
if (rb_obj_class(value) != rb_cString) {
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -33,11 +33,18 @@ module Google
|
|
33
33
|
return_value[:bool_val] = value
|
34
34
|
when :string
|
35
35
|
raise TypeError.new "Invalid argument for string field '#{name}' (given #{value.class})." unless value.is_a?(String) or value.is_a?(Symbol)
|
36
|
-
|
36
|
+
value = value.to_s if value.is_a?(Symbol)
|
37
|
+
if value.encoding == Encoding::UTF_8
|
38
|
+
unless value.valid_encoding?
|
39
|
+
# TODO:
|
40
|
+
# For now we only warn for this case. We will remove the
|
41
|
+
# warning and throw an exception below in the 30.x release
|
42
|
+
warn "String is invalid UTF-8. This will be an error in a future version."
|
43
|
+
# raise Encoding::InvalidByteSequenceError.new "String is invalid UTF-8"
|
44
|
+
end
|
45
|
+
string_value = value
|
46
|
+
else
|
37
47
|
string_value = value.to_s.encode("UTF-8")
|
38
|
-
rescue Encoding::UndefinedConversionError
|
39
|
-
# TODO - why not include the field name here?
|
40
|
-
raise Encoding::UndefinedConversionError.new "String is invalid UTF-8"
|
41
48
|
end
|
42
49
|
return_value[:str_val][:size] = string_value.bytesize
|
43
50
|
return_value[:str_val][:data] = Google::Protobuf::FFI.arena_malloc(arena, string_value.bytesize)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-protobuf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.28.0.rc.
|
4
|
+
version: 4.28.0.rc.2
|
5
5
|
platform: x86_64-darwin
|
6
6
|
authors:
|
7
7
|
- Protobuf Authors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-07
|
11
|
+
date: 2024-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler-dock
|
@@ -190,7 +190,7 @@ homepage: https://developers.google.com/protocol-buffers
|
|
190
190
|
licenses:
|
191
191
|
- BSD-3-Clause
|
192
192
|
metadata:
|
193
|
-
source_code_uri: https://github.com/protocolbuffers/protobuf/tree/v4.28.0-
|
193
|
+
source_code_uri: https://github.com/protocolbuffers/protobuf/tree/v4.28.0-rc2/ruby
|
194
194
|
post_install_message:
|
195
195
|
rdoc_options: []
|
196
196
|
require_paths:
|