πŸ’Ύ Archived View for lists.flounder.online β€Ί patches β€Ί threads β€Ί 20210315175744.6493-1-johann@qwertqw… captured on 2022-07-16 at 16:25:44. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2022-04-28)

-=-=-=-=-=-=-

[PATCH mygit 1/5] percent decode repository name

[PATCH mygit 1/5] percent decode repository name

From: johann@qwertqwefsday.eu

Date: Mon, 15 Mar 2021 18:57:40 +0100

Message-Id: 20210315175744.6493-1-johann@qwertqwefsday.eu

To: <~aw/patches@lists.sr.ht>

Cc: "Johann150" <johann@qwertqwefsday.eu>

Reply

Export

--------------------------------------

From: Johann150 <johann@qwertqwefsday.eu>

---

Cargo.lock | 1 +

Cargo.toml | 1 +

src/main.rs | 3 +++

3 files changed, 5 insertions(+)

diff --git a/Cargo.lock b/Cargo.lock

index 677d1e4..6da49e6 100644

--- 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

index 49c992f..9515e55 100644

--- 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

index 6ad1499..9f264ab 100644

--- 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)?;

--

2.20.1

Re: [PATCH mygit 1/5] percent decode repository name

From: alex@alexwennerberg.com

Date: Mon, 15 Mar 2021 12:01:44 -0700

Message-Id: C9Y5O3EFDVMX.38PU2L9KTC47S@debian-alex

To: "Johann Galle" <johann@qwertqwefsday.eu>, <~aw/patches@lists.sr.ht>

In-Reply-To: 20210315175744.6493-1-johann@qwertqwefsday.eu

Reply

Export

--------------------------------------

Hi these look good! I'm on lunch break so I don't have time to look into

this in detail -- but my only question is about the first patch -- the

other 4 are ready to apply. Is there a way to do this that uses the tide

crate itself rather than another crate? I havent checked but it seems

like something I would expect the crate to be able to do

Alex

On Mon Mar 15, 2021 at 10:57 AM PDT, Johann Galle wrote:

From: Johann150 <johann@qwertqwefsday.eu>
---
Cargo.lock | 1 +
Cargo.toml | 1 +
src/main.rs | 3 +++
3 files changed, 5 insertions(+)
diff --git a/Cargo.lock b/Cargo.lock
index 677d1e4..6da49e6 100644
--- 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
index 49c992f..9515e55 100644
--- 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
index 6ad1499..9f264ab 100644
--- 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)?;
--
2.20.1

Re: [PATCH mygit 1/5] percent decode repository name

From: johann@qwertqwefsday.eu

Date: Mon, 15 Mar 2021 21:54:32 +0100

Message-Id: 5d3834d5-8da1-c5d6-a7dc-a5ee16820eaf@qwertqwefsday.eu

To: "Alex Wennerberg" <alex@alexwennerberg.com>, <~aw/patches@lists.sr.ht>

In-Reply-To: C9Y5O3EFDVMX.38PU2L9KTC47S@debian-alex

Reply

Export

--------------------------------------

On 2021-03-15T20:01+01:00, Alex Wennerberg wrote:

Hi these look good! I'm on lunch break so I don't have time to look into this in detail -- but my only question is about the first patch -- the other 4 are ready to apply. Is there a way to do this that uses the tide crate itself rather than another crate? I havent checked but it seems like something I would expect the crate to be able to do

That is something I also wondered and tried to find on <https://docs.rs/tide>. Searching for "percent", "url", "encode" or "decode" did not bring anything up. Same results for the re-exportet http-types crate. But anyway we were already indirectly dependent on the percent-encoding crate [1], so the meaning of adding this to our Crates.toml only means that we can now also access it.

[1] more completely, we get this inverse dependency tree for it:

$ cargo tree -i percent-encoding

percent-encoding v2.1.0

β”œβ”€β”€ askama_shared v0.11.1

β”‚Β Β  β”œβ”€β”€ askama v0.10.5

β”‚Β Β  β”‚Β Β  β”œβ”€β”€ askama_tide v0.13.0

β”‚Β Β  β”‚Β Β  β”‚Β Β  └── grifter v0.1.0

β”‚Β Β  β”‚Β Β  └── grifter v0.1.0

β”‚Β Β  └── askama_derive v0.10.5 (proc-macro)

β”‚Β Β Β Β Β Β  └── askama v0.10.5 (*)

β”œβ”€β”€ cookie v0.14.4

β”‚Β Β  └── http-types v2.10.0

β”‚Β Β Β Β Β Β  β”œβ”€β”€ async-h1 v2.3.2

β”‚Β Β Β Β Β Β  β”‚Β Β  └── tide v0.16.0

