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

Freeze in the shortcode replacement func #4653

Closed
bep opened this Issue Apr 20, 2018 · 1 comment

Comments

Projects
None yet
1 participant
@bep
Member

bep commented Apr 20, 2018

Found this by accident when testing some shortcode work. Seems rare (I have done a lot of shortcodes), but the following causes Hugo to freeze (it looks cryptic, but the below is meant to be machine-read):

repl := testShortcodeReplacement{
		Source: "\n\n<p>Testing shortcode vs <code>.Site.Get.Page</code> vs <code>.Content</code> etc.</p>\n\n<h3 id=\"bundle-p1\">Bundle P1!</h3>\n\n<p>HAHAHUGOSHORTCODE-1HBHB</p>\n\n<h3 id=\"current\">Current</h3>\n\n<p>HAHAHUGOSHORTCODE-2HBHB</p>\n",
		Prefix: "HUGOSHORTCODE",
		Replacements: map[string]string{
			"HAHAHUGOSHORTCODE-1HBHB": "\n\n\n\n\n\n\n\n<h3>Resource in shortcode</h3>\n<ul>\n<li>Title: P1 Resource</li>\n<li>Content: \n\n<p>This is P1, a bundled content page.</p>\n\n<h2 id=\"bundle-heading-1\">Bundle heading 1</h2>\n\n<h2 id=\"get-a-section-from-a-bundled-file\">Get a section from a bundled file</h2>\n\n<p>HAHAHUGOSHORTCODE-1HBHB</p>\n</li>\n</ul>\n\n",
			"HAHAHUGOSHORTCODE-2HBHB": "<h3>These will be empty When Called by The Self</h3>\n<ul>\n<li>Content: </li>\n<li>Summary: </li>\n<li>WordCount: 0</li>\n</ul>\n\n<h3>ToC Should Work</h3>\n\n<nav id=\"TableOfContents\">\n<ul>\n<li>\n<ul>\n<li>\n<ul>\n<li><a href=\"#bundle-p1\">Bundle P1!</a></li>\n<li><a href=\"#current\">Current</a></li>\n</ul></li>\n</ul></li>\n</ul>\n</nav>",
		},
	}

@bep bep added the Bug label Apr 20, 2018

@bep bep added this to the v0.39.1 milestone Apr 20, 2018

@bep bep self-assigned this Apr 20, 2018

bep added a commit to bep/hugo that referenced this issue Apr 20, 2018

Make Page.Content lazy loaded
This resolves some surprising behaviour when reading other pages' content from shortcodes. Note that this has never been an issue from regular templates.

Note that it will still not be possible to get **the current shortcode's  page's rendered content**. That would have made Einstein impressed.

Benchmarks shows that doing this is as fast as the old approach. Only better.

Fixes gohugoio#4632
Fixes gohugoio#4653

bep added a commit to bep/hugo that referenced this issue Apr 20, 2018

Make Page.Content lazy loaded
This resolves some surprising behaviour when reading other pages' content from shortcodes. Note that this has never been an issue from regular templates.

Note that it will still not be possible to get **the current shortcode's  page's rendered content**. That would have made Einstein impressed.

Benchmarks shows that doing this is as fast as the old approach. Only better.

Fixes gohugoio#4632
Fixes gohugoio#4653

@bep bep modified the milestones: v0.39.1, v0.40 Apr 20, 2018

bep added a commit to bep/hugo that referenced this issue Apr 20, 2018

Make .Content (almost) always available in shortcodes
This resolves some surprising behaviour when reading other pages' content from shortcodes. Note that this has never been an issue from regular templates.

Note that it will still not be possible to get **the current shortcode's  page's rendered content**. That would have made Einstein impressed.

Benchmarks shows that doing this is as fast as the old approach. Only better.

Fixes gohugoio#4632
Fixes gohugoio#4653

bep added a commit to bep/hugo that referenced this issue Apr 20, 2018

Make .Content (almost) always available in shortcodes
This resolves some surprising behaviour when reading other pages' content from shortcodes. Note that this has never been an issue from regular templates.

