Bug 2276561 - Review Request: rust-onenote_parser - Parser for Microsoft OneNote® files
Summary: Review Request: rust-onenote_parser - Parser for Microsoft OneNote® files
Keywords:
Status: NEW
Alias: None
Product: Fedora
Classification: Fedora
Component: Package Review
Version: rawhide
Hardware: All
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Nobody's working on this, feel free to take it
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On: 2276560
Blocks: 2170297
TreeView+ depends on / blocked
 
Reported: 2024-04-23 03:28 UTC by Orion Poplawski
Modified: 2024-04-25 02:47 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Orion Poplawski 2024-04-23 03:28:20 UTC
Spec URL: https://orion.fedorapeople.org/rust-onenote_parser.spec
SRPM URL: https://orion.fedorapeople.org/rust-onenote_parser-0.3.1-1.fc41.src.rpm
Description:
A parser for Microsoft OneNote® files.

Fedora Account System Username: orion

This is needed for clamav 1.3.0+

Currently is doesn't build due to changes in the widestring dep:

error[E0412]: cannot find type `MissingNulError` in crate `widestring`
  --> src/errors.rs:54:23
   |
54 | impl From<widestring::MissingNulError<u16>> for Error {
   |                       ^^^^^^^^^^^^^^^ not found in `widestring`

error[E0412]: cannot find type `MissingNulError` in crate `widestring`
  --> src/errors.rs:55:30
   |
55 |     fn from(err: widestring::MissingNulError<u16>) -> Self {
   |                              ^^^^^^^^^^^^^^^ not found in `widestring`

error[E0412]: cannot find type `MissingNulError` in crate `widestring`
   --> src/errors.rs:131:26
    |
131 |         err: widestring::MissingNulError<u16>,
    |                          ^^^^^^^^^^^^^^^ not found in `widestring`

warning: unused import: `Cursor`
 --> src/onenote/mod.rs:9:32
  |
9 | use std::io::{BufReader, Read, Cursor};
  |                                ^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

For more information about this error, try `rustc --explain E0412`.

Help with that would be appreciated.

Comment 1 Orion Poplawski 2024-04-23 03:50:38 UTC
So my naive patch is:

diff -up onenote_parser-0.3.1/src/errors.rs.widestring onenote_parser-0.3.1/src/errors.rs
--- onenote_parser-0.3.1/src/errors.rs.widestring       2006-07-23 19:21:28.000000000 -0600
+++ onenote_parser-0.3.1/src/errors.rs  2024-04-22 21:31:52.083264294 -0600
@@ -51,8 +51,8 @@ impl From<std::string::FromUtf16Error> f
     }
 }

-impl From<widestring::MissingNulError<u16>> for Error {
-    fn from(err: widestring::MissingNulError<u16>) -> Self {
+impl From<widestring::error::MissingNulTerminator> for Error {
+    fn from(err: widestring::error::MissingNulTerminator) -> Self {
         ErrorKind::from(err).into()
     }
 }
@@ -128,6 +128,6 @@ pub enum ErrorKind {
     #[error("UTF-16 string is missing null terminator: {err}")]
     Utf16MissingNull {
         #[from]
-        err: widestring::MissingNulError<u16>,
+        err: widestring::error::MissingNulTerminator,
     },
 }
diff -up onenote_parser-0.3.1/src/utils.rs.widestring onenote_parser-0.3.1/src/utils.rs
--- onenote_parser-0.3.1/src/utils.rs.widestring        2006-07-23 19:21:28.000000000 -0600
+++ onenote_parser-0.3.1/src/utils.rs   2024-04-22 21:41:02.878758421 -0600
@@ -12,7 +12,7 @@ impl Utf16ToString for &[u8] {
             .map(|v| u16::from_le_bytes([v[0], v[1]]))
             .collect();

-        let value = U16CString::from_vec_with_nul(data)?;
+        let value = U16CString::from_vec_truncate(data);

         Ok(value.to_string()?)
     }

I dropped the ? because rust said it couldn't be applied but that led to:

error[E0277]: `?` couldn't convert the error to `errors::Error`
  --> src/utils.rs:17:29
   |
17 |         Ok(value.to_string()?)
   |                             ^ the trait `From<Utf16Error>` is not implemented for `errors::Error`, which is required by `std::result::Result<String, errors::Error>: FromResidual<std::result::Result<Infallible, Utf16Error>>`
   |
   = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
   = help: the following other types implement trait `From<T>`:
             <errors::Error as From<uuid::Error>>
             <errors::Error as From<widestring::error::MissingNulTerminator>>
             <errors::Error as From<errors::ErrorKind>>
             <errors::Error as From<std::io::Error>>
             <errors::Error as From<FromUtf16Error>>
   = note: required for `std::result::Result<String, errors::Error>` to implement `FromResidual<std::result::Result<Infallible, Utf16Error>>`


At this point I'll just say I know nothing about rust and will stop.  Help appreciated.

Comment 2 Orion Poplawski 2024-04-25 02:47:35 UTC
Found that upstream has actually merged some fixes so current version builds okay.


Note You need to log in before you can comment on or make changes to this bug.