Repository: nodejs/node
Pull request: deps: patch resb crate

Original commit message:

    Fix resb on big endian platforms

Fixes: https://github.com/nodejs/node/issues/61808
Refs: https://github.com/unicode-org/icu4x/commit/d310df8b3fb1cbfc551682ccf80f378ed152da8e
Refs: https://github.com/unicode-org/icu4x/pull/7658

---

I'm open to other suggestions about how to patch the vendored crate. This way appears to work, https://ci.nodejs.org/job/node-test-commit-linuxone/53963/ (configured with `--v8-enable-temporal-support`). See https://github.com/nodejs/node/issues/61808 for other methods I have tried (unsuccessfully).

<!--
Before submitting a pull request, please read:

- the CONTRIBUTING guide at https://github.com/nodejs/node/blob/HEAD/CONTRIBUTING.md
- the commit message formatting guidelines at
  https://github.com/nodejs/node/blob/HEAD/doc/contributing/pull-requests.md#commit-message-guidelines

For code changes:
1. Include tests for any bug fixes or new features.
2. Update documentation if relevant.
3. Ensure that `make -j4 test` (UNIX), or `vcbuild test` (Windows) passes.

If you believe this PR should be highlighted in the Node.js CHANGELOG
please add the `notable-change` label.

Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.
-->


Changed files:
filename: deps/crates/Cargo.lock
patch: @@ -243,8 +243,6 @@ dependencies = [
 [[package]]
 name = "resb"
 version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6a067ab3b5ca3b4dc307d0de9cf75f9f5e6ca9717b192b2f28a36c83e5de9e76"
 dependencies = [
  "potential_utf",
  "serde_core",

filename: deps/crates/Cargo.toml
patch: @@ -30,3 +30,7 @@ version = "=0.1.0"
 default-features = false
 # This is necessary to enable a spec-compliance quirk when upgrading to v0.1.2
 # features = ["float64_representable_durations"]
+
+[patch.crates-io]
+# Float https://github.com/unicode-org/icu4x/pull/7658 until crate is updated.
+resb = { path="patches/resb" }

filename: deps/crates/patches/resb/src/binary.rs
patch: @@ -473,7 +473,7 @@ fn read_u16(input: &[u8]) -> Result<(u16, &[u8]), BinaryDeserializerError> {
     let bytes = get_subslice(input, ..core::mem::size_of::<u16>())?
         .try_into()
         .unwrap();
-    let value = u16::from_le_bytes(bytes);
+    let value = u16::from_ne_bytes(bytes);
 
     let rest = get_subslice(input, core::mem::size_of::<u16>()..)?;
     Ok((value, rest))

filename: deps/crates/patches/resb/src/binary/deserializer.rs
patch: @@ -23,6 +23,11 @@ const SYSTEM_CHARSET_FAMILY: CharsetFamily = CharsetFamily::Ascii;
 
 /// Deserializes an instance of type `T` from bytes representing a binary ICU
 /// resource bundle.
+///
+/// The input data must be in the platform's native endianness. ICU4C resource
+/// bundles such as `zoneinfo64.res` are generated in both little endian and
+/// big endian formats; callers must ensure the appropriate format is provided
+/// for the target platform.
 pub fn from_words<'a, T>(input: &'a [u32]) -> Result<T, BinaryDeserializerError>
 where
     T: Deserialize<'a>,
@@ -142,7 +147,7 @@ impl<'de> ResourceTreeDeserializer<'de> {
                 ))
             }
         };
-        let descriptor = u32::from_le_bytes(descriptor);
+        let descriptor = u32::from_ne_bytes(descriptor);
 
         ResDescriptor::try_from(descriptor)
     }
@@ -887,7 +892,7 @@ impl<'de> Resource16BitDeserializer<'de> {
             // exactly 2 bytes.
             #[expect(clippy::unwrap_used)]
             let bytes = <[u8; 2]>::try_from(bytes).unwrap();
-            u16::from_le_bytes(bytes)
+            u16::from_ne_bytes(bytes)
         });
 
         char::decode_utf16(units)
@@ -1255,7 +1260,7 @@ fn read_u32(input: &[u8]) -> Result<(u32, &[u8]), BinaryDeserializerError> {
         ))?
         .try_into()
         .unwrap();
-    let value = u32::from_le_bytes(bytes);
+    let value = u32::from_ne_bytes(bytes);
 
     let rest =
         input

filename: deps/crates/patches/resb/src/binary/header.rs
patch: @@ -113,11 +113,8 @@ impl TryFrom<&[u8]> for BinReprInfo {
         let (size, value) = read_u16(value)?;
         let (reserved_word, value) = read_u16(value)?;
 
-        // While the consumer is responsible for verifying acceptability of most
-        // contents of the repr info, we explicitly depend on little endian data
-        // in order to ensure compatibility with `zerovec`.
         let (endianness, value) = (Endianness::try_from(value[0])?, &value[1..]);
-        if endianness != Endianness::Little {
+        if (endianness == Endianness::Little) != cfg!(target_endian = "little") {
             return Err(BinaryDeserializerError::unsupported_format(
                 "big-endian bundles are not supported",
             ));