hugo/hugolib
Bjørn Erik Pedersen 4e14cf7607
Fail with error when double-rendering text in markdownify/RenderString
This commit prevents the most commons case of infinite recursion in link render hooks when the `linkify` option is enabled (see below). This is always a user error, but getting a `stack overflow` (the current stack limit in Go is 1 GB on 64-bit, 250 MB on 32-bit) error isn't very helpful. This fix will not prevent all such errors, though, but we may do better once #9570 is in place.

So, these will fail:

```
<a href="{{ .Destination | safeURL }}" >{{ .Text | markdownify }}</a>
<a href="{{ .Destination | safeURL }}" >{{ .Text | .Page.RenderString }}</a>
```

`.Text` is already rendered to `HTML`. The above needs to be rewritten to:

```
<a href="{{ .Destination | safeURL }}" >{{ .Text | safeHTML }}</a>
<a href="{{ .Destination | safeURL }}" >{{ .Text | safeHTML }}</a>
```

Fixes #8959
2022-03-10 08:19:03 +01:00
..
assets/images Image resource refactor 2019-08-26 15:00:44 +02:00
filesystems Allow rendering static files to disk and dynamic to memory in server mode 2022-03-08 19:27:54 +01:00
paths Misc config loading fixes 2021-06-14 17:00:32 +02:00
testdata Add some basic security policies with sensible defaults 2021-12-16 09:40:22 +01:00
testsite Add support for CODEOWNERS 2022-02-23 22:43:19 +01:00
404_test.go all: Format code with gofumpt 2020-12-03 13:12:58 +01:00
alias.go tpl/fmt: Add erroridf template func 2021-06-07 19:11:03 +02:00
alias_test.go Add lang attribute to internal alias template 2022-03-09 19:06:59 +01:00
breaking_changes_test.go all: Fix minor typos 2020-12-16 12:11:32 +01:00
cascade_test.go Fix BenchmarkCascadeTarget 2022-02-16 13:23:43 +01:00
case_insensitive_test.go all: Format code with gofumpt 2020-12-03 13:12:58 +01:00
codeowners.go Rename Codeowners() to CodeOwners() 2022-02-27 19:40:07 +01:00
collections.go tpl/fmt: Add erroridf template func 2021-06-07 19:11:03 +02:00
collections_test.go tests: Convert from testify to quicktest 2019-08-12 13:26:32 +02:00
config.go Misc depreation updates 2022-01-04 17:10:39 +01:00
config_test.go config: Set HUGO_ENABLEGITINFO=false override in Set_in_string 2021-10-22 19:40:18 +02:00
configdir_test.go Switch to go-toml v2 2021-07-28 11:51:13 +02:00
content_factory.go Improve error when we cannot determine content directory in "hugo new" 2021-11-15 11:21:39 +01:00
content_factory_test.go Fix path resolution in hugo new 2021-11-08 14:10:46 +01:00
content_map.go hugofs: Make FileMeta a struct 2021-07-15 17:14:26 +02:00
content_map_page.go Add support for CODEOWNERS 2022-02-23 22:43:19 +01:00
content_map_test.go hugofs: Make FileMeta a struct 2021-07-15 17:14:26 +02:00
content_render_hooks_test.go Add Markdown diagrams and render hooks for code blocks 2022-02-24 18:59:50 +01:00
datafiles_test.go all: Format code with gofumpt 2020-12-03 13:12:58 +01:00
dates_test.go Fix error handling for the time func alias 2021-08-01 13:39:30 +02:00
disableKinds_test.go all: Format code with gofumpt 2020-12-03 13:12:58 +01:00
embedded_shortcodes_test.go deps: Update github.com/alecthomas/chroma v0.9.4 => v0.10.0 2022-02-15 10:37:14 +01:00
embedded_templates_test.go Remove empty href element from pagination template 2021-12-02 09:14:30 +01:00
fileInfo.go all: Format code with gofumpt 2020-12-03 13:12:58 +01:00
fileInfo_test.go tests: Convert from testify to quicktest 2019-08-12 13:26:32 +02:00
gitinfo.go all: Format code with gofumpt 2020-12-03 13:12:58 +01:00
hugo_modules_test.go Fix duplicate mount sources 2022-01-26 20:32:13 +01:00
hugo_sites.go Rename Codeowners() to CodeOwners() 2022-02-27 19:40:07 +01:00
hugo_sites_build.go Add a cross process build lock and use it in the archetype content builder 2021-10-18 12:13:13 +02:00
hugo_sites_build_errors_test.go Misc config loading fixes 2021-06-14 17:00:32 +02:00
hugo_sites_build_test.go Add lang attribute to internal alias template 2022-03-09 19:06:59 +01:00
hugo_sites_multihost_test.go all: Format code with gofumpt 2020-12-03 13:12:58 +01:00
hugo_sites_rebuild_test.go all: Format code with gofumpt 2020-12-03 13:12:58 +01:00
hugo_smoke_test.go Add hugo.Deps 2022-01-11 18:06:23 +01:00
image_test.go Misc config loading fixes 2021-06-14 17:00:32 +02:00
integrationtest_builder.go Remove the trailing new line in .Code 2022-02-26 21:54:36 +01:00
language_content_dir_test.go Add Markdown diagrams and render hooks for code blocks 2022-02-24 18:59:50 +01:00
language_test.go Reduce binary size vs locale, update to CLDR v36.1 2021-08-02 19:40:32 +02:00
menu_test.go Improve handling of <nil> Params 2021-07-30 21:07:52 +02:00
minify_publisher_test.go Misc config loading fixes 2021-06-14 17:00:32 +02:00
mount_filters_test.go Fix panic when specifying multiple excludeFiles directives 2021-10-25 19:50:18 +02:00
multilingual.go all: Format code with gofumpt 2020-12-03 13:12:58 +01:00
page.go markup/goldmark/codeblocks: Fix slice bounds out of range 2022-03-08 21:50:21 +01:00
page__common.go Add support for CODEOWNERS 2022-02-23 22:43:19 +01:00
page__content.go all: Format code with gofumpt 2020-12-03 13:12:58 +01:00
page__data.go all: Format code with gofumpt 2020-12-03 13:12:58 +01:00
page__menus.go Simplify "active menu" logic for section menus 2021-07-20 17:50:59 +02:00
page__meta.go Fix erroneous warning with .Page.RenderString on a page without a backing file 2022-01-28 17:35:49 +01:00
page__new.go Add Markdown diagrams and render hooks for code blocks 2022-02-24 18:59:50 +01:00
page__output.go Make the RenderString content provider fix more general 2022-01-27 11:51:13 +01:00
page__paginator.go all: Format code with gofumpt 2020-12-03 13:12:58 +01:00
page__paths.go all: Format code with gofumpt 2020-12-03 13:12:58 +01:00
page__per_output.go Fail with error when double-rendering text in markdownify/RenderString 2022-03-10 08:19:03 +01:00
page__position.go all: Format code with gofumpt 2020-12-03 13:12:58 +01:00
page__ref.go all: Format code with gofumpt 2020-12-03 13:12:58 +01:00
page__tree.go all: Format code with gofumpt 2020-12-03 13:12:58 +01:00
page_kinds.go all: Format code with gofumpt 2020-12-03 13:12:58 +01:00
page_permalink_test.go all: Format code with gofumpt 2020-12-03 13:12:58 +01:00
page_test.go Add lang attribute to internal alias template 2022-03-09 19:06:59 +01:00
page_unwrap.go Make Page an interface 2019-03-23 18:51:22 +01:00
page_unwrap_test.go Add render template hooks for links and images 2019-12-18 11:44:40 +01:00
pagebundler_test.go Add Markdown diagrams and render hooks for code blocks 2022-02-24 18:59:50 +01:00
pagecollections.go hugofs: Make FileMeta a struct 2021-07-15 17:14:26 +02:00
pagecollections_test.go all: Format code with gofumpt 2020-12-03 13:12:58 +01:00
pages_capture.go hugofs: Make FileMeta a struct 2021-07-15 17:14:26 +02:00
pages_capture_test.go Reimplement archetypes 2021-10-16 15:22:03 +02:00
pages_language_merge_test.go Fix BenchmarkMergeByLanguage 2020-12-09 17:47:10 +01:00
pages_process.go Allow rendering static files to disk and dynamic to memory in server mode 2022-03-08 19:27:54 +01:00
pages_test.go Add a benchmark 2021-05-04 17:59:04 +02:00
paginator_test.go all: Format code with gofumpt 2020-12-03 13:12:58 +01:00
permalinker.go all: Format code with gofumpt 2020-12-03 13:12:58 +01:00
prune_resources.go cache/filecache: Add a cache prune func 2018-11-14 23:14:51 +01:00
resource_chain_test.go deps: Update github.com/tdewolff/minify/v2 v2.9.22 => v2.9.29 2022-02-15 17:36:29 +01:00
robotstxt_test.go Misc config loading fixes 2021-06-14 17:00:32 +02:00
rss_test.go tests: Convert from testify to quicktest 2019-08-12 13:26:32 +02:00
securitypolicies_test.go Add resources.GetRemote 2021-12-17 09:33:51 +01:00
shortcode.go Add some basic security policies with sensible defaults 2021-12-16 09:40:22 +01:00
shortcode_page.go Add render template hooks for links and images 2019-12-18 11:44:40 +01:00
shortcode_test.go Remove mmark 2022-01-04 17:10:39 +01:00
site.go Allow rendering static files to disk and dynamic to memory in server mode 2022-03-08 19:27:54 +01:00
site_benchmark_new_test.go Add a TOML front matter benchmark 2021-07-27 19:27:54 +02:00
site_output.go all: Format code with gofumpt 2020-12-03 13:12:58 +01:00
site_output_test.go Fix surprise OutputFormat.Rel overwriting 2022-01-04 10:38:38 +01:00
site_render.go tpl/fmt: Add erroridf template func 2021-06-07 19:11:03 +02:00
site_sections.go Add Markdown diagrams and render hooks for code blocks 2022-02-24 18:59:50 +01:00
site_sections_test.go all: Format code with gofumpt 2020-12-03 13:12:58 +01:00
site_stats_test.go all: Format code with gofumpt 2020-12-03 13:12:58 +01:00
site_test.go Misc depreation updates 2022-01-04 17:10:39 +01:00
site_url_test.go all: Format code with gofumpt 2020-12-03 13:12:58 +01:00
siteJSONEncode_test.go all: Format code with gofumpt 2020-12-03 13:12:58 +01:00
sitemap_test.go tpl/embedded: Exclude pages without Permalink from sitemap 2021-02-06 18:30:09 +01:00
taxonomy.go Simplify page tree logic 2019-08-08 20:13:39 +02:00
taxonomy_test.go all: Fix minor typos 2020-12-16 12:11:32 +01:00
template_test.go tpl/collections: Fix apply with namespaced template funcs 2022-01-17 09:50:48 +01:00
testhelpers_test.go Add a migration test helper 2022-02-09 16:38:12 +01:00
translations.go Introduce a tree map for all content 2020-02-18 09:49:42 +01:00