Commit graph

6750 commits

Author SHA1 Message Date
Bjørn Erik Pedersen 9af4ca3861 deps: Upgrade github.com/evanw/esbuild v0.14.8 => v0.14.11 2022-01-11 20:31:50 +01:00
Bjørn Erik Pedersen 7396aa945a Add hugo.Deps
Fixes #8949
2022-01-11 18:06:23 +01:00
roointan d82cef5c53
hugolib: Fix livereload problem with files including NFC characters in MacOs
Fixes #8429
2022-01-08 11:35:30 +01:00
Bjørn Erik Pedersen 74f0777c5f
docs. Regen CLI docs
Closes #9363
2022-01-07 12:37:07 +01:00
Bjørn Erik Pedersen e334a40661
commands: Fix CLI help text for hugo new
Updates #9363
2022-01-07 12:36:12 +01:00
Bjørn Erik Pedersen 5bd3c8df40
Update to Go 1.17.6
Fixes #9361
2022-01-07 11:07:42 +01:00
Joe Mooring 0aca99fe01 create: Correctly pass newContentEditor flags
Fixes #9356
2022-01-07 10:46:32 +01:00
Bjørn Erik Pedersen c8b5ab75b7 Add --panicOnWarning flag
Fixes #9357
Fixes #9359
2022-01-06 12:27:04 +01:00
Bjørn Erik Pedersen 85c5b89593
github: Increase stale days 2022-01-05 15:48:00 +01:00
Bjørn Erik Pedersen 965760835d
docs: Regenerate CLI docs 2022-01-04 17:12:09 +01:00
Bjørn Erik Pedersen 4a0b55330c
docs: Regenerate docshelper 2022-01-04 17:11:17 +01:00
Bjørn Erik Pedersen 1651beb2c1 Remove mmark
Closes #9350
2022-01-04 17:10:39 +01:00
Bjørn Erik Pedersen 2b6063c3e3 Misc depreation updates
* Deprecate .Page.Path when backed by a file
* site.Permalinks
* --ignoreVendor (use --ignoreVendorPaths)

Closes #9348
Closes #9349
2022-01-04 17:10:39 +01:00
Bjørn Erik Pedersen 56ab83a597 Make the deprecated Page/File methods (from Hugo 0.55) ERROR
Closes #9346
2022-01-04 17:10:39 +01:00
Bjørn Erik Pedersen dad0dc8d86
github: Add add stale GitHub action 2022-01-04 17:08:10 +01:00
Paul Gottschling d3c4fdb8ff Fix surprise OutputFormat.Rel overwriting
In page.NewOutputFormat, we take an output.Format f and use it to
create a page.OutputFormat. If the format is canonical, we assign
the final OutputFormat's Rel to "canonical" rather than using
f.Rel. However, this leads to unexpected behavior for custom
output formats, where a user can define a "rel" for a format
via the config file.

For example, the standard for "humans.txt" files requires using
rel="author" in HTML "link" elements. Meanwhile, humans.txt is
usually the only format used for its content. As a result, for
Hugo configurations that define a humans.txt custom output format,
Hugo will render "link" elements to content in this format with
rel="canonical," rather than "author" as required by the standard.

This commit changes page.NewOutputFormat to check whether a given
format is user defined and, if so, skips assigning Rel to
"canonical," even if isCanonical is true.

Fixes #8030
2022-01-04 10:38:38 +01:00
Bjørn Erik Pedersen d632dd7d74
hugolib: Make an RST test optional
If no RST installed.
2022-01-01 12:20:07 +01:00
Joe Mooring 0671ef5593 deps: Upgrade github.com/niklasfasching/go-org v1.5.0 => v1.6.0
Fixes #8921
2021-12-30 22:40:43 +01:00
Bjørn Erik Pedersen 672481f1f0
Update stale.yml 2021-12-30 20:13:08 +01:00
hugoreleaser 1dbfc0f930 releaser: Prepare repository for 0.92.0-DEV
[ci skip]
2021-12-23 16:10:18 +00:00
hugoreleaser 1798bd3fd1 releaser: Bump versions for release of 0.91.2
[ci skip]
2021-12-23 15:33:33 +00:00
hugoreleaser f0b55a68ee releaser: Add release notes for 0.91.2
[ci skip]
2021-12-23 15:33:33 +00:00
Bjørn Erik Pedersen 623dda7174 Revert "config/security: Add HOME to default exec env var whitelist"
There have been one report in the wild suggesting that this needs to be tested better before doing:

