]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
Never sanitize when url set in front matter
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 16 Oct 2024 14:59:12 +0000 (16:59 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 16 Oct 2024 16:01:11 +0000 (18:01 +0200)
Fixes #12954

resources/page/page_paths.go
resources/page/permalinks_integration_test.go

index 4826ed5f9b14360e9ede363c3770fabecb941835..ea22eab8198efe03eb7ad49941acfb8d37e760c6 100644 (file)
@@ -254,7 +254,7 @@ func CreateTargetPaths(d TargetPathDescriptor) (tp TargetPaths) {
 
        // if page URL is explicitly set in frontmatter,
        // preserve its value without sanitization
-       if d.Kind != kinds.KindPage || d.URL == "" {
+       if d.URL == "" {
                // Note: MakePathSanitized will lower case the path if
                // disablePathToLower isn't set.
                pb.Sanitize()
index 4188c70ca0cd576d7ff00e8bfbb3a0366a51484f..52bcd6860804176702432948cc1e6f14d5cebccd 100644 (file)
@@ -235,6 +235,7 @@ slug: custom-recipe-2
 }
 
 // Issue 12948.
+// Issue 12954.
 func TestPermalinksWithEscapedColons(t *testing.T) {
        t.Parallel()
 
@@ -244,9 +245,14 @@ func TestPermalinksWithEscapedColons(t *testing.T) {
 
        files := `
 -- hugo.toml --
-disableKinds = ['home','rss','section','sitemap','taxonomy','term']
+disableKinds = ['home','rss','sitemap','taxonomy','term']
 [permalinks.page]
 s2 = "/c\\:d/:slug/"
+-- content/s1/_index.md --
+---
+title: s1
+url: "/a\\:b/:slug/"
+---
 -- content/s1/p1.md --
 ---
 title: p1
@@ -258,13 +264,16 @@ title: p2
 ---
 -- layouts/_default/single.html --
 {{ .Title }}
+-- layouts/_default/list.html --
+{{ .Title }}
 `
 
        b := hugolib.Test(t, files)
 
        b.AssertFileExists("public/a:b/p1/index.html", true)
+       b.AssertFileExists("public/a:b/s1/index.html", true)
 
-       // The above URL comes from the URL front matter field where everything is allowed.
+       // The above URLs come from the URL front matter field where everything is allowed.
        // We strip colons from paths constructed by Hugo (they are not supported on Windows).
        b.AssertFileExists("public/cd/p2/index.html", true)
 }