]> git.proxmox.com Git - proxmox-backup.git/blob - pbs-tools/src/percent_encoding.rs
afe011e2615a1d0173cc865b52e0851af6c001eb
[proxmox-backup.git] / pbs-tools / src / percent_encoding.rs
1 use percent_encoding::{utf8_percent_encode, AsciiSet};
2
3 /// This used to be: `SIMPLE_ENCODE_SET` plus space, `"`, `#`, `<`, `>`, backtick, `?`, `{`, `}`
4 pub 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
20 pub fn percent_encode_component(comp: &str) -> String {
21 utf8_percent_encode(comp, percent_encoding::NON_ALPHANUMERIC).to_string()
22 }