Skip to content

Commit f056f0f

Browse files
authored
Merge pull request #299 from mattsse/ef-deps
Update dedendencies
2 parents ed21356 + 9348ba9 commit f056f0f

File tree

13 files changed

+235
-103
lines changed

13 files changed

+235
-103
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,4 @@ jobs:
8484
- uses: actions/checkout@v6
8585
- uses: dtolnay/rust-toolchain@stable
8686
- name: Check examples
87-
run: cargo check --examples --features fetcher
87+
run: cargo check --examples --features fetcher,zip8,rustls

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1818
- Bump CDP to `r1566079`
1919
- Use a struct `Arg` for arguments to combine flags automatically
2020
- Browser process no longer inherits stdout
21+
- Update `reqwest` to v0.13
22+
- Update `thiserror` to v2
23+
- Update `heck` to v0.5
24+
- Add support for `zip` v8 and make it default
2125

2226
### Added
2327

Cargo.toml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "chromiumoxide"
3-
version = "0.8.0"
3+
version = "0.9.0"
44
rust-version = "1.85"
55
autotests = false
66
authors = ["Matthias Seitz <matthias.seitz@outlook.de>"]
@@ -14,15 +14,15 @@ keywords = ["chrome", "chromedriver", "puppeteer", "automation"]
1414
categories = ["web-programming", "api-bindings", "development-tools::testing"]
1515

1616
[dependencies]
17-
async-tungstenite = { version = "0.32.0", features = ["tokio-runtime"] }
17+
async-tungstenite = { version = "0.32", features = ["tokio-runtime"] }
1818
serde = { version = "1", features = ["derive"] }
1919
futures = "0.3"
20-
chromiumoxide_types = { path = "chromiumoxide_types", version = "0.8" }
21-
chromiumoxide_cdp = { path = "chromiumoxide_cdp", version = "0.8" }
22-
chromiumoxide_fetcher = { path = "chromiumoxide_fetcher", version = "0.8", default-features = false, optional = true }
20+
chromiumoxide_types = { path = "chromiumoxide_types", version = "0.9" }
21+
chromiumoxide_cdp = { path = "chromiumoxide_cdp", version = "0.9" }
22+
chromiumoxide_fetcher = { path = "chromiumoxide_fetcher", version = "0.9", default-features = false, optional = true }
2323
serde_json = "1"
2424
which = "8"
25-
thiserror = "1"
25+
thiserror = "2"
2626
url = "2"
2727
base64 = "0.22"
2828
fnv = "1"
@@ -39,10 +39,10 @@ tracing = "0.1"
3939
pin-project-lite = "0.2"
4040
dunce = "1"
4141
bytes = { version = "1", features = ["serde"], optional = true }
42-
reqwest = { version = "0.12", default-features = false }
42+
reqwest = { version = "0.13", default-features = false }
4343

4444
[target.'cfg(windows)'.dependencies]
45-
windows-registry = "0.5"
45+
windows-registry = "0.6"
4646

4747
[dev-dependencies]
4848
quote = "1"
@@ -55,14 +55,16 @@ tokio = { version = "1", features = ["rt-multi-thread", "time", "macros"] }
5555
default = ["bytes"]
5656
fetcher = ["chromiumoxide_fetcher"]
5757
bytes = ["dep:bytes"]
58-
serde0 = []
5958

6059
rustls = ["chromiumoxide_fetcher/rustls"]
6160
native-tls = ["chromiumoxide_fetcher/native-tls"]
6261

62+
zip0 = ["chromiumoxide_fetcher/zip0"]
63+
zip8 = ["chromiumoxide_fetcher/zip8"]
64+
6365
[[example]]
6466
name = "fetcher"
65-
required-features = ["fetcher"]
67+
required-features = ["fetcher", "zip8", "rustls"]
6668

6769
[[test]]
6870
name = "chromiumoxide_tests"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ All Events are bundled in single enum (`CdpEvent`)
8484
By default `chromiumoxide` will try to find an installed version of chromium on the computer it runs on.
8585
It is possible to download and install one automatically for some platforms using the `fetcher` feature.
8686

87-
You need to enable either the `rustls` or the `native-tls` feature to allow the fetcher to download binaries.
87+
You need to enable either the `rustls` or the `native-tls` feature and the `zip0` or `zip8` feature to allow the fetcher to download binaries.
8888

8989
```rust
9090
use std::path::Path;

chromiumoxide_cdp/Cargo.toml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "chromiumoxide_cdp"
3-
version = "0.8.0"
3+
version = "0.9.0"
44
authors = ["Matthias Seitz <matthias.seitz@outlook.de>"]
55
edition = "2024"
66
rust-version = "1.85"
@@ -11,16 +11,15 @@ repository = "https://github.com/mattsse/chromiumoxide"
1111
readme = "../README.md"
1212
include = ["src/**/*", "*.pdl", "LICENSE-*"]
1313

14-
[features]
15-
serde0 = []
1614

1715
[dev-dependencies]
18-
chromiumoxide_pdl = { path = "../chromiumoxide_pdl", version = "0.8" }
19-
ureq = "2.10.0"
20-
tempfile = "3.10.1"
16+
chromiumoxide_pdl = { path = "../chromiumoxide_pdl", version = "0.9" }
17+
reqwest = { version = "0.13", features = ["rustls"], default-features = false }
18+
tempfile = "3.10"
19+
tokio = { version = "1", features = ["rt", "fs", "process", "macros"] }
2120

2221
[dependencies]
23-
chromiumoxide_pdl = { path = "../chromiumoxide_pdl", version = "0.8" }
24-
chromiumoxide_types = { path = "../chromiumoxide_types", version = "0.8" }
22+
chromiumoxide_pdl = { path = "../chromiumoxide_pdl", version = "0.9" }
23+
chromiumoxide_types = { path = "../chromiumoxide_types", version = "0.9" }
2524
serde = { version = "1", features = ["derive"] }
2625
serde_json = "1"

chromiumoxide_cdp/tests/generate.rs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ fn generated_code_is_fresh() {
3535
}
3636

3737
/// Check that the PDL files are up to date
38-
#[test]
39-
fn pdl_is_fresh() {
38+
#[tokio::test]
39+
async fn pdl_is_fresh() {
4040
const BASE_URL: &str = "https://raw.githubusercontent.com/ChromeDevTools/devtools-protocol";
4141

4242
let dir = Path::new(env!("CARGO_MANIFEST_DIR"));
@@ -48,12 +48,13 @@ fn pdl_is_fresh() {
4848
.unwrap_or_else(|_| dir.join("pdl/js_protocol.pdl"));
4949

5050
let js_proto_old = fs::read_to_string(&js_proto).unwrap_or_default();
51-
let js_proto_new = ureq::get(&format!(
51+
let js_proto_new = reqwest::get(&format!(
5252
"{BASE_URL}/{CURRENT_REVISION}/pdl/js_protocol.pdl",
5353
))
54-
.call()
54+
.await
5555
.unwrap()
56-
.into_string()
56+
.text()
57+
.await
5758
.unwrap();
5859
assert!(js_proto_new.contains("The Chromium Authors"));
5960

@@ -68,12 +69,13 @@ fn pdl_is_fresh() {
6869
.unwrap_or_else(|_| dir.join("pdl/browser_protocol.pdl"));
6970

7071
let browser_proto_old = fs::read_to_string(&browser_proto).unwrap_or_default();
71-
let browser_proto_new = ureq::get(&format!(
72+
let browser_proto_new = reqwest::get(&format!(
7273
"{BASE_URL}/{CURRENT_REVISION}/pdl/browser_protocol.pdl"
7374
))
74-
.call()
75+
.await
7576
.unwrap()
76-
.into_string()
77+
.text()
78+
.await
7779
.unwrap();
7880
assert!(browser_proto_new.contains("The Chromium Authors"));
7981

@@ -95,11 +97,13 @@ fn pdl_is_fresh() {
9597
let include_path = dir.join("pdl").join(include);
9698

9799
let include_proto_old = fs::read_to_string(&include_path).unwrap_or_default();
98-
let include_proto_new = ureq::get(&format!("{BASE_URL}/{CURRENT_REVISION}/pdl/{include}"))
99-
.call()
100-
.unwrap()
101-
.into_string()
102-
.unwrap();
100+
let include_proto_new =
101+
reqwest::get(&format!("{BASE_URL}/{CURRENT_REVISION}/pdl/{include}"))
102+
.await
103+
.unwrap()
104+
.text()
105+
.await
106+
.unwrap();
103107
assert!(include_proto_new.contains("The Chromium Authors"));
104108

105109
if include_proto_new != include_proto_old {

chromiumoxide_fetcher/Cargo.toml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "chromiumoxide_fetcher"
3-
version = "0.8.0"
3+
version = "0.9.0"
44
authors = ["Matthias Seitz <matthias.seitz@outlook.de>"]
55
edition = "2024"
66
rust-version = "1.85"
@@ -22,26 +22,29 @@ path = "tests/lib.rs"
2222
harness = true
2323

2424
[dev-dependencies]
25-
reqwest = { version = "0.12", features = [
26-
"rustls-tls",
27-
], default-features = false }
25+
reqwest = { version = "0.13", features = ["rustls"], default-features = false }
2826
tokio = { version = "1", features = ["rt", "fs", "process", "macros"] }
2927

3028
[dependencies]
31-
thiserror = "1"
29+
thiserror = "2"
3230
anyhow = "1"
3331
directories = "6"
3432
serde = { version = "1", features = ["derive"] }
3533
tracing = "0.1"
36-
zip = { version = "0.6", default-features = false, features = ["deflate"] }
34+
zip0 = { package = "zip", version = "0.6", default-features = false, features = [
35+
"deflate",
36+
], optional = true }
37+
zip8 = { package = "zip", version = "8", default-features = false, features = [
38+
"deflate-flate2-zlib-rs",
39+
], optional = true }
3740
tokio = { version = "1", features = ["fs", "io-util"] }
38-
reqwest = { version = "0.12", default-features = false, features = ["json"] }
41+
reqwest = { version = "0.13", default-features = false, features = ["json"] }
3942

4043
[target.'cfg(target_os = "windows")'.dependencies]
4144
windows-version = "0.1"
4245

4346
[features]
44-
default = ["rustls"]
47+
default = ["rustls", "zip8"]
4548

46-
rustls = ["reqwest/rustls-tls"]
49+
rustls = ["reqwest/rustls"]
4750
native-tls = ["reqwest/native-tls"]
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#[cfg(feature = "zip0")]
2+
mod zip0;
3+
#[cfg(feature = "zip0")]
4+
pub use zip0::ZipArchive;
5+
6+
#[cfg(feature = "zip8")]
7+
mod zip8;
8+
#[cfg(feature = "zip8")]
9+
pub use zip8::ZipArchive;

chromiumoxide_fetcher/src/runtime/zip.rs renamed to chromiumoxide_fetcher/src/runtime/zip/zip0.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ fn create_symlink(link_target: Vec<u8>, link_path: &Path) -> ZipResult<()> {
102102
fn create_symlink(link_target: Vec<u8>, link_path: &Path) -> ZipResult<()> {
103103
// Only supports UTF-8 paths which is enough for our usecase
104104
let link_target = String::from_utf8(link_target)
105-
.map_err(|_| ZipError::InvalidArchive("Invalid synmlink target name"))?;
105+
.map_err(|_| ZipError::InvalidArchive("Invalid symlink target name"))?;
106106
std::os::windows::fs::symlink_file(link_target, link_path)?;
107107

108108
Ok(())
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
use std::fs;
2+
use std::io::{self, Read, Seek};
3+
use std::ops::{Deref, DerefMut};
4+
use std::path::Path;
5+
6+
use zip8::{
7+
read::ZipFile,
8+
result::{ZipError, ZipResult},
9+
};
10+
11+
#[derive(Clone, Debug)]
12+
pub struct ZipArchive<R: Read + Seek>(zip8::ZipArchive<R>);
13+
14+
impl<R: Read + Seek> Deref for ZipArchive<R> {
15+
type Target = zip8::ZipArchive<R>;
16+
17+
fn deref(&self) -> &Self::Target {
18+
&self.0
19+
}
20+
}
21+
22+
impl<R: Read + Seek> DerefMut for ZipArchive<R> {
23+
fn deref_mut(&mut self) -> &mut Self::Target {
24+
&mut self.0
25+
}
26+
}
27+
28+
impl<R: Read + Seek> ZipArchive<R> {
29+
pub fn new(reader: R) -> ZipResult<Self> {
30+
zip8::ZipArchive::new(reader).map(Self)
31+
}
32+
33+
/// We need this custom extract function to support symlinks.
34+
/// This is based on https://github.com/zip-rs/zip/pull/213.
35+
///
36+
/// We must be careful with this implementation since it is not
37+
/// protected against malicious symlinks, but we trust the binaries
38+
/// provided by chromium.
39+
pub fn extract<P: AsRef<Path>>(&mut self, directory: P) -> ZipResult<()> {
40+
for i in 0..self.len() {
41+
let mut file = self.by_index(i)?;
42+
43+
let filepath = file
44+
.enclosed_name()
45+
.ok_or(ZipError::InvalidArchive("Invalid file path".into()))?;
46+
let outpath = directory.as_ref().join(filepath);
47+
48+
if file.is_dir() {
49+
fs::create_dir_all(&outpath)?;
50+
} else {
51+
if let Some(p) = outpath.parent() {
52+
if !p.exists() {
53+
fs::create_dir_all(p)?;
54+
}
55+
}
56+
57+
match read_symlink(&mut file)? {
58+
Some(target) => {
59+
create_symlink(target, &outpath)?;
60+
}
61+
None => {
62+
let mut outfile = fs::File::create(&outpath)?;
63+
io::copy(&mut file, &mut outfile)?;
64+
65+
// Get and Set permissions
66+
#[cfg(unix)]
67+
{
68+
use std::os::unix::fs::PermissionsExt;
69+
if let Some(mode) = file.unix_mode() {
70+
fs::set_permissions(&outpath, fs::Permissions::from_mode(mode))?;
71+
}
72+
}
73+
}
74+
}
75+
}
76+
}
77+
Ok(())
78+
}
79+
}
80+
81+
fn read_symlink<R: Read + Seek>(entry: &mut ZipFile<'_, R>) -> ZipResult<Option<Vec<u8>>> {
82+
if let Some(mode) = entry.unix_mode() {
83+
const S_IFLNK: u32 = 0o120000; // symbolic link
84+
if mode & S_IFLNK == S_IFLNK {
85+
let mut contents = Vec::new();
86+
entry.read_to_end(&mut contents)?;
87+
return Ok(Some(contents));
88+
}
89+
}
90+
Ok(None)
91+
}
92+
93+
#[cfg(target_family = "unix")]
94+
fn create_symlink(link_target: Vec<u8>, link_path: &Path) -> ZipResult<()> {
95+
use std::os::unix::ffi::OsStringExt as _;
96+
97+
let link_target = std::ffi::OsString::from_vec(link_target);
98+
std::os::unix::fs::symlink(link_target, link_path)?;
99+
100+
Ok(())
101+
}
102+
103+
#[cfg(target_family = "windows")]
104+
fn create_symlink(link_target: Vec<u8>, link_path: &Path) -> ZipResult<()> {
105+
// Only supports UTF-8 paths which is enough for our usecase
106+
let link_target = String::from_utf8(link_target)
107+
.map_err(|_| ZipError::InvalidArchive("Invalid symlink target name".into()))?;
108+
std::os::windows::fs::symlink_file(link_target, link_path)?;
109+
110+
Ok(())
111+
}

0 commit comments

Comments
 (0)