Note that it will still not be possible to get **the current shortcode's  page's rendered content**. That would have made Einstein impressed.

Benchmarks shows that doing this is as fast as the old approach. Only better.

Fixes gohugoio#4632
Fixes gohugoio#4653

bep added a commit to bep/hugo that referenced this issue Apr 20, 2018

Make .Content (almost) always available in shortcodes
This resolves some surprising behaviour when reading other pages' content from shortcodes. Note that this has never been an issue from regular templates.

Note that it will still not be possible to get **the current shortcode's  page's rendered content**. That would have made Einstein impressed.

Benchmarks shows that doing this is as fast as the old approach. Only better.

Fixes gohugoio#4632
Fixes gohugoio#4653

bep added a commit to bep/hugo that referenced this issue Apr 20, 2018

Make .Content (almost) always available in shortcodes
This resolves some surprising behaviour when reading other pages' content from shortcodes. Note that this has never been an issue from regular templates.

Note that it will still not be possible to get **the current shortcode's  page's rendered content**. That would have made Einstein impressed.

Benchmarks shows that doing this is as fast as the old approach. Only better.

Fixes gohugoio#4632
Fixes gohugoio#4653

bep added a commit to bep/hugo that referenced this issue Apr 20, 2018

Make .Content (almost) always available in shortcodes
This resolves some surprising behaviour when reading other pages' content from shortcodes. Note that this has never been an issue from regular templates.

Note that it will still not be possible to get **the current shortcode's  page's rendered content**. That would have made Einstein impressed.

Benchmarks shows that doing this is as fast as the old approach. Only better.

Fixes gohugoio#4632
Fixes gohugoio#4653

bep added a commit to bep/hugo that referenced this issue Apr 20, 2018

Make .Content (almost) always available in shortcodes
This resolves some surprising behaviour when reading other pages' content from shortcodes. Note that this has never been an issue from regular templates.

Note that it will still not be possible to get **the current shortcode's  page's rendered content**. That would have made Einstein impressed.

Benchmarks shows that doing this is as fast as the old approach. Only better.

Fixes gohugoio#4632
Fixes gohugoio#4653
@bep

This comment has been minimized.

Member

bep commented Apr 20, 2018

Note that the above is related to #4632 -- and highly unlikely (I think) in Hugo <= 0.39.

bep added a commit to bep/hugo that referenced this issue Apr 20, 2018

Make .Content (almost) always available in shortcodes
This resolves some surprising behaviour when reading other pages' content from shortcodes. Note that this has never been an issue from regular templates.

Note that it will still not be possible to get **the current shortcode's  page's rendered content**. That would have made Einstein impressed.

Benchmarks shows that doing this is as fast as the old approach. Only better.

Fixes gohugoio#4632
Fixes gohugoio#4653

bep added a commit to bep/hugo that referenced this issue Apr 20, 2018

Make .Content (almost) always available in shortcodes
This resolves some surprising behaviour when reading other pages' content from shortcodes. Note that this has never been an issue from regular templates.

Note that it will still not be possible to get **the current shortcode's  page's rendered content**. That would have made Einstein impressed.

Benchmarks shows that doing this is as fast as the old approach. Only better.

Fixes gohugoio#4632
Fixes gohugoio#4653

bep added a commit to bep/hugo that referenced this issue Apr 21, 2018

Make .Content (almost) always available in shortcodes
This resolves some surprising behaviour when reading other pages' content from shortcodes. Note that this has never been an issue from regular templates.

Note that it will still not be possible to get **the current shortcode's  page's rendered content**. That would have made Einstein impressed.

Benchmarks shows that doing this is as fast as the old approach. Only better.

Fixes gohugoio#4632
Fixes gohugoio#4653

bep added a commit to bep/hugo that referenced this issue Apr 21, 2018

Make .Content (almost) always available in shortcodes
This resolves some surprising behaviour when reading other pages' content from shortcodes. Note that this has never been an issue from regular templates.

Note that it will still not be possible to get **the current shortcode's  page's rendered content**. That would have made Einstein impressed.

