summaryrefslogtreecommitdiffstats
path: root/vendor/gix-url/src
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:42 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:42 +0000
commit837b550238aa671a591ccf282dddeab29cadb206 (patch)
tree914b6b8862bace72bd3245ca184d374b08d8a672 /vendor/gix-url/src
parentAdding debian version 1.70.0+dfsg2-1. (diff)
downloadrustc-837b550238aa671a591ccf282dddeab29cadb206.tar.xz
rustc-837b550238aa671a591ccf282dddeab29cadb206.zip
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/gix-url/src')
-rw-r--r--vendor/gix-url/src/expand_path.rs2
-rw-r--r--vendor/gix-url/src/impls.rs1
-rw-r--r--vendor/gix-url/src/lib.rs41
-rw-r--r--vendor/gix-url/src/parse.rs4
-rw-r--r--vendor/gix-url/src/scheme.rs2
5 files changed, 22 insertions, 28 deletions
diff --git a/vendor/gix-url/src/expand_path.rs b/vendor/gix-url/src/expand_path.rs
index 393ce9116..85fb0da50 100644
--- a/vendor/gix-url/src/expand_path.rs
+++ b/vendor/gix-url/src/expand_path.rs
@@ -5,7 +5,7 @@ use bstr::{BStr, BString, ByteSlice};
/// Whether a repository is resolving for the current user, or the given one.
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
-#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
+#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum ForUser {
/// The currently logged in user.
Current,
diff --git a/vendor/gix-url/src/impls.rs b/vendor/gix-url/src/impls.rs
index d3c578088..14926fc3c 100644
--- a/vendor/gix-url/src/impls.rs
+++ b/vendor/gix-url/src/impls.rs
@@ -13,6 +13,7 @@ impl Default for Url {
serialize_alternative_form: false,
scheme: Scheme::Ssh,
user: None,
+ password: None,
host: None,
port: None,
path: bstr::BString::default(),
diff --git a/vendor/gix-url/src/lib.rs b/vendor/gix-url/src/lib.rs
index 9e3de2b79..ca62bdd6f 100644
--- a/vendor/gix-url/src/lib.rs
+++ b/vendor/gix-url/src/lib.rs
@@ -32,12 +32,14 @@ pub use scheme::Scheme;
///
/// Note that we do not support passing the password using the URL as it's likely leading to accidents.
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
-#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
+#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Url {
/// The URL scheme.
pub scheme: Scheme,
/// The user to impersonate on the remote.
user: Option<String>,
+ /// The password associated with a user.
+ password: Option<String>,
/// The host to which to connect. Localhost is implied if `None`.
host: Option<String>,
/// When serializing, use the alternative forms as it was parsed as such.
@@ -50,44 +52,25 @@ pub struct Url {
/// Instantiation
impl Url {
- /// Create a new instance from the given parts, which will be validated by parsing them back.
+ /// Create a new instance from the given parts, including a password, which will be validated by parsing them back.
pub fn from_parts(
scheme: Scheme,
user: Option<String>,
+ password: Option<String>,
host: Option<String>,
port: Option<u16>,
path: BString,
+ serialize_alternative_form: bool,
) -> Result<Self, parse::Error> {
parse(
Url {
scheme,
user,
+ password,
host,
port,
path,
- serialize_alternative_form: false,
- }
- .to_bstring()
- .as_ref(),
- )
- }
-
- /// Create a new instance from the given parts, which will be validated by parsing them back from its alternative form.
- pub fn from_parts_as_alternative_form(
- scheme: Scheme,
- user: Option<String>,
- host: Option<String>,
- port: Option<u16>,
- path: BString,
- ) -> Result<Self, parse::Error> {
- parse(
- Url {
- scheme,
- user,
- host,
- port,
- path,
- serialize_alternative_form: true,
+ serialize_alternative_form,
}
.to_bstring()
.as_ref(),
@@ -133,6 +116,10 @@ impl Url {
pub fn user(&self) -> Option<&str> {
self.user.as_deref()
}
+ /// Returns the password mentioned in the url, if present.
+ pub fn password(&self) -> Option<&str> {
+ self.password.as_deref()
+ }
/// Returns the host mentioned in the url, if present.
pub fn host(&self) -> Option<&str> {
self.host.as_deref()
@@ -178,6 +165,10 @@ impl Url {
match (&self.user, &self.host) {
(Some(user), Some(host)) => {
out.write_all(user.as_bytes())?;
+ if let Some(password) = &self.password {
+ out.write_all(&[b':'])?;
+ out.write_all(password.as_bytes())?;
+ }
out.write_all(&[b'@'])?;
out.write_all(host.as_bytes())?;
}
diff --git a/vendor/gix-url/src/parse.rs b/vendor/gix-url/src/parse.rs
index df5ad5565..bb9c1f38b 100644
--- a/vendor/gix-url/src/parse.rs
+++ b/vendor/gix-url/src/parse.rs
@@ -66,10 +66,12 @@ fn has_no_explicit_protocol(url: &[u8]) -> bool {
}
fn to_owned_url(url: url::Url) -> Result<crate::Url, Error> {
+ let password = url.password();
Ok(crate::Url {
serialize_alternative_form: false,
scheme: str_to_protocol(url.scheme()),
- user: if url.username().is_empty() {
+ password: password.map(ToOwned::to_owned),
+ user: if url.username().is_empty() && password.is_none() {
None
} else {
Some(url.username().into())
diff --git a/vendor/gix-url/src/scheme.rs b/vendor/gix-url/src/scheme.rs
index 5f491596a..1c5f04526 100644
--- a/vendor/gix-url/src/scheme.rs
+++ b/vendor/gix-url/src/scheme.rs
@@ -2,7 +2,7 @@
///
/// It defines how to talk to a given repository.
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
-#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
+#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[allow(missing_docs)]
pub enum Scheme {
/// A local resource that is accessible on the current host.