Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions rust/agama-lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ regex = "1.11.1"
fluent-uri = { version = "0.3.2", features = ["serde"] }
tokio-tungstenite = { version = "0.26.2", features = ["native-tls"] }
tokio-native-tls = "0.3.1"
percent-encoding = "2.3.1"

[dev-dependencies]
httpmock = "0.7.0"
Expand Down
7 changes: 5 additions & 2 deletions rust/agama-lib/src/network/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

use super::{settings::NetworkConnection, types::Device};
use crate::http::{BaseHTTPClient, BaseHTTPClientError};
use crate::utils::url::encode;

#[derive(Debug, thiserror::Error)]
pub enum NetworkClientError {
Expand Down Expand Up @@ -56,9 +57,10 @@ impl NetworkClient {

/// Returns an array of network connections
pub async fn connection(&self, id: &str) -> Result<NetworkConnection, NetworkClientError> {
let encoded_id = encode(id);
let json = self
.client
.get::<NetworkConnection>(format!("/network/connections/{id}").as_str())
.get::<NetworkConnection>(format!("/network/connections/{encoded_id}").as_str())
.await?;

Ok(json)
Expand All @@ -70,10 +72,11 @@ impl NetworkClient {
connection: NetworkConnection,
) -> Result<(), NetworkClientError> {
let id = connection.id.clone();
let encoded_id = encode(id.as_str());
let response = self.connection(id.as_str()).await;

if response.is_ok() {
let path = format!("/network/connections/{id}");
let path = format!("/network/connections/{encoded_id}");
self.client.put_void(path.as_str(), &connection).await?
} else {
self.client
Expand Down
1 change: 1 addition & 0 deletions rust/agama-lib/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

mod file_format;
mod transfer;
pub mod url;

pub use file_format::*;
pub use transfer::*;
38 changes: 38 additions & 0 deletions rust/agama-lib/src/utils/url.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright (c) [2025] SUSE LLC
//
// All Rights Reserved.
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 of the License, or (at your option)
// any later version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
// more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, contact SUSE LLC.
//
// To contact SUSE LLC about this file by physical or electronic mail, you may
// find current contact information at www.suse.com.

use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC};

pub fn encode(value: &str) -> String {
utf8_percent_encode(value, NON_ALPHANUMERIC).to_string()
}

#[cfg(test)]
mod tests {

use super::encode;

#[test]
fn test_encode_value() {
let id = "Wired #1";
let encoded_id = encode(id);
assert_eq!(encoded_id, "Wired%20%231");
}
}
6 changes: 6 additions & 0 deletions rust/package/agama.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Wed Jul 23 11:37:04 UTC 2025 - Knut Anderssen <[email protected]>

- Fix CLI connection update when using an special character in
the connection ID (bsc#1246930, gh#agama-project/agama#2605).

-------------------------------------------------------------------
Tue Jul 22 07:53:34 UTC 2025 - Martin Vidner <[email protected]>

Expand Down