Benchmarks shows that doing this is as fast as the old approach. Only better.

Fixes gohugoio#4632
Fixes gohugoio#4653
Fixes gohugoio#4655

bep added a commit to bep/hugo that referenced this issue Apr 21, 2018

Make .Content (almost) always available in shortcodes
This resolves some surprising behaviour when reading other pages' content from shortcodes. Note that this has never been an issue from regular templates.

Note that it will still not be possible to get **the current shortcode's  page's rendered content**. That would have made Einstein impressed.

So the current simple rules are:

* `.Page.Content` will be empty. The related `.Page.Truncated` `.Page.Summary`, `.WordCount`, `.ReadingTime`, `.Plain` and `.PlainWords` will also have empty values.
* For _other pages_ (retrieved via `.Page.Site.GetPage`, `.Site.Pages` etc.) the `.Content` there to use as long as you don't have infinite content recursion in your shortcode/content setup. See below.

If you get into a situation of infinite recursion, the `.Content` will be empty. Run `hugo -v` for more information.

Fixes gohugoio#4632
Fixes gohugoio#4653
Fixes gohugoio#4655

bep added a commit to bep/hugo that referenced this issue Apr 21, 2018

Make .Content (almost) always available in shortcodes
This resolves some surprising behaviour when reading other pages' content from shortcodes. Note that this has never been an issue from regular templates.

Note that it will still not be possible to get **the current shortcode's  page's rendered content**. That would have made Einstein impressed.

So the current simple rules are:

* `.Page.Content` will be empty. The related `.Page.Truncated` `.Page.Summary`, `.WordCount`, `.ReadingTime`, `.Plain` and `.PlainWords` will also have empty values.
* For _other pages_ (retrieved via `.Page.Site.GetPage`, `.Site.Pages` etc.) the `.Content` there to use as long as you don't have infinite content recursion in your shortcode/content setup. See below.

If you get into a situation of infinite recursion, the `.Content` will be empty. Run `hugo -v` for more information.

Fixes gohugoio#4632
Fixes gohugoio#4653
Fixes gohugoio#4655

bep added a commit to bep/hugo that referenced this issue Apr 21, 2018

Make .Content (almost) always available in shortcodes
This resolves some surprising behaviour when reading other pages' content from shortcodes. Note that this has never been an issue from regular templates.

Note that it will still not be possible to get **the current shortcode's  page's rendered content**. That would have made Einstein impressed.

So the current simple rules are:

* `.Page.Content` will be empty. The related `.Page.Truncated` `.Page.Summary`, `.WordCount`, `.ReadingTime`, `.Plain` and `.PlainWords` will also have empty values.
* For _other pages_ (retrieved via `.Page.Site.GetPage`, `.Site.Pages` etc.) the `.Content` there to use as long as you don't have infinite content recursion in your shortcode/content setup. See below.

If you get into a situation of infinite recursion, the `.Content` will be empty. Run `hugo -v` for more information.

Fixes gohugoio#4632
Fixes gohugoio#4653
Fixes gohugoio#4655

bep added a commit to bep/hugo that referenced this issue Apr 21, 2018

Make .Content (almost) always available in shortcodes
This resolves some surprising behaviour when reading other pages' content from shortcodes. Note that this has never been an issue from regular templates.

Note that it will still not be possible to get **the current shortcode's  page's rendered content**. That would have made Einstein impressed.

So the current simple rules are:

* `.Page.Content` will be empty. The related `.Page.Truncated` `.Page.Summary`, `.WordCount`, `.ReadingTime`, `.Plain` and `.PlainWords` will also have empty values.
* For _other pages_ (retrieved via `.Page.Site.GetPage`, `.Site.Pages` etc.) the `.Content` is there to use as you please as long as you don't have infinite content recursion in your shortcode/content setup. See below.

If you get into a situation of infinite recursion, the `.Content` will be empty. Run `hugo -v` for more information.

Fixes gohugoio#4632
Fixes gohugoio#4653
Fixes gohugoio#4655

bep added a commit to bep/hugo that referenced this issue Apr 21, 2018

