mirror of
https://github.com/librespot-org/librespot.git
synced 2025-10-05 19:42:03 +02:00
Fix utf username.
This commit is contained in:
parent
0056400ca1
commit
6f084d7ea5
3 changed files with 22 additions and 3 deletions
|
@ -1,4 +1,5 @@
|
|||
use crate::protocol;
|
||||
use crate::util::url_encode;
|
||||
use byteorder::{BigEndian, ByteOrder};
|
||||
use bytes::Bytes;
|
||||
use futures::sync::{mpsc, oneshot};
|
||||
|
@ -192,7 +193,7 @@ impl MercuryManager {
|
|||
let header: protocol::mercury::Header = protobuf::parse_from_bytes(&header_data).unwrap();
|
||||
|
||||
let response = MercuryResponse {
|
||||
uri: header.get_uri().to_owned(),
|
||||
uri: url_encode(header.get_uri()).to_owned(),
|
||||
status_code: header.get_status_code(),
|
||||
payload: pending.parts,
|
||||
};
|
||||
|
|
|
@ -12,6 +12,21 @@ pub fn rand_vec<G: Rng>(rng: &mut G, size: usize) -> Vec<u8> {
|
|||
.collect()
|
||||
}
|
||||
|
||||
pub fn url_encode(inp: &str) -> String {
|
||||
let mut encoded = String::new();
|
||||
|
||||
for c in inp.as_bytes().iter() {
|
||||
match *c as char {
|
||||
'A'..='Z' | 'a'..='z' | '0'..='9' | '-' | '_' | '.' | '~' | ':' | '/' => {
|
||||
encoded.push(*c as char)
|
||||
}
|
||||
c => encoded.push_str(format!("%{:02X}", c as u32).as_str()),
|
||||
};
|
||||
}
|
||||
|
||||
encoded
|
||||
}
|
||||
|
||||
pub fn powm(base: &BigUint, exp: &BigUint, modulus: &BigUint) -> BigUint {
|
||||
let mut base = base.clone();
|
||||
let mut exp = exp.clone();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue