Compare commits
2 commits
e74134d9ad
...
6f71ab08f6
Author | SHA1 | Date | |
---|---|---|---|
6f71ab08f6 | |||
93d942b8a7 |
5 changed files with 16 additions and 5 deletions
7
Cargo.lock
generated
7
Cargo.lock
generated
|
@ -371,6 +371,7 @@ dependencies = [
|
|||
"tokio",
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
"urlencoding",
|
||||
"which",
|
||||
]
|
||||
|
||||
|
@ -1451,6 +1452,12 @@ dependencies = [
|
|||
"percent-encoding",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "urlencoding"
|
||||
version = "2.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da"
|
||||
|
||||
[[package]]
|
||||
name = "utf8parse"
|
||||
version = "0.2.1"
|
||||
|
|
|
@ -24,4 +24,5 @@ axum = { version = "0.7.4", optional = true }
|
|||
reqwest = { version = "0.11.24", optional = true, default-features = false, features = ["rustls-tls", "blocking", "json", "gzip", "brotli", "deflate"] }
|
||||
tempfile = { version = "3.10.0", optional = true }
|
||||
which = { version = "6.0.0", optional = true }
|
||||
nix = { version = "0.27.1", optional = true, default-features = false, features = ["signal"] }
|
||||
nix = { version = "0.27.1", optional = true, default-features = false, features = ["signal"] }
|
||||
urlencoding = { version = "2.1.3"}
|
|
@ -52,6 +52,7 @@ pub fn finger_fedi(client: &Client, handle: &str) -> Result<Resource, FediFinger
|
|||
.split_once('@')
|
||||
.ok_or(FediFingerError::MissingMiddleAt)?;
|
||||
let account = format!("acct:{handle}");
|
||||
let account = urlencoding::encode(account.as_str());
|
||||
|
||||
let url =
|
||||
Url::parse(format!("https://{domain}/.well-known/webfinger?resource={account}").as_str())
|
||||
|
|
|
@ -4,13 +4,11 @@ use std::io::{Read, Seek, SeekFrom, Write};
|
|||
use std::process::Command;
|
||||
use tempfile::NamedTempFile;
|
||||
use thiserror::Error;
|
||||
use tracing::{debug, instrument, trace};
|
||||
use tracing::{debug, instrument, trace, warn};
|
||||
|
||||
/// Error type returned by `spawn_editor`
|
||||
#[derive(Debug, Error)]
|
||||
pub enum EditorSpawnError {
|
||||
#[error("$EDITOR environment variable isn't set")]
|
||||
NoEditorEnv,
|
||||
#[error("failed to parse out absolute path of editor: {0}")]
|
||||
InvalidEditorPath(which::Error),
|
||||
#[error("failed to create temporary file for edit buffer: {0}")]
|
||||
|
@ -34,7 +32,10 @@ pub enum EditorSpawnError {
|
|||
pub fn spawn_editor(buffer: impl AsRef<str> + Display) -> Result<String, EditorSpawnError> {
|
||||
use EditorSpawnError::*;
|
||||
trace!("Input buffer: {buffer}");
|
||||
let editor = option_env!("EDITOR").ok_or(NoEditorEnv)?;
|
||||
let editor = option_env!("EDITOR").unwrap_or_else(|| {
|
||||
warn!("EDITOR environment variable isn't set, defaulting to vi");
|
||||
"vi"
|
||||
});
|
||||
debug!("$EDITOR is {editor}");
|
||||
let editor = which::which(editor).map_err(InvalidEditorPath)?;
|
||||
debug!("$EDITOR's full path is {editor:?}");
|
||||
|
|
|
@ -81,6 +81,7 @@ async fn run_webfinger_query(
|
|||
info!("Received query with {uri}");
|
||||
let query = uri.query().ok_or(StatusCode::BAD_REQUEST)?;
|
||||
debug!("Query string is {query}");
|
||||
let query = urlencoding::decode(query).map_err(|e| StatusCode::BAD_REQUEST)?;
|
||||
let params = query
|
||||
.split('&')
|
||||
.filter_map(|query_part| {
|
||||
|
|
Loading…
Reference in a new issue