β”‚Β Β Β Β Β Β  β”‚Β Β Β Β Β Β  β”œβ”€β”€ askama_tide v0.13.0 (*)

β”‚Β Β Β Β Β Β  β”‚Β Β Β Β Β Β  └── grifter v0.1.0

β”‚Β Β Β Β Β Β  β”œβ”€β”€ async-sse v4.1.0

β”‚Β Β Β Β Β Β  β”‚Β Β  └── tide v0.16.0 (*)

β”‚Β Β Β Β Β Β  β”œβ”€β”€ http-client v6.3.4

β”‚Β Β Β Β Β Β  β”‚Β Β  └── tide v0.16.0 (*)

β”‚Β Β Β Β Β Β  └── tide v0.16.0 (*)

β”œβ”€β”€ form_urlencoded v1.0.1

β”‚Β Β  β”œβ”€β”€ serde_urlencoded v0.7.0

β”‚Β Β  β”‚Β Β  └── http-types v2.10.0 (*)

β”‚Β Β  └── url v2.2.1

β”‚Β Β Β Β Β Β  β”œβ”€β”€ git2 v0.13.17

β”‚Β Β Β Β Β Β  β”‚Β Β  └── grifter v0.1.0

β”‚Β Β Β Β Β Β  └── http-types v2.10.00 (*)

β”œβ”€β”€ grifter v0.1.0

β”œβ”€β”€ serde_qs v0.7.2

β”‚Β Β  └── http-types v2.10.0 (*)

└── url v2.2.1 (*)

Re: [PATCH mygit 1/5] percent decode repository name

From: alex@alexwennerberg.com

Date: Mon, 15 Mar 2021 16:22:39 -0700

Message-Id: A43A6913-A1B7-4B7A-959D-E9CEBA269AF2@alexwennerberg.com

To: "Johann Galle" <johann@qwertqwefsday.eu>

In-Reply-To: 5d3834d5-8da1-c5d6-a7dc-a5ee16820eaf@qwertqwefsday.eu

Cc: <~aw/patches@lists.sr.ht>

Reply

Export

--------------------------------------

Makes sense to me. I’ll merge these as soon as I get home

Alex

On Mar 15, 2021, at 1:54 PM, Johann Galle <johann@qwertqwefsday.eu> wrote:
ο»ΏOn 2021-03-15T20:01+01:00, Alex Wennerberg wrote:
> Hi these look good! I'm on lunch break so I don't have time to look into this in detail -- but my only question is about the first patch -- the other 4 are ready to apply. Is there a way to do this that uses the tide crate itself rather than another crate? I havent checked but it seems like something I would expect the crate to be able to do
That is something I also wondered and tried to find on <https://docs.rs/tide>. Searching for "percent", "url", "encode" or "decode" did not bring anything up. Same results for the re-exportet http-types crate. But anyway we were already indirectly dependent on the percent-encoding crate [1], so the meaning of adding this to our Crates.toml only means that we can now also access it.
[1] more completely, we get this inverse dependency tree for it:
$ cargo tree -i percent-encoding
percent-encoding v2.1.0
β”œβ”€β”€ askama_shared v0.11.1
β”‚ β”œβ”€β”€ askama v0.10.5
β”‚ β”‚ β”œβ”€β”€ askama_tide v0.13.0
β”‚ β”‚ β”‚ └── grifter v0.1.0
β”‚ β”‚ └── grifter v0.1.0
β”‚ └── askama_derive v0.10.5 (proc-macro)
β”‚ └── askama v0.10.5 (*)
β”œβ”€β”€ cookie v0.14.4
β”‚ └── http-types v2.10.0
β”‚ β”œβ”€β”€ async-h1 v2.3.2
β”‚ β”‚ └── tide v0.16.0
β”‚ β”‚ β”œβ”€β”€ askama_tide v0.13.0 (*)
β”‚ β”‚ └── grifter v0.1.0
β”‚ β”œβ”€β”€ async-sse v4.1.0
β”‚ β”‚ └── tide v0.16.0 (*)
β”‚ β”œβ”€β”€ http-client v6.3.4
β”‚ β”‚ └── tide v0.16.0 (*)
β”‚ └── tide v0.16.0 (*)
β”œβ”€β”€ form_urlencoded v1.0.1
β”‚ β”œβ”€β”€ serde_urlencoded v0.7.0
β”‚ β”‚ └── http-types v2.10.0 (*)
β”‚ └── url v2.2.1
β”‚ β”œβ”€β”€ git2 v0.13.17
β”‚ β”‚ └── grifter v0.1.0
β”‚ └── http-types v2.10.00 (*)
β”œβ”€β”€ grifter v0.1.0
β”œβ”€β”€ serde_qs v0.7.2
β”‚ └── http-types v2.10.0 (*)
└── url v2.2.1 (*)