A fuzz test discovered that our JSON parser will accept "overlong" UTF-8
characters, i.e. encodings that use more bytes than necessary. We should reject
these overlong encodings, because they are not considered valid.
To fix this problem, I updated the JSON lexer to rely on utf8_range for
checking UTF-8 validity. This way, the lexer does not need to do any UTF-8
validation of its own, but just has to interpret the UTF-8 enough to know how
many bytes to read for each character.
PiperOrigin-RevId: 599657903
This is already emitted a few lines before in previous has_reflection_ condition and results in compiler -Wredundant-decls warnings.
Fixes#14979
PiperOrigin-RevId: 599610424
The upb libraries can also be accessed from Kotlin Native code, which
understands only C headers, not C++. By adding these `#ifdef` directives, the
C++ headers will appear to be empty in that case.
PiperOrigin-RevId: 599593286
feature.
The existing solution does not work well in the face of shared libraries when
section merging can't be done via linker script.
The new solution has two separate modes of action:
- When sections are not merged, we directly put the default instance pointer
in the file_default_instances array.
- When sections are merged, the file_default_instances array is all `nullptr`
and we inject them at runtime via `InitWeakDefaults`. All the surviving
default instances are in this section with extra information to be able to
iterate the section.
PiperOrigin-RevId: 599558000
We want to return $pb$::FieldEntry<'_, $msg_type$> for msg_mut accessors as opposed to the current state (returning $Msg$Mut directly).
In this CL, we pave the way to implementing field entry returns.
We introduce { MessagePresentMutData, MessageAbsentMutData } and impl { ProxiedWithRawVTable, ProxiedWithRawOptionalVTable }. I initially tried a blanket impl approach, but it collided with the already existing PrimitiveVTable constructs; perhaps worth revisiting post 0.6.
In a followup, we'll flesh out the bodies. Lastly, we'll perform the swapover by
replacing $field$_mut with $field$_entry, updating all related tests.
PiperOrigin-RevId: 599282850
- Only prepend r# to fields when needed instead of always
- Append '__mangled_because_symbol_is_a_rust_raw_identifier' to names like 'Self' which can't be used legally even with an r# prefix
Also use the same check to prepend r# on:
- Message names (eg `message Self {}`)
- oneof names
- oneof case names
- enum names
- enum case names
- module names (e.g. 'package google.type')
PiperOrigin-RevId: 599153141
We now support fields with bytes as map values e.g. map<i32, bytes>. The implementation for the C++ runtime was straightforward. The majority of the changes in this CL are about the UPB runtime. In UPB, when we insert Rust bytes/string into the map we need to first copy the bytes onto the maps arena. To support this I have rewritten the macro that implements the ProxiedInMapValue types. I refactored the functionality to convert between UPB and Rust types into the 'UpbTypeConversions' trait. This trait has a function 'to_message_value_if_required' which does the copying for bytes and strings.
PiperOrigin-RevId: 599118416
This adds private methods of:
-- .raw_msg() to Msg+MsgMut+MsgView
-- .raw_arena() to Msg+MsgMut [upb kernel only]
And updates the accessors to use the self.raw_msg() / self.raw_arena().
A couple more things will need to be changed before the accessors can be verbatim reused in Msg/MsgView/MsgMut which will be mailed separately.
PiperOrigin-RevId: 598869392