mygit

[UNMAINTAINED] A cgit/webgit alternative, written in Rust
Log | Files | Refs | README | LICENSE

commit a4259e3b27bfb32a6e8adcfeaa5686bc9e5f1680
parent 88a500cbd9d29366a791202c347bae6ab215fd33
Author: Johann150 <johann@qwertqwefsday.eu>
Date:   Mon, 15 Mar 2021 18:57:40 +0100

percent decode repository name

Diffstat:
MCargo.lock | 1+
MCargo.toml | 1+
Msrc/main.rs | 3+++
3 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock @@ -1127,6 +1127,7 @@ dependencies = [ "chrono", "git2", "once_cell", + "percent-encoding", "pico-args", "pulldown-cmark", "serde", diff --git a/Cargo.toml b/Cargo.toml @@ -15,6 +15,7 @@ async-std = { version = "1.8.0", features = ["attributes"] } chrono = "0.4" git2 = {version="0.13", default-features = false} once_cell = "1.7.2" +percent-encoding = "2.1" pico-args = "0.4" pulldown-cmark = "0.8" serde = { version = "1.0", features = ["derive"] } diff --git a/src/main.rs b/src/main.rs @@ -84,6 +84,9 @@ struct RepoHomeTemplate { } fn repo_from_request(repo_name: &str) -> Result<Repository> { + let repo_name = percent_encoding::percent_decode_str(repo_name) + .decode_utf8_lossy() + .into_owned(); let repo_path = Path::new(&CONFIG.repo_directory).join(repo_name); // TODO CLEAN PATH! VERY IMPORTANT! DONT FORGET! let r = Repository::open(repo_path)?;