🐛 Allowing spaces in server names
parent
f81d819c31
commit
49cd292115
|
@ -108,7 +108,7 @@ struct Config {
|
|||
|
||||
impl From <&ConfigFile> for Config {
|
||||
fn from (f: &ConfigFile) -> Self {
|
||||
let trips = HashMap::from_iter (f.server_tripcodes.iter ()
|
||||
let server_tripcodes = HashMap::from_iter (f.server_tripcodes.iter ()
|
||||
.map (|(k, v)| {
|
||||
use std::convert::TryInto;
|
||||
let bytes: Vec <u8> = base64::decode (v).unwrap ();
|
||||
|
@ -116,11 +116,15 @@ impl From <&ConfigFile> for Config {
|
|||
|
||||
let v = blake3::Hash::from (bytes);
|
||||
|
||||
(k.clone (), v)
|
||||
let k = percent_encoding::percent_encode (k.as_bytes (), percent_encoding::NON_ALPHANUMERIC).to_string ();
|
||||
|
||||
debug! ("Tripcode {} => {}", k, v.to_hex ());
|
||||
|
||||
(k, v)
|
||||
}));
|
||||
|
||||
Self {
|
||||
server_tripcodes: trips,
|
||||
server_tripcodes,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -485,10 +489,12 @@ async fn handle_all (req: Request <Body>, state: Arc <RelayState>)
|
|||
}
|
||||
else if let Some (rest) = prefix_match ("/frontend/servers/", path) {
|
||||
if rest == "" {
|
||||
use std::borrow::Cow;
|
||||
|
||||
#[derive (Serialize)]
|
||||
struct ServerEntry <'a> {
|
||||
path: &'a str,
|
||||
name: &'a str,
|
||||
name: Cow <'a, str>,
|
||||
}
|
||||
|
||||
#[derive (Serialize)]
|
||||
|
@ -503,7 +509,7 @@ async fn handle_all (req: Request <Body>, state: Arc <RelayState>)
|
|||
let page = ServerListPage {
|
||||
servers: names.iter ()
|
||||
.map (|name| ServerEntry {
|
||||
name: &name,
|
||||
name: percent_encoding::percent_decode_str (name).decode_utf8 ().unwrap_or_else (|_| "Server name isn't UTF-8".into ()),
|
||||
path: &name,
|
||||
})
|
||||
.collect (),
|
||||
|
|
Loading…
Reference in New Issue