Skip to content

Commit e4ad0c5

Browse files
committed
Never sanitize when url set in front matter
Fixes gohugoio#12954
1 parent a2f666b commit e4ad0c5

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

‎resources/page/page_paths.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ func CreateTargetPaths(d TargetPathDescriptor) (tp TargetPaths) {
254254

255255
// if page URL is explicitly set in frontmatter,
256256
// preserve its value without sanitization
257-
if d.Kind != kinds.KindPage || d.URL == "" {
257+
if d.URL == "" {
258258
// Note: MakePathSanitized will lower case the path if
259259
// disablePathToLower isn't set.
260260
pb.Sanitize()

‎resources/page/permalinks_integration_test.go‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ slug: custom-recipe-2
235235
}
236236

237237
// Issue 12948.
238+
// Issue 12954.
238239
func TestPermalinksWithEscapedColons(t *testing.T) {
239240
t.Parallel()
240241

@@ -244,9 +245,14 @@ func TestPermalinksWithEscapedColons(t *testing.T) {
244245

245246
files := `
246247
-- hugo.toml --
247-
disableKinds = ['home','rss','section','sitemap','taxonomy','term']
248+
disableKinds = ['home','rss','sitemap','taxonomy','term']
248249
[permalinks.page]
249250
s2 = "/c\\:d/:slug/"
251+
-- content/s1/_index.md --
252+
---
253+
title: s1
254+
url: "/a\\:b/:slug/"
255+
---
250256
-- content/s1/p1.md --
251257
---
252258
title: p1
@@ -258,13 +264,16 @@ title: p2
258264
---
259265
-- layouts/_default/single.html --
260266
{{ .Title }}
267+
-- layouts/_default/list.html --
268+
{{ .Title }}
261269
`
262270

263271
b := hugolib.Test(t, files)
264272

265273
b.AssertFileExists("public/a:b/p1/index.html", true)
274+
b.AssertFileExists("public/a:b/s1/index.html", true)
266275

267-
// The above URL comes from the URL front matter field where everything is allowed.
276+
// The above URLs come from the URL front matter field where everything is allowed.
268277
// We strip colons from paths constructed by Hugo (they are not supported on Windows).
269278
b.AssertFileExists("public/cd/p2/index.html", true)
270279
}

0 commit comments

Comments
 (0)