Make .Content (almost) always available in shortcodes
This resolves some surprising behaviour when reading other pages' content from shortcodes. Note that this has never been an issue from regular templates.

Note that it will still not be possible to get **the current shortcode's  page's rendered content**. That would have made Einstein impressed.

So the current simple rules are:

* `.Page.Content` will be empty. The related `.Page.Truncated` `.Page.Summary`, `.WordCount`, `.ReadingTime`, `.Plain` and `.PlainWords` will also have empty values.
* For _other pages_ (retrieved via `.Page.Site.GetPage`, `.Site.Pages` etc.) the `.Content` is there to use as you please as long as you don't have infinite content recursion in your shortcode/content setup. See below.

If you get into a situation of infinite recursion, the `.Content` will be empty. Run `hugo -v` for more information.

Fixes gohugoio#4632
Fixes gohugoio#4653
Fixes gohugoio#4655

bep added a commit to bep/hugo that referenced this issue Apr 21, 2018

Make .Content (almost) always available in shortcodes
This resolves some surprising behaviour when reading other pages' content from shortcodes. Note that this has never been an issue from regular templates.

Note that it will still not be possible to get **the current shortcode's  page's rendered content**. That would have made Einstein impressed.

So the current simple rules are:

* `.Page.Content` will be empty. The related `.Page.Truncated` `.Page.Summary`, `.WordCount`, `.ReadingTime`, `.Plain` and `.PlainWords` will also have empty values.
* For _other pages_ (retrieved via `.Page.Site.GetPage`, `.Site.Pages` etc.) the `.Content` is there to use as you please as long as you don't have infinite content recursion in your shortcode/content setup. See below.

If you get into a situation of infinite recursion, the `.Content` will be empty. Run `hugo -v` for more information.

Fixes gohugoio#4632
Fixes gohugoio#4653
Fixes gohugoio#4655

bep added a commit to bep/hugo that referenced this issue Apr 21, 2018

Make .Content (almost) always available in shortcodes
This resolves some surprising behaviour when reading other pages' content from shortcodes. Note that this has never been an issue from regular templates.

Note that it will still not be possible to get **the current shortcode's  page's rendered content**. That would have made Einstein impressed.

So the current simple rules are:

* `.Page.Content` from a shortcode will be empty. The related `.Page.Truncated` `.Page.Summary`, `.Page.WordCount`, `.Page.ReadingTime`, `.Page.Plain` and `.Page.PlainWords` will also have empty values.
* For _other pages_ (retrieved via `.Page.Site.GetPage`, `.Site.Pages` etc.) the `.Content` is there to use as you please as long as you don't have infinite content recursion in your shortcode/content setup. See below.
* `.Page.TableOfContents` is good to go (but does not support shortcodes in headlines; this is unchanged)

If you get into a situation of infinite recursion, the `.Content` will be empty. Run `hugo -v` for more information.

Fixes gohugoio#4632
Fixes gohugoio#4653
Fixes gohugoio#4655

bep added a commit to bep/hugo that referenced this issue Apr 21, 2018

Make .Content (almost) always available in shortcodes
This resolves some surprising behaviour when reading other pages' content from shortcodes. Before this commit, that behaviour has been undefined. Note that this has never been an issue from regular templates.

It will still not be possible to get **the current shortcode's  page's rendered content**. That would have impressed Einstein.

The new and well defined rules are:

* `.Page.Content` from a shortcode will be empty. The related `.Page.Truncated` `.Page.Summary`, `.Page.WordCount`, `.Page.ReadingTime`, `.Page.Plain` and `.Page.PlainWords` will also have empty values.
* For _other pages_ (retrieved via `.Page.Site.GetPage`, `.Site.Pages` etc.) the `.Content` is there to use as you please as long as you don't have infinite content recursion in your shortcode/content setup. See below.
* `.Page.TableOfContents` is good to go (but does not support shortcodes in headlines; this is unchanged)

If you get into a situation of infinite recursion, the `.Content` will be empty. Run `hugo -v` for more information.

Fixes gohugoio#4632
Fixes gohugoio#4653
Fixes gohugoio#4655

bep added a commit to bep/hugo that referenced this issue Apr 21, 2018

Make .Content (almost) always available in shortcodes
This resolves some surprising behaviour when reading other pages' content from shortcodes. Before this commit, that behaviour has been undefined. Note that this has never been an issue from regular templates.

It will still not be possible to get **the current shortcode's  page's rendered content**. That would have impressed Einstein.

The new and well defined rules are:

* `.Page.Content` from a shortcode will be empty. The related `.Page.Truncated` `.Page.Summary`, `.Page.WordCount`, `.Page.ReadingTime`, `.Page.Plain` and `.Page.PlainWords` will also have empty values.
* For _other pages_ (retrieved via `.Page.Site.GetPage`, `.Site.Pages` etc.) the `.Content` is there to use as you please as long as you don't have infinite content recursion in your shortcode/content setup. See below.
* `.Page.TableOfContents` is good to go (but does not support shortcodes in headlines; this is unchanged)

If you get into a situation of infinite recursion, the `.Content` will be empty. Run `hugo -v` for more information.

Fixes gohugoio#4632
Fixes gohugoio#4653
Fixes gohugoio#4655

bep added a commit to bep/hugo that referenced this issue Apr 21, 2018

Make .Content (almost) always available in shortcodes
This resolves some surprising behaviour when reading other pages' content from shortcodes. Before this commit, that behaviour has been undefined. Note that this has never been an issue from regular templates.

It will still not be possible to get **the current shortcode's  page's rendered content**. That would have impressed Einstein.

The new and well defined rules are:

* `.Page.Content` from a shortcode will be empty. The related `.Page.Truncated` `.Page.Summary`, `.Page.WordCount`, `.Page.ReadingTime`, `.Page.Plain` and `.Page.PlainWords` will also have empty values.
* For _other pages_ (retrieved via `.Page.Site.GetPage`, `.Site.Pages` etc.) the `.Content` is there to use as you please as long as you don't have infinite content recursion in your shortcode/content setup. See below.
* `.Page.TableOfContents` is good to go (but does not support shortcodes in headlines; this is unchanged)

If you get into a situation of infinite recursion, the `.Content` will be empty. Run `hugo -v` for more information.

Fixes gohugoio#4632
Fixes gohugoio#4653
Fixes gohugoio#4655

bep added a commit to bep/hugo that referenced this issue Apr 21, 2018

Make .Content (almost) always available in shortcodes
This resolves some surprising behaviour when reading other pages' content from shortcodes. Before this commit, that behaviour has been undefined. Note that this has never been an issue from regular templates.

It will still not be possible to get **the current shortcode's  page's rendered content**. That would have impressed Einstein.

The new and well defined rules are:

* `.Page.Content` from a shortcode will be empty. The related `.Page.Truncated` `.Page.Summary`, `.Page.WordCount`, `.Page.ReadingTime`, `.Page.Plain` and `.Page.PlainWords` will also have empty values.
* For _other pages_ (retrieved via `.Page.Site.GetPage`, `.Site.Pages` etc.) the `.Content` is there to use as you please as long as you don't have infinite content recursion in your shortcode/content setup. See below.
* `.Page.TableOfContents` is good to go (but does not support shortcodes in headlines; this is unchanged)

If you get into a situation of infinite recursion, the `.Content` will be empty. Run `hugo -v` for more information.

Fixes gohugoio#4632
Fixes gohugoio#4653
Fixes gohugoio#4655

bep added a commit to bep/hugo that referenced this issue Apr 21, 2018

Make .Content (almost) always available in shortcodes
This resolves some surprising behaviour when reading other pages' content from shortcodes. Before this commit, that behaviour has been undefined. Note that this has never been an issue from regular templates.

It will still not be possible to get **the current shortcode's  page's rendered content**. That would have impressed Einstein.

The new and well defined rules are:

* `.Page.Content` from a shortcode will be empty. The related `.Page.Truncated` `.Page.Summary`, `.Page.WordCount`, `.Page.ReadingTime`, `.Page.Plain` and `.Page.PlainWords` will also have empty values.
* For _other pages_ (retrieved via `.Page.Site.GetPage`, `.Site.Pages` etc.) the `.Content` is there to use as you please as long as you don't have infinite content recursion in your shortcode/content setup. See below.
* `.Page.TableOfContents` is good to go (but does not support shortcodes in headlines; this is unchanged)

If you get into a situation of infinite recursion, the `.Content` will be empty. Run `hugo -v` for more information.

Fixes gohugoio#4632
Fixes gohugoio#4653
Fixes gohugoio#4655

bep added a commit to bep/hugo that referenced this issue Apr 21, 2018

Make .Content (almost) always available in shortcodes
This resolves some surprising behaviour when reading other pages' content from shortcodes. Before this commit, that behaviour was undefined. Note that this has never been an issue from regular templates.

It will still not be possible to get **the current shortcode's  page's rendered content**. That would have impressed Einstein.

The new and well defined rules are:

* `.Page.Content` from a shortcode will be empty. The related `.Page.Truncated` `.Page.Summary`, `.Page.WordCount`, `.Page.ReadingTime`, `.Page.Plain` and `.Page.PlainWords` will also have empty values.
* For _other pages_ (retrieved via `.Page.Site.GetPage`, `.Site.Pages` etc.) the `.Content` is there to use as you please as long as you don't have infinite content recursion in your shortcode/content setup. See below.
* `.Page.TableOfContents` is good to go (but does not support shortcodes in headlines; this is unchanged)

If you get into a situation of infinite recursion, the `.Content` will be empty. Run `hugo -v` for more information.

Fixes gohugoio#4632
Fixes gohugoio#4653
Fixes gohugoio#4655

bep added a commit to bep/hugo that referenced this issue Apr 21, 2018

Make .Content (almost) always available in shortcodes
This resolves some surprising behaviour when reading other pages' content from shortcodes. Before this commit, that behaviour was undefined. Note that this has never been an issue from regular templates.

It will still not be possible to get **the current shortcode's  page's rendered content**. That would have impressed Einstein.

The new and well defined rules are:

* `.Page.Content` from a shortcode will be empty. The related `.Page.Truncated` `.Page.Summary`, `.Page.WordCount`, `.Page.ReadingTime`, `.Page.Plain` and `.Page.PlainWords` will also have empty values.
* For _other pages_ (retrieved via `.Page.Site.GetPage`, `.Site.Pages` etc.) the `.Content` is there to use as you please as long as you don't have infinite content recursion in your shortcode/content setup. See below.
* `.Page.TableOfContents` is good to go (but does not support shortcodes in headlines; this is unchanged)

If you get into a situation of infinite recursion, the `.Content` will be empty. Run `hugo -v` for more information.

Fixes gohugoio#4632
Fixes gohugoio#4653
Fixes gohugoio#4655

bep added a commit to bep/hugo that referenced this issue Apr 21, 2018

Make .Content (almost) always available in shortcodes
This resolves some surprising behaviour when reading other pages' content from shortcodes. Before this commit, that behaviour was undefined. Note that this has never been an issue from regular templates.

It will still not be possible to get **the current shortcode's  page's rendered content**. That would have impressed Einstein.

The new and well defined rules are:

* `.Page.Content` from a shortcode will be empty. The related `.Page.Truncated` `.Page.Summary`, `.Page.WordCount`, `.Page.ReadingTime`, `.Page.Plain` and `.Page.PlainWords` will also have empty values.
* For _other pages_ (retrieved via `.Page.Site.GetPage`, `.Site.Pages` etc.) the `.Content` is there to use as you please as long as you don't have infinite content recursion in your shortcode/content setup. See below.
* `.Page.TableOfContents` is good to go (but does not support shortcodes in headlines; this is unchanged)

If you get into a situation of infinite recursion, the `.Content` will be empty. Run `hugo -v` for more information.

Fixes gohugoio#4632
Fixes gohugoio#4653
Fixes gohugoio#4655

@bep bep closed this in #4651 Apr 21, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment