gohugoio / hugo

The world’s fastest framework for building websites.
https://gohugo.io
Apache License 2.0
75.62k stars 7.52k forks source link

Panic on resource publish when mkdir: file name is too long #4240

Closed biodranik closed 6 years ago

biodranik commented 6 years ago

I'm using Mac OS X 10.13.2. This is content which causes bug:

content/news/folder/index.md
content/news/folder/image.jpg

Detailed bug description is below:

---
# This is frontmatter of content/news/folder/index.md
# This long slug crashes hugo if any image is copied into content/news/folder/
# The shorter version of the slug with an image generates percent-encoded path for the image together with a correctly utf-8-encoded path for the index.html file.
# This and shorter slugs work correctly without image in content/news/folder/
slug: очень-длинная-строка-для-того-чтобы-крешнуть-самый-лучший-статический-генератор
---

I see at least two erors:

goroutine 27 [running]: log.Panicln(0xc420ccb900, 0x1, 0x1) /usr/local/Cellar/go/1.9.2/libexec/src/log/log.go:340 +0xc0 github.com/gohugoio/hugo/vendor/github.com/spf13/afero.WriteReader(0x2b07360, 0x2b8ce00, 0xc4210ba000, 0x22e, 0x2afb0e0, 0xc4208739e8, 0x2afb1a0, 0xc420e80d20) /private/tmp/hugo-20180108-44182-1t9hvji/hugo-0.32.3/src/github.com/gohugoio/hugo/vendor/github.com/spf13/afero/util.go:49 +0x24f github.com/gohugoio/hugo/helpers.WriteToDisk(0xc4210ba000, 0x22e, 0x2afb0e0, 0xc4208739e8, 0x2b07360, 0x2b8ce00, 0x0, 0xc420f8b480) /private/tmp/hugo-20180108-44182-1t9hvji/hugo-0.32.3/src/github.com/gohugoio/hugo/helpers/path.go:532 +0x5d github.com/gohugoio/hugo/resource.(genericResource).Publish(0xc4212a1570, 0x0, 0x0) /private/tmp/hugo-20180108-44182-1t9hvji/hugo-0.32.3/src/github.com/gohugoio/hugo/resource/resource.go:272 +0x1da github.com/gohugoio/hugo/hugolib.(PageOutput).renderResources(0xc420f8b440, 0xc420ffc0a0, 0x1a61b01) /private/tmp/hugo-20180108-44182-1t9hvji/hugo-0.32.3/src/github.com/gohugoio/hugo/hugolib/page_output.go:294 +0xd1 github.com/gohugoio/hugo/hugolib.pageRenderer(0xc42035b8c0, 0xc420c7a840, 0xc420c7a7e0, 0xc421535fe0) /private/tmp/hugo-20180108-44182-1t9hvji/hugo-0.32.3/src/github.com/gohugoio/hugo/hugolib/site_render.go:115 +0xa29 created by github.com/gohugoio/hugo/hugolib.(*Site).renderPages /private/tmp/hugo-20180108-44182-1t9hvji/hugo-0.32.3/src/github.com/gohugoio/hugo/hugolib/site_render.go:45 +0x153

bep commented 6 years ago

slug: очень-длинная-строка-для-того-чтобы-крешнуть-самый-лучший-статический-генератор

Does it crash if you make the above ... short?

biodranik commented 6 years ago

No, but incorrectly generates percent-encoded path, as I described in comments to the slug.

bep commented 6 years ago

No, but incorrectly generates percent-encoded path,

Can you create a separate issue for that.

bep commented 6 years ago

The fix for this particular issue is to not panic, i.e. return a proper error that gets logged. The "filename too long" is OS dependent and not something we want to validate.

biodranik commented 6 years ago

Just checked, /bin/mkdir has a hard-coded limit of 256 characters in the path on Mac OS X 10.13

biodranik commented 6 years ago

However, this panic is a minor issue, the major one is that any .Resource generates an incorrect percent-encoded path.

bep commented 6 years ago

Howewer, this panic is a minor issue, the major one is that any .Resource generates an incorrect percent-encoded path.

Sure. But you use an ascii slug and it will work.

biodranik commented 6 years ago

It's inconsistent with alias in FrontMatter which correctly generates UTF-8 encoded folders for index.html. Why does slug use percent-encoding but alias does not?

biodranik commented 6 years ago

No, it is even worse: alias and slug work in the same way (correctly) without any images in subsection (.Page.Resource), but if you put any image slug stops working.

github-actions[bot] commented 2 years ago

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.