1
Fork 0
mirror of https://https.git.savannah.gnu.org/git/guix.git/ synced 2025-07-13 18:40:57 +02:00

gnu: Add rust-onenote-parser-for-clamav.

* gnu/packages/crates-io.scm (rust-onenote-parser-for-clamav): New
variable.
* gnu/packages/patches/rust-onenote-parser-for-clamav-deps.patch
* gnu/packages/patches/rust-onenote-parser-for-clamav-parse-in-memory-buffer.patch
* gnu/packages/patches/rust-onenote-parser-for-clamav-property-type.patch
Add patches here...
* gnu/local.mk: ...and here.

Signed-off-by: Efraim Flashner <efraim@flashner.co.il>
Change-Id: I6c2bb1d7afef8328317a54dcfee9204614864e64
This commit is contained in:
Nicolas Graves 2024-11-06 00:14:52 +01:00 committed by Efraim Flashner
parent 309da5dba0
commit 02cd7d7586
No known key found for this signature in database
GPG key ID: 41AAE7DCCA3D8351
5 changed files with 200 additions and 0 deletions

View file

@ -2193,6 +2193,9 @@ dist_patch_DATA = \
%D%/packages/patches/rust-ndarray-0.13-remove-blas-src.patch \
%D%/packages/patches/rust-ndarray-0.14-remove-blas-src.patch \
%D%/packages/patches/rust-nettle-disable-vendor.patch \
%D%/packages/patches/rust-onenote-parser-for-clamav-deps.patch \
%D%/packages/patches/rust-onenote-parser-for-clamav-parse-in-memory-buffer.patch \
%D%/packages/patches/rust-onenote-parser-for-clamav-property-type.patch \
%D%/packages/patches/rust-poem-1-fewer-deps.patch \
%D%/packages/patches/rust-rspec-1-remove-clippy.patch \
%D%/packages/patches/rust-trash-2-update-windows.patch \

View file

@ -48830,6 +48830,33 @@ safe unsynchronized access.")
"This package provides a parser for Microsoft OneNote files.")
(license license:mpl2.0)))
(define-public rust-onenote-parser-for-clamav
(package
(inherit rust-onenote-parser-0.3)
(name "rust-onenote-parser-for-clamav")
(source (origin
(inherit (package-source rust-onenote-parser-0.3))
(patches
(search-patches
"rust-onenote-parser-for-clamav-deps.patch"
"rust-onenote-parser-for-clamav-parse-in-memory-buffer.patch"
"rust-onenote-parser-for-clamav-property-type.patch"))
(snippet #~(begin
(delete-file "Cargo.toml")
(rename-file "Cargo.toml.orig" "Cargo.toml")))))
(arguments
`(#:cargo-inputs
(("rust-bytes" ,rust-bytes-1)
("rust-encoding-rs" ,rust-encoding-rs-0.8)
("rust-enum-primitive-derive" ,rust-enum-primitive-derive-0.2)
("rust-itertools" ,rust-itertools-0.10)
("rust-num-traits" ,rust-num-traits-0.2)
("rust-paste" ,rust-paste-1)
("rust-thiserror" ,rust-thiserror-1)
("rust-uuid" ,rust-uuid-1)
("rust-widestring" ,rust-widestring-1))
#:cargo-development-inputs (("rust-insta" ,rust-insta-1))))))
(define-public rust-onig-6
(package
(name "rust-onig")

View file

@ -0,0 +1,88 @@
From f940d8c8fa087554583158d50df071af89c516db Mon Sep 17 00:00:00 2001
From: Simon Lamon <32477463+silamon@users.noreply.github.com>
Date: Sat, 19 Nov 2022 20:32:07 +0100
Subject: [PATCH] chore: upgrade dependencies (#9)
Co-authored-by: Markus Siemens <markus@m-siemens.de>
---
Cargo.toml.orig | 8 ++++----
src/errors.rs | 6 +++---
src/reader.rs | 2 +-
src/utils.rs | 5 ++---
4 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
index 9afddd0..e302436 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -14,15 +14,15 @@ categories = ["parser-implementations"]
backtrace = []
[dependencies]
-bytes = "0.5"
+bytes = "1.2.0"
encoding_rs = "0.8.31"
enum-primitive-derive = "0.2.2"
-itertools = "0.9.0"
+itertools = "0.10.3"
num-traits = "0.2"
paste = "1.0"
thiserror = "1.0"
-uuid = "0.8"
-widestring = "0.4.3"
+uuid = "1.1.2"
+widestring = "1.0.2"
[dev-dependencies]
insta = "1.21.1"
diff --git a/src/errors.rs b/src/errors.rs
index 91477b3..50079a3 100644
--- a/src/errors.rs
+++ b/src/errors.rs
@@ -51,8 +51,8 @@ impl From<std::string::FromUtf16Error> for Error {
}
}
-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 --git a/src/reader.rs b/src/reader.rs
index 64730d0..318c280 100644
--- a/src/reader.rs
+++ b/src/reader.rs
@@ -40,7 +40,7 @@ impl<'a> Reader<'a> {
}
pub(crate) fn bytes(&self) -> &[u8] {
- self.0.bytes()
+ self.0.chunk()
}
pub(crate) fn remaining(&self) -> usize {
diff --git a/src/utils.rs b/src/utils.rs
index fd77181..074ff50 100644
--- a/src/utils.rs
+++ b/src/utils.rs
@@ -12,8 +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)?;
-
- Ok(value.to_string()?)
+ let value = U16CString::from_vec_truncate(data);
+ Ok(value.to_string().unwrap())
}
}

View file

@ -0,0 +1,52 @@
From 8b450447e58143004b68dd21c11b710fdb79be92 Mon Sep 17 00:00:00 2001
From: Micah Snyder <micasnyd@cisco.com>
Date: Mon, 3 Jul 2023 21:44:57 -0700
Subject: [PATCH] Add ability to parse section from in memory buffer
Resolves: https://github.com/msiemens/onenote.rs/issues/12
---
src/onenote/mod.rs | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/src/onenote/mod.rs b/src/onenote/mod.rs
index de172c9..8bcb62b 100644
--- a/src/onenote/mod.rs
+++ b/src/onenote/mod.rs
@@ -6,8 +6,9 @@ use crate::onestore::parse_store;
use crate::reader::Reader;
use std::ffi::OsStr;
use std::fs::File;
-use std::io::{BufReader, Read};
+use std::io::{BufReader, Read, Cursor};
use std::path::Path;
+use std::str::FromStr;
pub(crate) mod content;
pub(crate) mod embedded_file;
@@ -76,6 +77,26 @@ impl Parser {
Ok(Notebook { entries: sections })
}
+ /// Parse a OneNote section buffer.
+ ///
+ /// The `data` argument must contain a OneNote section.
+ pub fn parse_section_buffer(&mut self, data: &[u8], file_name: &Path) -> Result<Section> {
+ let packaging = OneStorePackaging::parse(&mut Reader::new(data))?;
+ let store = parse_store(&packaging)?;
+
+ if store.schema_guid() != guid!({1F937CB4-B26F-445F-B9F8-17E20160E461}) {
+ return Err(ErrorKind::NotASectionFile {
+ file: file_name.to_string_lossy().into_owned(),
+ }
+ .into());
+ }
+
+ section::parse_section(
+ store,
+ file_name.to_string_lossy().into_owned(),
+ )
+ }
+
/// Parse a OneNote section file.
///
/// The `path` argument must point to a `.one` file that contains a

View file

@ -0,0 +1,30 @@
From 29c08532252b917543ff268284f926f30876bb79 Mon Sep 17 00:00:00 2001
From: Matt Jolly <Matt.Jolly@footclan.ninja>
Date: Mon, 24 Jun 2024 17:34:05 +1000
Subject: [PATCH] PropertType: Specify type for custom discriminant values
We use custom discriminant values for enum variants for "PropertType" without specifying the type.
This causes it to default to "isize" which on 64bit platforms is big enough to hold the 32bit constants,
but causes overflow when isize is 32bit.
This issue was uncovered due to build failures on arm for Gentoo Linux as a dependency of ClamAV.
Bug: https://bugs.gentoo.org/927214
Signed-off-by: Matt Jolly <kangie@gentoo.org>
Co-authored-by: Steven Newbury <steve@snewbury.org.uk>
---
src/one/property/mod.rs | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/one/property/mod.rs b/src/one/property/mod.rs
index 42841c6..fcc0481 100644
--- a/src/one/property/mod.rs
+++ b/src/one/property/mod.rs
@@ -23,6 +23,7 @@ mod references;
pub(crate) mod simple;
pub(crate) mod time;
+#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq)]
#[allow(dead_code)]
#[allow(clippy::enum_clike_unportable_variant)]