-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
resources/page: Escaping colon in permalinks erroneously throws error in some circumstances #12948
Comments
If we keep the feature I'll move this comment to a separate issue. This currently works in front matter:
This currently fails in the site configuration (colon omitted from file path):
This test case covers both front matter and site configuration: func TestPermalinksWithEscapedColons(t *testing.T) {
t.Parallel()
files := `
-- hugo.toml --
disableKinds = ['home','rss','section','sitemap','taxonomy','term']
[permalinks.page]
s2 = "/c\\:d/:slug/"
-- content/s1/p1.md --
---
title: p1
url: "/a\\:b/:slug/"
---
-- content/s2/p2.md --
---
title: p2
---
-- layouts/_default/single.html --
{{ .Title }}
`
b := hugolib.Test(t, files)
b.AssertFileExists("public/a:b/p1/index.html", true)
b.AssertFileExists("public/c:d/p2/index.html", true)
} |
@jmooring I have fixed this in #12951 -- but I needed to adjust the test case a little. I have added a comment. The test case looks a little odd, but opening up for colons in Hugo generated paths would create mayhem. I think this falls into the category of "the |
Understood. Use with I'm not fond of this rabbit hole either, and would support removing it. |
Yea, well, maybe. The thing is, this was already possible before we added permalink tokens to the front matter There's many characters that's allowed in func isAllowedPathCharacter(s string, i int, r rune) bool {
if r == ' ' {
return false
}
// Check for the most likely first (faster).
isAllowed := unicode.IsLetter(r) || unicode.IsDigit(r)
isAllowed = isAllowed || r == '.' || r == '/' || r == '\\' || r == '_' || r == '#' || r == '+' || r == '~' || r == '-' || r == '@'
isAllowed = isAllowed || unicode.IsMark(r)
isAllowed = isAllowed || (r == '%' && i+2 < len(s) && ishex(s[i+1]) && ishex(s[i+2]))
return isAllowed
} |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I found this while attempting to document how to escape a colon.
With this front matter:
Hugo throws an error:
Although not related to this bug, if I had taken the time to weigh in on the original proposal I would have expressed my concerns about OS compatibility. You cannot use this feature on Windows because the path cannot contain a colon (restricted character). We will have to note in the documentation that you can't use this feature on Windows, but that won't really help for projects with multiple contributors where some use Windows.
The existing tests pass on Windows because they don't write to disk.
I think we should consider removing this feature.
The text was updated successfully, but these errors were encountered: