Skip to content

Commit

Permalink
fix: made custom url crate optional in order to pass cargo publish
Browse files Browse the repository at this point in the history
  • Loading branch information
evilsocket committed Jan 30, 2024
1 parent bce3661 commit 8f3a705
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ default = [
"socks5",
]
http = ["dep:url", "dep:reqwest", "dep:base64", "dep:ntlmclient"]
http_relative_paths = []
dns = ["dep:trust-dns-resolver"]
ssh = ["dep:async-ssh2-tokio"]
sql = ["dep:sqlx"]
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ RUN apt-get update && apt-get install -y libsmbclient-dev libssl-dev ca-certific

WORKDIR /app
ADD . /app
RUN cargo build --release
RUN cargo build --release --features http_relative_paths

FROM debian:bullseye
RUN apt-get update && apt-get install -y libsmbclient libssl-dev ca-certificates
Expand Down
14 changes: 14 additions & 0 deletions src/plugins/http/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,11 +380,25 @@ impl HTTP {
)
};

// HACK: since crates.io removes the patch.crates-io sections from the Cargo file:
//
// https://stackoverflow.com/questions/69235287/can-i-publish-a-crate-that-uses-a-patch
// https://github.com/rust-lang/cargo/issues/10440
//
// using our version of the URL crate won't compile with "cargo publish". Therefore
// we need to wrap this in an optional feature that's not included by default.

#[cfg(feature = "http_relative_paths")]
let url = Url::options()
.leave_relative(true)
.parse(&url_raw)
.map_err(|e| format!("could not parse url '{}': {:?}", url_raw, e))?;

#[cfg(not(feature = "http_relative_paths"))]
let url = Url::options()
.parse(&url_raw)
.map_err(|e| format!("could not parse url '{}': {:?}", url_raw, e))?;

// build base request object
let request = self
.client
Expand Down

0 comments on commit 8f3a705

Please sign in to comment.