]> git.proxmox.com Git - proxmox-backup.git/blame - pbs-tools/src/percent_encoding.rs
fix StdChannelWriter usage
[proxmox-backup.git] / pbs-tools / src / percent_encoding.rs
CommitLineData
4805edc4
WB
1use percent_encoding::{utf8_percent_encode, AsciiSet};
2
3/// This used to be: `SIMPLE_ENCODE_SET` plus space, `"`, `#`, `<`, `>`, backtick, `?`, `{`, `}`
4pub const DEFAULT_ENCODE_SET: &AsciiSet = &percent_encoding::CONTROLS // 0..1f and 7e
5 // The SIMPLE_ENCODE_SET adds space and anything >= 0x7e (7e itself is already included above)
6 .add(0x20)
7 .add(0x7f)
8 // the DEFAULT_ENCODE_SET added:
9 .add(b' ')
10 .add(b'"')
11 .add(b'#')
12 .add(b'<')
13 .add(b'>')
14 .add(b'`')
15 .add(b'?')
16 .add(b'{')
17 .add(b'}');
18
19/// percent encode a url component
20pub fn percent_encode_component(comp: &str) -> String {
21 utf8_percent_encode(comp, percent_encoding::NON_ALPHANUMERIC).to_string()
22}