https://discourse.gohugo.io/t/hugo-mod-failing-in-v0-91-1-but-works-in-v0-91-0/36180/5

This reverts commit fca266ebbb.
2021-12-23 16:23:15 +01:00
Bjørn Erik Pedersen aee9e11a40 Make sure we always create the /public folder
* Before this commit, when you had static files in the root of /content and no /public folder, that folder would not be created unless the /static syncer had already run.
* So, with a common pattern doing `rm -rf public && hugo` would the fail now and then because /static and /content are processed in parallel (unless you have cleanDestinationDir=true)
* This was even worse before commit 0b918e131f – a frozen build.

Closes #8166
2021-12-23 15:09:27 +01:00
Bjørn Erik Pedersen bd63c1aa56 Fix "stuck on build" in error situations in content processing
Updates #8166
2021-12-23 15:09:27 +01:00
Bjørn Erik Pedersen 9eb05807c6 deps: Run "go mod tidy" 2021-12-23 10:19:10 +01:00
Bjørn Erik Pedersen 654f513a4c deps: Upgrade github.com/evanw/esbuild v0.14.7 => v0.14.8 2021-12-23 10:19:10 +01:00
hugoreleaser 759cdf3fc8 releaser: Prepare repository for 0.92.0-DEV
[ci skip]
2021-12-22 16:07:34 +00:00
hugoreleaser f423505746 releaser: Bump versions for release of 0.91.1
[ci skip]
2021-12-22 15:31:05 +00:00
hugoreleaser af165d5b6d releaser: Add release notes for 0.91.1
[ci skip]
2021-12-22 15:31:05 +00:00
Bjørn Erik Pedersen 6779117f72 media: Also consider extension in FromContent
As used in `resources.GetRemote`.

This will now reject image files with text and text files with images.
2021-12-22 11:35:53 +01:00
Bjørn Erik Pedersen ce04011096 media: Add missing BMP and GIF to the default MediaTypes list 2021-12-22 11:35:53 +01:00
Bjørn Erik Pedersen cdc73526a8 media: Add PDF MIME type 2021-12-22 11:35:53 +01:00
Bjørn Erik Pedersen 425c7d90f0 deps: Update github.com/evanw/esbuild v0.14.5 => v0.14.7 2021-12-22 11:34:21 +01:00
Bjørn Erik Pedersen fca266ebbb config/security: Add HOME to default exec env var whitelist
See #9309
2021-12-22 11:33:59 +01:00
Bjørn Erik Pedersen 0016e21cd6 modules: Set GOCACHE env var
This was introduced in Go 1.15. We do set the GOPATH, which should be enough, but #9309 indicate that's not the case on every platform (GitHub Actions).

Closes #9309
2021-12-22 11:33:59 +01:00
hugoreleaser 728feaecf0 releaser: Prepare repository for 0.92.0-DEV
[ci skip]
2021-12-17 10:31:22 +00:00
hugoreleaser d1dc0e9a54 releaser: Bump versions for release of 0.91.0
[ci skip]
2021-12-17 09:50:19 +00:00
hugoreleaser 072bca69d8 releaser: Add release notes for 0.91.0
[ci skip]
2021-12-17 09:50:19 +00:00
Bjørn Erik Pedersen e26e13fbb7
releaser: Drop running tests as part of the release 2021-12-17 10:44:10 +01:00
Bjørn Erik Pedersen 6df2f080c9
docs: Regen docs helper 2021-12-17 10:31:08 +01:00
Bjørn Erik Pedersen b84745d497
tpl/resources: Add empty method mapping for GetRemote
To get auto generated documentation for it.
2021-12-17 10:30:10 +01:00
Bjørn Erik Pedersen 44954497bc
Always use content to resolve content type in resources.GetRemote
This is a security hardening measure; don't trust the URL extension or any `Content-Type`/`Content-Disposition` header on its own, always look at the file content using Go's `http.DetectContentType`.

This commit also adds ttf and otf media type definitions to Hugo.

Fixes #9302
Fixes #9301
2021-12-17 09:50:28 +01:00
Bjørn Erik Pedersen 22ef5da20d
Add resources.GetRemote
In Hugo 0.89 we added remote support to `resources.Get`.

In hindsight that was not a great idea, as a poll from many Hugo users showed. See Issue #9285 for more details.

After this commit `resources.Get` only supports local resource lookups. If you want to support both, you need to use a construct similar to:

Also improve some option case handling.

```
{{ resource := "" }}
{{ if (urls.Parse $url).IsAbs }}
{{ $resource = resources.GetRemote $url }}
{{ else }}
{{ $resource = resources.Get $url }}
{{ end }}
```

Fixes #9285
Fixes #9296
2021-12-17 09:33:51 +01:00
Paul Gottschling 5758c370ea
Allow for return partials with falsy arguments (#9298)
Partials with returns values are parsed, then inserted into a
partial return wrapper via wrapInPartialReturnWrapper in order
to assign the return value via *contextWrapper.Set. The
predefined wrapper template for partials inserts a partial's nodes
into a "with" template action in order to set dot to a
*contextWrapper within the partial. However, because "with" is
skipped if its argument is falsy, partials with falsy arguments
were not being evaluated.

This replaces the "with" action in the partial wrapper with a
"range" action that isn't skipped if .Arg is falsy.

Fixes #7528
2021-12-17 08:35:21 +01:00
Bjørn Erik Pedersen 8ee6de6d96 deps: Upgrade github.com/evanw/esbuild v0.14.2 => v0.14.5 2021-12-17 08:26:45 +01:00
Joachim Ansorg a4b9f1a92c don't use path.Join, because it cleans the final path 2021-12-16 21:14:33 +01:00
Bjørn Erik Pedersen f4389e48ce
Add some basic security policies with sensible defaults
This ommmit contains some security hardening measures for the Hugo build runtime.

There are some rarely used features in Hugo that would be good to have disabled by default. One example would be the "external helpers".

For `asciidoctor` and some others we use Go's `os/exec` package to start a new process.

These are a predefined set of binary names, all loaded from `PATH` and with a predefined set of arguments. Still, if you don't use `asciidoctor` in your project, you might as well have it turned off.

You can configure your own in the new `security` configuration section, but the defaults are configured to create a minimal amount of site breakage. And if that do happen, you will get clear instructions in the loa about what to do.

The default configuration is listed below. Note that almost all of these options are regular expression _whitelists_ (a string or a slice); the value `none` will block all.

```toml
[security]
  enableInlineShortcodes = false
  [security.exec]
    allow = ['^dart-sass-embedded$', '^go$', '^npx$', '^postcss$']
    osEnv = ['(?i)^(PATH|PATHEXT|APPDATA|TMP|TEMP|TERM)$']

  [security.funcs]
    getenv = ['^HUGO_']

  [security.http]
    methods = ['(?i)GET|POST']
    urls = ['.*']
```
2021-12-16 09:40:22 +01:00
Bjørn Erik Pedersen 803f572e66
Simplify Babel test assertions
To make the tests pass on my grand old Windows 8 VM.
2021-12-14 07:26:53 +01:00
Bjørn Erik Pedersen 6183184b96
Merge commit '45e6fdb315d113ba13e20a633ed0c67e3f25170d' 2021-12-13 21:05:10 +01:00