From 9a6430656d921646348c10bd305b090facf6b902 Mon Sep 17 00:00:00 2001 From: spikecodes <19519553+spikecodes@users.noreply.github.com> Date: Sun, 29 Nov 2020 18:50:29 -0800 Subject: [PATCH] Added Percent Encoding Support --- Cargo.lock | 3 +- Cargo.toml | 5 +- cargo-timing.html | 16534 -------------------------------------------- rustfmt.toml | 2 +- src/main.rs | 2 +- src/popular.rs | 4 +- src/post.rs | 26 +- src/proxy.rs | 23 +- src/subreddit.rs | 12 +- src/user.rs | 6 +- src/utils.rs | 16 +- 11 files changed, 63 insertions(+), 16570 deletions(-) delete mode 100644 cargo-timing.html diff --git a/Cargo.lock b/Cargo.lock index 31b1369..439f0ec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1394,11 +1394,12 @@ dependencies = [ [[package]] name = "libreddit" -version = "0.1.7" +version = "0.1.8" dependencies = [ "actix-web", "askama", "chrono", + "percent-encoding", "pulldown-cmark", "serde", "serde_json", diff --git a/Cargo.toml b/Cargo.toml index dd836dd..bdec072 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,15 +3,16 @@ name = "libreddit" description = " Alternative private front-end to Reddit" license = "AGPL-3.0" repository = "https://github.com/spikecodes/libreddit" -version = "0.1.7" +version = "0.1.8" authors = ["spikecodes <19519553+spikecodes@users.noreply.github.com>"] edition = "2018" [features] default = ["proxy"] -proxy = ["actix-web/rustls"] +proxy = ["actix-web/rustls", "percent-encoding"] [dependencies] +percent-encoding = { version = "2.1.0", optional = true } actix-web = "3.2.0" surf = "2.1.0" askama = "0.8.0" diff --git a/cargo-timing.html b/cargo-timing.html deleted file mode 100644 index a3d7a19..0000000 --- a/cargo-timing.html +++ /dev/null @@ -1,16534 +0,0 @@ - - - - Cargo Build Timings — libreddit 0.1.6 - - - - - -

Cargo Build Timings

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Targets:libreddit 0.1.6 (bin "libreddit")
Profile:dev
Fresh units:0
Dirty units:323
Total units:323
Max concurrency:12 (jobs=12 ncpu=12)
Build start:2020-11-26T21:59:35Z
Total time:56.1s
rustc:rustc 1.50.0-nightly (825637983 2020-11-18)
Host: x86_64-unknown-linux-gnu
Target: x86_64-unknown-linux-gnu
Max (global) rustc threads concurrency:0
- - - - - - - - - - - - - - -
- -
- - -
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
UnitTotalCodegenFeatures
1.async-std v1.7.010.7s4.3s (40%)alloc, async-global-executor, async-io, async-mutex, blocking, crossbeam-utils, default, futures-channel, futures-core, futures-io, futures-lite, gloo-timers, kv-log-macro, log, memchr, num_cpus, once_cell, pin-project-lite, pin-utils, slab, std, wasm-bindgen-futures
2.syn v1.0.5010.5s2.6s (25%)clone-impls, default, derive, extra-traits, full, parsing, printing, proc-macro, quote, visit, visit-mut
3.regex-syntax v0.6.218.6s4.2s (48%)default, unicode, unicode-age, unicode-bool, unicode-case, unicode-gencat, unicode-perl, unicode-script, unicode-segment
4.object v0.22.08.4s3.3s (40%)archive, coff, elf, macho, pe, read_core, unaligned
5.libreddit v0.1.6 bin "libreddit"7.6s0.0s (0%)default, proxy
6.serde_derive v1.0.1177.1s0.0s (0%)default
7.h2 v0.2.76.5s1.2s (19%)
8.encoding_rs v0.8.266.4s3.2s (49%)
9.brotli-sys v0.3.2 custom-build (run)6.4s0.0s (0%)
10.derive_more v0.99.116.4s0.0s (0%)add, add_assign, as_mut, as_ref, constructor, default, deref, deref_mut, display, error, from, from_str, index, index_mut, into, into_iterator, iterator, mul, mul_assign, not, sum, try_into
11.tokio v0.2.235.8s1.5s (26%)default, futures-core, io-driver, io-util, iovec, lazy_static, libc, memchr, mio, mio-uds, rt-core, rt-util, signal, signal-hook-registry, slab, stream, tcp, time, udp, uds, winapi
12.gimli v0.23.05.8s1.0s (17%)read
13.regex v1.4.25.8s3.5s (60%)aho-corasick, default, memchr, perf, perf-cache, perf-dfa, perf-inline, perf-literal, std, thread_local, unicode, unicode-age, unicode-bool, unicode-case, unicode-gencat, unicode-perl, unicode-script, unicode-segment
14.rustls v0.18.15.3s2.1s (39%)dangerous_configuration, default, log, logging
15.http v0.2.15.3s1.4s (26%)
16.pin-project-internal v0.4.275.1s0.0s (0%)
17.ring v0.16.174.9s2.5s (51%)alloc, default, dev_urandom_fallback, once_cell
18.pin-project-internal v1.0.24.8s0.0s (0%)
19.tracing-attributes v0.1.114.8s0.0s (0%)
20.syn v0.15.444.7s1.6s (35%)clone-impls, default, derive, parsing, printing, proc-macro, quote
21.pulldown-cmark v0.8.04.1s2.2s (54%)default, getopts
22.backtrace v0.3.554.0s3.2s (79%)addr2line, default, gimli-symbolize, miniz_oxide, object, std
23.serde v1.0.1174.0s0.2s (6%)default, derive, serde_derive, std
24.askama_derive v0.8.04.0s0.0s (0%)
25.async-trait v0.1.424.0s0.0s (0%)
26.futures-util v0.3.84.0s0.1s (3%)alloc, async-await, async-await-macro, channel, default, futures-channel, futures-io, futures-macro, futures-sink, io, memchr, proc-macro-hack, proc-macro-nested, sink, slab, std
27.actix-http v2.1.03.9s0.7s (19%)actix-tls, brotli2, compress, default, flate2, rustls
28.thiserror-impl v1.0.223.9s0.0s (0%)
29.trust-dns-proto v0.19.63.9s1.1s (28%)tokio, tokio-runtime
30.aho-corasick v0.7.153.6s2.0s (56%)default, std
31.cc v1.0.653.6s2.5s (69%)
32.data-encoding v2.3.13.5s2.7s (77%)alloc, default, std
33.http-types v2.8.03.5s1.0s (29%)async-std, cookie-secure, default, fs
34.isahc v0.9.133.3s1.4s (43%)http2
35.actix-web v3.2.03.1s0.6s (21%)compress, default, rust-tls, rustls
36.trust-dns-resolver v0.19.63.0s1.3s (42%)ipconfig, resolv-conf, system-config, tokio, tokio-runtime
37.futures-macro v0.3.82.9s0.0s (0%)
38.awc v2.0.12.6s1.7s (64%)compress, rust-tls, rustls
39.proc-macro-hack v0.5.192.6s0.0s (0%)
40.chrono v0.4.192.6s0.8s (30%)clock, default, libc, oldtime, std, time, winapi
41.actix-web-codegen v0.4.02.6s0.0s (0%)
42.time v0.2.232.6s0.8s (32%)libc, std, stdweb, winapi
43.libnghttp2-sys v0.1.5+1.42.0 custom-build (run)2.5s0.0s (0%)
44.mio v0.6.222.5s1.1s (45%)default, with-deprecated
45.serde_json v1.0.592.3s0.6s (24%)default, std
46.toml v0.4.102.3s0.6s (28%)
47.time-macros-impl v0.1.12.3s0.0s (0%)
48.rand v0.7.32.2s0.4s (19%)alloc, default, getrandom, getrandom_package, libc, std
49.async-io v1.2.02.2s1.5s (68%)
50.proc-macro2 v1.0.242.1s1.3s (61%)default, proc-macro
51.ring v0.16.17 custom-build (run)2.0s0.0s (0%)alloc, default, dev_urandom_fallback, once_cell
52.enum-as-inner v0.3.32.0s0.0s (0%)
53.nom v4.2.32.0s0.6s (31%)alloc, default, std
54.actix-server v1.0.42.0s1.2s (64%)default
55.num-traits v0.2.141.9s0.2s (8%)default, std
56.miniz_oxide v0.4.31.9s1.0s (50%)
57.unicode-normalization v0.1.161.9s0.3s (17%)default, std
58.proc-macro2 v0.4.301.8s1.0s (54%)default, proc-macro
59.tinyvec v1.1.01.8s0.0s (2%)alloc, default, tinyvec_macros
60.idna v0.2.01.8s0.8s (46%)
61.futures-lite v1.11.21.8s0.2s (13%)alloc, default, fastrand, futures-io, parking, std, waker-fn
62.rand_chacha v0.2.21.7s1.4s (78%)std
63.language-tags v0.2.21.7s1.4s (80%)
64.mime_guess v2.0.3 custom-build1.7s0.0s (0%)default, rev-mappings
65.actix-macros v0.1.21.6s0.0s (0%)
66.unicode-bidi v0.3.41.6s1.1s (66%)default
67.url v2.2.01.5s0.4s (26%)serde
68.pkg-config v0.3.191.5s1.1s (74%)
69.curl v0.4.341.5s0.4s (29%)default, http2, openssl-probe, openssl-sys, ssl
70.typenum v1.12.0 custom-build1.5s0.0s (0%)
71.const_fn v0.4.31.5s0.0s (0%)
72.getopts v0.2.211.5s1.0s (70%)
73.typenum v1.12.01.4s0.0s (2%)
74.ring v0.16.17 custom-build1.4s0.0s (0%)alloc, default, dev_urandom_fallback, once_cell
75.tracing-core v0.1.171.4s0.7s (51%)lazy_static, std
76.bytes v0.5.61.4s0.5s (36%)default, std
77.libc v0.2.801.4s0.1s (9%)align, default, std
78.autocfg v1.0.11.4s0.8s (56%)
79.openssl-sys v0.9.58 custom-build1.3s0.0s (0%)
80.actix-router v0.2.51.3s0.3s (24%)default, http
81.flate2 v1.0.191.2s0.3s (26%)default, miniz_oxide, rust_backend
82.version_check v0.9.21.2s0.7s (57%)
83.time v0.1.441.2s0.6s (51%)
84.mime_guess v2.0.31.2s0.3s (29%)default, rev-mappings
85.resolv-conf v0.7.01.2s0.7s (60%)hostname, system
86.crossbeam-utils v0.8.01.2s0.6s (52%)default, lazy_static, std
87.askama_shared v0.8.01.1s0.5s (44%)
88.sha2 v0.9.21.1s0.6s (53%)default, std
89.signal-hook-registry v1.2.21.1s0.8s (71%)
90.parking_lot v0.11.11.1s0.7s (61%)default
91.webpki v0.21.31.1s0.5s (49%)default, std, trust_anchor_util
92.async-executor v1.4.01.1s0.7s (69%)
93.rustc-demangle v0.1.181.1s0.6s (56%)
94.threadpool v1.8.11.0s0.8s (80%)
95.serde_qs v0.7.01.0s0.3s (30%)default
96.infer v0.2.31.0s0.6s (59%)
97.cookie v0.14.31.0s0.4s (40%)aes-gcm, base64, hkdf, hmac, key-expansion, percent-encode, percent-encoding, private, rand, secure, sha2, signed
98.curl-sys v0.4.38+curl-7.73.0 custom-build1.0s0.0s (0%)default, http2, libnghttp2-sys, openssl-sys, ssl
99.num_cpus v1.13.01.0s0.7s (72%)
100.unicode-segmentation v1.7.01.0s0.3s (26%)
101.proc-macro2 v1.0.24 custom-build1.0s0.0s (0%)default, proc-macro
102.log v0.4.111.0s0.4s (40%)kv_unstable
103.libc v0.2.80 custom-build1.0s0.0s (0%)align, default, std
104.openssl-sys v0.9.581.0s0.1s (12%)
105.httparse v1.3.4 custom-build0.9s0.0s (0%)default, std
106.syn v1.0.50 custom-build0.9s0.0s (0%)clone-impls, default, derive, extra-traits, full, parsing, printing, proc-macro, quote, visit, visit-mut
107.socket2 v0.3.170.9s0.5s (52%)
108.hashbrown v0.9.10.9s0.0s (4%)raw
109.anyhow v1.0.340.9s0.5s (57%)default, std
110.aes-soft v0.6.40.9s0.4s (44%)
111.net2 v0.2.350.9s0.5s (55%)default, duration
112.byteorder v1.3.4 custom-build0.9s0.0s (0%)default, std
113.actix-rt v1.1.10.8s0.5s (54%)
114.version_check v0.1.50.8s0.6s (76%)
115.async-global-executor v1.4.30.8s0.6s (74%)async-io, default
116.num-integer v0.1.440.8s0.3s (36%)
117.memchr v2.3.40.8s0.3s (37%)default, std, use_std
118.surf v2.1.00.8s0.2s (25%)curl-client, default, default-client, encoding, encoding_rs, middleware-logger, once_cell, web-sys
119.blocking v1.0.20.8s0.4s (53%)
120.indexmap v1.6.00.8s0.1s (11%)
121.quote v1.0.70.8s0.4s (51%)default, proc-macro
122.parking_lot_core v0.8.00.8s0.4s (50%)
123.ppv-lite86 v0.2.100.8s0.0s (3%)simd, std
124.generic-array v0.14.40.8s0.0s (3%)
125.const_fn v0.4.3 custom-build0.8s0.0s (0%)
126.base64 v0.12.30.8s0.3s (34%)default, std
127.mime v0.3.160.8s0.4s (56%)
128.libz-sys v1.1.2 custom-build0.7s0.0s (0%)libc
129.httparse v1.3.40.7s0.3s (44%)default, std
130.base64 v0.13.00.7s0.2s (32%)default, std
131.isahc v0.9.13 custom-build0.7s0.0s (0%)http2
132.memchr v2.3.4 custom-build0.7s0.0s (0%)default, std, use_std
133.actix-service v1.0.60.7s0.0s (2%)
134.actix-utils v2.0.00.7s0.2s (28%)
135.proc-macro2 v0.4.30 custom-build0.7s0.0s (0%)default, proc-macro
136.tokio-util v0.3.10.7s0.2s (25%)codec, default
137.syn v0.15.44 custom-build0.7s0.0s (0%)clone-impls, default, derive, parsing, printing, proc-macro, quote
138.polling v2.0.20.7s0.4s (59%)default, std
139.serde v1.0.117 custom-build0.7s0.0s (0%)default, derive, serde_derive, std
140.ryu v1.0.5 custom-build0.6s0.0s (0%)
141.serde_derive v1.0.117 custom-build0.6s0.0s (0%)default
142.serde_json v1.0.59 custom-build0.6s0.0s (0%)default, std
143.log v0.4.11 custom-build0.6s0.0s (0%)kv_unstable
144.http-client v6.2.00.6s0.2s (40%)async-std, curl_client, isahc
145.byteorder v1.3.40.6s0.1s (16%)default, std
146.quote v0.6.130.6s0.4s (62%)default, proc-macro
147.libnghttp2-sys v0.1.5+1.42.0 custom-build0.6s0.0s (0%)
148.pin-project-internal v0.4.27 custom-build0.6s0.0s (0%)
149.proc-macro-hack v0.5.19 custom-build0.6s0.0s (0%)
150.crc32fast v1.2.1 custom-build0.6s0.0s (0%)default, std
151.sha-1 v0.9.20.6s0.3s (55%)default, std
152.bitflags v1.2.1 custom-build0.6s0.0s (0%)default
153.actix-connect v2.0.00.6s0.1s (11%)default, http, rust-tls, rustls, tokio-rustls, uri, webpki
154.tracing v0.1.220.6s0.2s (37%)attributes, default, log, std, tracing-attributes
155.anyhow v1.0.34 custom-build0.6s0.0s (0%)default, std
156.flume v0.9.20.6s0.1s (22%)async, futures-core, futures-sink
157.brotli2 v0.3.20.5s0.2s (45%)
158.http-types v2.8.0 custom-build0.5s0.0s (0%)async-std, cookie-secure, default, fs
159.proc-macro-nested v0.1.6 custom-build0.5s0.0s (0%)
160.rand_core v0.5.10.5s0.2s (30%)alloc, getrandom, std
161.thread_local v1.0.10.5s0.3s (53%)
162.sluice v0.5.30.5s0.4s (69%)
163.addr2line v0.14.00.5s0.1s (27%)
164.fastrand v1.4.00.5s0.2s (41%)
165.brotli-sys v0.3.2 custom-build0.5s0.0s (0%)
166.percent-encoding v2.1.00.5s0.3s (59%)
167.heck v0.3.10.5s0.3s (65%)
168.event-listener v2.5.10.5s0.3s (61%)
169.async-task v4.0.30.5s0.2s (42%)default, std
170.unicase v2.6.00.5s0.2s (41%)
171.futures-core v0.3.80.5s0.1s (31%)alloc, default, std
172.serde_urlencoded v0.7.00.5s0.1s (12%)
173.futures-channel v0.3.80.4s0.1s (12%)alloc, default, futures-sink, sink, std
174.serde_urlencoded v0.6.10.4s0.0s (6%)
175.getrandom v0.1.150.4s0.2s (44%)std
176.crc32fast v1.2.10.4s0.2s (48%)default, std
177.getrandom v0.1.15 custom-build0.4s0.0s (0%)std
178.libnghttp2-sys v0.1.5+1.42.00.4s0.2s (38%)
179.smallvec v1.5.00.4s0.0s (8%)
180.ryu v1.0.50.4s0.2s (41%)
181.standback v0.2.13 custom-build0.4s0.0s (0%)std
182.time v0.2.23 custom-build0.4s0.0s (0%)libc, std, stdweb, winapi
183.once_cell v1.5.20.4s0.2s (48%)alloc, default, std
184.mio-uds v0.6.80.4s0.2s (41%)
185.futures-io v0.3.80.4s0.2s (53%)default, std
186.unicode-xid v0.2.10.4s0.0s (10%)default
187.lock_api v0.4.20.4s0.0s (6%)
188.parking v2.0.00.4s0.2s (62%)
189.openssl-probe v0.1.20.3s0.2s (66%)
190.cookie v0.14.3 custom-build0.3s0.0s (0%)aes-gcm, base64, hkdf, hmac, key-expansion, percent-encode, percent-encoding, private, rand, secure, sha2, signed
191.curl v0.4.34 custom-build0.3s0.0s (0%)default, http2, openssl-probe, openssl-sys, ssl
192.crossbeam-utils v0.8.0 custom-build0.3s0.0s (0%)default, lazy_static, std
193.polyval v0.4.10.3s0.2s (52%)
194.nom v4.2.3 custom-build0.3s0.0s (0%)alloc, default, std
195.form_urlencoded v1.0.00.3s0.2s (48%)
196.crossbeam-utils v0.8.0 custom-build (run)0.3s0.0s (0%)default, lazy_static, std
197.tokio-rustls v0.14.10.3s0.0s (9%)
198.unicase v2.6.0 custom-build0.3s0.0s (0%)
199.num-integer v0.1.44 custom-build0.3s0.0s (0%)
200.sct v0.6.00.3s0.2s (46%)
201.num-traits v0.2.14 custom-build0.3s0.0s (0%)default, std
202.indexmap v1.6.0 custom-build0.3s0.0s (0%)
203.miniz_oxide v0.4.3 custom-build0.3s0.0s (0%)
204.futures-task v0.3.80.3s0.1s (36%)alloc, once_cell, std
205.bytestring v0.1.50.3s0.1s (37%)
206.aead v0.3.20.3s0.1s (47%)alloc
207.hostname v0.3.10.3s0.2s (61%)default
208.generic-array v0.14.4 custom-build0.3s0.0s (0%)
209.actix-codec v0.3.00.3s0.0s (8%)
210.linked-hash-map v0.5.30.3s0.0s (5%)
211.cipher v0.2.50.3s0.0s (8%)
212.concurrent-queue v1.2.20.3s0.0s (8%)
213.atomic-waker v1.0.00.3s0.1s (52%)
214.curl-sys v0.4.38+curl-7.73.00.3s0.0s (6%)default, http2, libnghttp2-sys, openssl-sys, ssl
215.dtoa v0.4.60.3s0.0s (15%)
216.pulldown-cmark v0.8.0 custom-build0.3s0.0s (0%)default, getopts
217.encoding_rs v0.8.26 custom-build0.3s0.0s (0%)
218.either v1.6.10.3s0.0s (8%)default, use_std
219.nb-connect v1.0.20.3s0.1s (41%)
220.ctr v0.6.00.2s0.0s (5%)
221.iovec v0.1.40.2s0.1s (51%)
222.humansize v1.1.00.2s0.0s (19%)
223.adler v0.2.30.2s0.1s (53%)
224.itoa v0.4.60.2s0.0s (7%)default, std
225.askama_escape v0.2.00.2s0.1s (41%)
226.async-channel v1.5.10.2s0.0s (15%)
227.cfg-if v0.1.100.2s0.0s (7%)
228.spin v0.5.20.2s0.0s (12%)
229.cfg-if v1.0.00.2s0.0s (5%)
230.subtle v2.3.00.2s0.0s (16%)
231.actix-threadpool v0.3.30.2s0.1s (28%)
232.actix-tls v2.0.00.2s0.0s (13%)default, rust-tls, rustls, tokio-rustls, webpki, webpki-roots
233.untrusted v0.7.10.2s0.1s (36%)
234.kv-log-macro v1.0.70.2s0.1s (47%)
235.actix-testing v1.0.10.2s0.0s (17%)
236.hkdf v0.10.00.2s0.0s (18%)
237.ghash v0.3.00.2s0.1s (46%)
238.num-traits v0.2.14 custom-build (run)0.2s0.0s (0%)default, std
239.typenum v1.12.0 custom-build (run)0.2s0.0s (0%)
240.aes-gcm v0.8.00.2s0.0s (10%)aes, alloc, default
241.lazy_static v1.4.00.2s0.0s (9%)
242.tracing-futures v0.2.40.2s0.0s (7%)pin-project, std, std-future
243.slab v0.4.20.2s0.0s (9%)
244.digest v0.9.00.2s0.0s (17%)alloc, std
245.thiserror v1.0.220.2s0.1s (45%)
246.vec-arena v1.0.00.2s0.0s (11%)
247.fxhash v0.2.10.2s0.0s (23%)
248.async-mutex v1.4.00.2s0.0s (13%)
249.lru-cache v0.1.20.1s0.0s (8%)
250.unicode-xid v0.1.00.1s0.0s (27%)default
251.futures v0.3.80.1s0.0s (7%)alloc, std
252.block-buffer v0.9.00.1s0.0s (13%)
253.indexmap v1.6.0 custom-build (run)0.1s0.0s (0%)
254.hmac v0.10.10.1s0.0s (7%)
255.webpki-roots v0.20.00.1s0.0s (20%)
256.universal-hash v0.4.00.1s0.0s (24%)
257.crypto-mac v0.10.00.1s0.0s (29%)
258.miniz_oxide v0.4.3 custom-build (run)0.1s0.0s (0%)
259.spinning_top v0.2.20.1s0.0s (40%)
260.quick-error v1.2.30.1s0.0s (32%)
261.num-integer v0.1.44 custom-build (run)0.1s0.0s (0%)
262.unicode-width v0.1.80.1s0.0s (9%)default
263.unicase v2.6.0 custom-build (run)0.1s0.0s (0%)
264.copyless v0.1.50.1s0.0s (15%)
265.libz-sys v1.1.20.1s0.0s (11%)libc
266.openssl-sys v0.9.58 custom-build (run)0.1s0.0s (0%)
267.brotli-sys v0.3.20.1s0.0s (14%)
268.futures-sink v0.3.80.1s0.0s (11%)alloc, default, std
269.askama v0.8.00.1s0.0s (9%)default
270.http-types v2.8.0 custom-build (run)0.1s0.0s (0%)async-std, cookie-secure, default, fs
271.pin-project v0.4.270.1s0.0s (12%)
272.standback v0.2.130.1s0.0s (12%)std
273.fnv v1.0.70.1s0.0s (16%)default, std
274.scopeguard v1.1.00.1s0.0s (14%)
275.cpuid-bool v0.1.20.1s0.0s (21%)
276.waker-fn v1.1.00.1s0.0s (22%)
277.cache-padded v1.1.10.1s0.0s (17%)
278.anyhow v1.0.34 custom-build (run)0.1s0.0s (0%)default, std
279.standback v0.2.13 custom-build (run)0.1s0.0s (0%)std
280.time-macros v0.1.10.1s0.0s (27%)
281.pin-project v1.0.20.1s0.0s (13%)
282.proc-macro-nested v0.1.60.1s0.0s (14%)
283.bitflags v1.2.10.1s0.0s (20%)default
284.pin-project-lite v0.2.00.1s0.0s (19%)
285.matches v0.1.80.1s0.0s (12%)
286.pin-project-lite v0.1.110.1s0.0s (18%)
287.match_cfg v0.1.00.1s0.0s (30%)default, use_core
288.instant v0.1.90.1s0.0s (17%)
289.pin-utils v0.1.00.1s0.0s (17%)
290.aes v0.6.00.1s0.0s (16%)
291.opaque-debug v0.3.00.0s0.0s (28%)
292.mime_guess v2.0.3 custom-build (run)0.0s0.0s (0%)default, rev-mappings
293.tinyvec_macros v0.1.00.0s0.0s (22%)
294.generic-array v0.14.4 custom-build (run)0.0s0.0s (0%)
295.crc32fast v1.2.1 custom-build (run)0.0s0.0s (0%)default, std
296.proc-macro2 v0.4.30 custom-build (run)0.0s0.0s (0%)default, proc-macro
297.serde_derive v1.0.117 custom-build (run)0.0s0.0s (0%)default
298.byteorder v1.3.4 custom-build (run)0.0s0.0s (1%)default, std
299.nom v4.2.3 custom-build (run)0.0s0.0s (0%)alloc, default, std
300.proc-macro2 v1.0.24 custom-build (run)0.0s0.0s (0%)default, proc-macro
301.curl-sys v0.4.38+curl-7.73.0 custom-build (run)0.0s0.0s (0%)default, http2, libnghttp2-sys, openssl-sys, ssl
302.pin-project-internal v0.4.27 custom-build (run)0.0s0.0s (0%)
303.syn v0.15.44 custom-build (run)0.0s0.0s (0%)clone-impls, default, derive, parsing, printing, proc-macro, quote
304.libc v0.2.80 custom-build (run)0.0s0.0s (0%)align, default, std
305.cookie v0.14.3 custom-build (run)0.0s0.0s (0%)aes-gcm, base64, hkdf, hmac, key-expansion, percent-encode, percent-encoding, private, rand, secure, sha2, signed
306.httparse v1.3.4 custom-build (run)0.0s0.0s (0%)default, std
307.serde v1.0.117 custom-build (run)0.0s0.0s (0%)default, derive, serde_derive, std
308.proc-macro-hack v0.5.19 custom-build (run)0.0s0.0s (0%)
309.time v0.2.23 custom-build (run)0.0s0.0s (0%)libc, std, stdweb, winapi
310.bitflags v1.2.1 custom-build (run)0.0s0.0s (0%)default
311.serde_json v1.0.59 custom-build (run)0.0s0.0s (0%)default, std
312.ryu v1.0.5 custom-build (run)0.0s0.0s (0%)
313.syn v1.0.50 custom-build (run)0.0s0.0s (0%)clone-impls, default, derive, extra-traits, full, parsing, printing, proc-macro, quote, visit, visit-mut
314.const_fn v0.4.3 custom-build (run)0.0s0.0s (0%)
315.libz-sys v1.1.2 custom-build (run)0.0s0.0s (0%)libc
316.memchr v2.3.4 custom-build (run)0.0s0.0s (0%)default, std, use_std
317.curl v0.4.34 custom-build (run)0.0s0.0s (1%)default, http2, openssl-probe, openssl-sys, ssl
318.isahc v0.9.13 custom-build (run)0.0s0.0s (0%)http2
319.log v0.4.11 custom-build (run)0.0s0.0s (0%)kv_unstable
320.pulldown-cmark v0.8.0 custom-build (run)0.0s0.0s (0%)default, getopts
321.proc-macro-nested v0.1.6 custom-build (run)0.0s0.0s (0%)
322.encoding_rs v0.8.26 custom-build (run)0.0s0.0s (0%)
323.getrandom v0.1.15 custom-build (run)0.0s0.0s (1%)std
- - - diff --git a/rustfmt.toml b/rustfmt.toml index e94c318..3477693 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,4 +1,4 @@ edition = "2018" tab_spaces = 2 hard_tabs = true -max_width = 200 \ No newline at end of file +max_width = 175 \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index fb8b450..c3bed73 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,9 +4,9 @@ use actix_web::{get, App, HttpResponse, HttpServer}; // Reference local files mod popular; mod post; +mod proxy; mod subreddit; mod user; -mod proxy; mod utils; // Create Services diff --git a/src/popular.rs b/src/popular.rs index 436a3f2..7fcd24a 100644 --- a/src/popular.rs +++ b/src/popular.rs @@ -1,7 +1,7 @@ // CRATES -use actix_web::{get, web, HttpResponse, Result, http::StatusCode}; -use askama::Template; use crate::utils::{fetch_posts, ErrorTemplate, Params, Post}; +use actix_web::{get, http::StatusCode, web, HttpResponse, Result}; +use askama::Template; // STRUCTS #[derive(Template)] diff --git a/src/post.rs b/src/post.rs index 10499be..46281f9 100644 --- a/src/post.rs +++ b/src/post.rs @@ -1,9 +1,12 @@ // CRATES -use actix_web::{get, web, HttpResponse, Result, http::StatusCode}; +use crate::utils::{request, val, Comment, ErrorTemplate, Flair, Params, Post}; +use actix_web::{get, http::StatusCode, web, HttpResponse, Result}; use askama::Template; use chrono::{TimeZone, Utc}; use pulldown_cmark::{html, Options, Parser}; -use crate::utils::{request, val, Comment, ErrorTemplate, Flair, Params, Post}; + +#[cfg(feature = "proxy")] +use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC}; // STRUCTS #[derive(Template)] @@ -66,6 +69,14 @@ async fn page(web::Path((_sub, id)): web::Path<(String, String)>, params: web::Q } } +async fn format_url(url: &str) -> String { + #[cfg(feature = "proxy")] + return utf8_percent_encode(url, NON_ALPHANUMERIC).to_string(); + + #[cfg(not(feature = "proxy"))] + return url.to_string(); +} + // UTILITIES async fn media(data: &serde_json::Value) -> String { let post_hint: &str = data["data"]["post_hint"].as_str().unwrap_or(""); @@ -76,15 +87,20 @@ async fn media(data: &serde_json::Value) -> String { let media: String = if !has_media { format!(r#"

{u}

"#, u = data["data"]["url"].as_str().unwrap()) } else { - format!(r#""#, prefix, data["data"]["url"].as_str().unwrap()) + format!( + r#""#, + prefix, + format_url(data["data"]["url"].as_str().unwrap()).await + ) }; match post_hint { "hosted:video" => format!( r#"