Browse Source

Percent decode paths on zola serve

master
Vincent Prouillet 5 months ago
parent
commit
ccad454922
4 changed files with 9 additions and 1 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +1
    -0
      Cargo.lock
  3. +1
    -0
      Cargo.toml
  4. +6
    -1
      src/cmd/serve.rs

+ 1
- 0
CHANGELOG.md View File

@ -21,6 +21,7 @@ content
- Remove `zola serve --watch-only`: since we build the HTML in memory and not on disk, it doesn't make sense anymore
- Update clojure syntax
- Prefer extra syntaxes to the default ones if we have a match for language
- Fix `zola serve` having issues with non-ascii paths
## 0.12.2 (2020-09-28)


+ 1
- 0
Cargo.lock View File

@ -3263,6 +3263,7 @@ dependencies = [
"lazy_static",
"notify",
"open",
"percent-encoding",
"relative-path",
"serde_json",
"site",


+ 1
- 0
Cargo.toml View File

@ -29,6 +29,7 @@ url = "2"
# Below is for the serve cmd
hyper = { version = "0.14.1", default-features = false, features = ["runtime", "server", "http2", "http1"] }
tokio = { version = "1.0.1", default-features = false, features = ["rt", "fs"] }
percent-encoding = "2"
notify = "4"
ws = "0.9"
ctrlc = "3"


+ 6
- 1
src/cmd/serve.rs View File

@ -72,8 +72,13 @@ const LIVE_RELOAD: &str = include_str!("livereload.js");
async fn handle_request(req: Request<Body>, mut root: PathBuf) -> Result<Response<Body>> {
let mut path = RelativePathBuf::new();
// https://zola.discourse.group/t/percent-encoding-for-slugs/736
let decoded = match percent_encoding::percent_decode_str(req.uri().path()).decode_utf8() {
Ok(d) => d,
Err(_) => return Ok(not_found()),
};
for c in req.uri().path().split('/') {
for c in decoded.split('/') {
path.push(c);
}


Loading…
Cancel
Save