Skip to content
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

Panic for invalid shortcode argument syntax #10860

Closed
willfaught opened this issue Mar 23, 2023 · 1 comment
Closed

Panic for invalid shortcode argument syntax #10860

willfaught opened this issue Mar 23, 2023 · 1 comment

Comments

@willfaught
Copy link

I was trying this:

{{< paige/social (slice
    (dict
        "class" "bi bi-github"
        "name" "GitHub"
        "url" "https://github.com/willfaught/paige"
    )
) >}}

with this shortcodes/paige/social.html:

{{ $items := .Get 0 | default (.Get "items") }}

<p class="display-6 paige-social text-center">
    {{ partial "paige/social.html" $items }}
</p>

and this partials/paige/social.html:

{{ $page := . }}

<span>
    {{ range $k, $v := $page.Param "paige.social" }}
        {{ if hasPrefix $v.link "mailto:" }}
            <a class="mx-2" href="#" data-a="{{ base64Encode (index (split $v.url `@`) 0) }}" data-b="{{ base64Encode `@` }}" data-c="{{ base64Encode (index (split $v.url `@`) 1) }}" onclick="this.href = atob(this.dataset.a) + atob(this.dataset.b) + atob(this.dataset.c)"><i class="{{ $v.class }}"><span class="visually-hidden">{{ $v.name }}</span></i></a>
        {{ else }}
            <a class="mx-2" href="{{ $v.url }}"><i class="{{ $v.class }}"><span class="visually-hidden">{{ $v.name }}</span></i></a>
        {{ end }}
    {{ end }}
</span>

I was getting this error, and changing the code in a few ways to see if I could work around it:

"/Users/Will/Developer/paige/exampleSite/content/_index.md:1:1": unrecognized character in shortcode action: U+0028 '('. Note: Parameters with non-alphanumeric args must be quoted 

I noticed about 10 minutes into it that hugo server had crashed:

Change detected, rebuilding site.
2023-03-22 16:55:16.872 -0700
Source changed WRITE         "/Users/Will/Developer/paige/exampleSite/content/_index.md"
Total in 234 ms

Change detected, rebuilding site.
2023-03-22 16:56:33.373 -0700
Source changed WRITE         "/Users/Will/Developer/paige/exampleSite/content/_index.md"
ERROR 2023/03/22 16:56:33 Rebuild failed: "/Users/Will/Developer/paige/exampleSite/content/_index.md:1:1": unrecognized character in shortcode action: U+0028 '('. Note: Parameters with non-alphanumeric args must be quoted
Total in 194 ms

Change detected, rebuilding site.
2023-03-22 16:59:55.871 -0700
Template changed WRITE         "/Users/Will/Developer/paige/layouts/partials/paige/social.html"
Source changed WRITE         "/Users/Will/Developer/paige/exampleSite/content/_index.md"
ERROR 2023/03/22 16:59:56 Rebuild failed: "/Users/Will/Developer/paige/exampleSite/content/_index.md:1:1": unrecognized character in shortcode action: U+0028 '('. Note: Parameters with non-alphanumeric args must be quoted
Total in 216 ms

Change detected, rebuilding site.
2023-03-22 17:00:02.871 -0700
Template changed WRITE         "/Users/Will/Developer/paige/layouts/shortcodes/paige/social.html"
Source changed WRITE         "/Users/Will/Developer/paige/exampleSite/content/_index.md"
ERROR 2023/03/22 17:00:03 Rebuild failed: "/Users/Will/Developer/paige/exampleSite/content/_index.md:1:1": unrecognized character in shortcode action: U+0028 '('. Note: Parameters with non-alphanumeric args must be quoted
Total in 210 ms

Change detected, rebuilding site.
2023-03-22 17:01:25.871 -0700
Source changed WRITE         "/Users/Will/Developer/paige/exampleSite/content/_index.md"
Total in 192 ms
panic: html/template: cannot Clone "" after it has executed

goroutine 3577 [running]:
github.com/gohugoio/hugo/tpl/internal/go_templates/htmltemplate.Must(...)
	github.com/gohugoio/hugo/tpl/internal/go_templates/htmltemplate/template.go:369
github.com/gohugoio/hugo/tpl/tplimpl.(*templateNamespace).createPrototypes(0xc0040558c0)
	github.com/gohugoio/hugo/tpl/tplimpl/template.go:994 +0xab
github.com/gohugoio/hugo/tpl/tplimpl.(*templateExec).MarkReady.func1()
	github.com/gohugoio/hugo/tpl/tplimpl/template.go:320 +0x45
sync.(*Once).doSlow(0xc007539bb3?, 0xcd?)
	sync/once.go:74 +0xc2
sync.(*Once).Do(...)
	sync/once.go:65
github.com/gohugoio/hugo/tpl/tplimpl.(*templateExec).MarkReady(0xc002d1f418?)
	github.com/gohugoio/hugo/tpl/tplimpl/template.go:317 +0x65
github.com/gohugoio/hugo/hugolib.newHugoSites.func2({0xc002d1f3e0, 0x1001121b1})
	github.com/gohugoio/hugo/hugolib/hugo_sites.go:376 +0x7c
github.com/gohugoio/hugo/lazy.(*Init).Do.func1()
	github.com/gohugoio/hugo/lazy/init.go:108 +0xe7
github.com/gohugoio/hugo/lazy.(*onceMore).Do(0x0?, 0x0?)
	github.com/gohugoio/hugo/lazy/once.go:53 +0x10d
github.com/gohugoio/hugo/lazy.(*Init).Do(0xc0008a23f0, {0x10248a570?, 0xc0000b6008?})
	github.com/gohugoio/hugo/lazy/init.go:89 +0x65
github.com/gohugoio/hugo/lazy.(*Init).Do.func1()
	github.com/gohugoio/hugo/lazy/init.go:113 +0x1a5
github.com/gohugoio/hugo/lazy.(*onceMore).Do(0xc00489b410?, 0xc0021fcfa8?)
	github.com/gohugoio/hugo/lazy/once.go:53 +0x10d
github.com/gohugoio/hugo/lazy.(*Init).Do(0xc0008a2230, {0x10248a570?, 0xc0000b6008?})
	github.com/gohugoio/hugo/lazy/init.go:89 +0x65
github.com/gohugoio/hugo/hugolib.(*HugoSites).render(0xc0000fecc0, 0xc006aa2000)
	github.com/gohugoio/hugo/hugolib/hugo_sites_build.go:271 +0x5a
github.com/gohugoio/hugo/hugolib.(*HugoSites).Build.func4()
	github.com/gohugoio/hugo/hugolib/hugo_sites_build.go:146 +0x2a
runtime/trace.WithRegion({0x10248a5e0?, 0xc002e60180?}, {0x101debbd1, 0x6}, 0xc002d1f8e8)
	runtime/trace/annotation.go:141 +0xe3
github.com/gohugoio/hugo/hugolib.(*HugoSites).Build(0xc0000fecc0, {0x0, {0x0, 0x0}, 0x0, 0x0, 0x0, 0x1, 0xc002e60150, 0x0, ...}, ...)
	github.com/gohugoio/hugo/hugolib/hugo_sites_build.go:148 +0x5f3
github.com/gohugoio/hugo/commands.(*commandeer).rebuildSites(0xc00085aa00, {0xc004328060?, 0x1?, 0x1?})
	github.com/gohugoio/hugo/commands/hugo.go:766 +0x346
github.com/gohugoio/hugo/commands.(*commandeer).handleEvents.func4(0xc00085aa00, 0xc004328018)
	github.com/gohugoio/hugo/commands/hugo.go:1162 +0x96
github.com/gohugoio/hugo/commands.(*commandeer).handleEvents(0xc00085aa00, 0xc005db9cb0, 0xc005033248, {0xc002ccc000?, 0x2, 0x2}, 0x0?)
	github.com/gohugoio/hugo/commands/hugo.go:1165 +0x13be
github.com/gohugoio/hugo/commands.(*commandeer).newWatcher.func1()
	github.com/gohugoio/hugo/commands/hugo.go:896 +0x24b
created by github.com/gohugoio/hugo/commands.(*commandeer).newWatcher
	github.com/gohugoio/hugo/commands/hugo.go:887 +0x4ca

I can't reproduce it locally by undoing/redoing.

I assume the crash is related to the invalid shortcode argument syntax.

What version of Hugo are you using?

$ hugo env
hugo env
hugo v0.111.3+extended darwin/amd64 BuildDate=unknown
GOOS="darwin"
GOARCH="amd64"
GOVERSION="go1.20.2"
github.com/sass/libsass="3.6.5"
github.com/webmproject/libwebp="v1.2.4"
github.com/sass/dart-sass-embedded/protocol="1.2.0"
github.com/sass/dart-sass-embedded/compiler="1.59.3"
github.com/sass/dart-sass-embedded/implementation="1.59.3"

Does this issue reproduce with the latest release?

Yes

@bep bep removed the NeedsTriage label Mar 29, 2023
@bep bep added this to the v0.112.0 milestone Mar 29, 2023
@bep bep modified the milestones: v0.112.0, v0.113.0 Apr 15, 2023
@bep bep modified the milestones: v0.113.0, v0.114.0, v0.115.0 Jun 8, 2023
@bep bep modified the milestones: v0.115.0, v0.116.0 Jun 30, 2023
@bep bep modified the milestones: v0.116.0, v0.117.0 Aug 1, 2023
@bep bep modified the milestones: v0.117.0, v0.118.0 Aug 30, 2023
@bep bep modified the milestones: v0.118.0, v0.119.0 Sep 15, 2023
@bep bep modified the milestones: v0.119.0, v0.120.0 Oct 5, 2023
@bep bep modified the milestones: v0.120.0, v0.121.0 Oct 31, 2023
@bep bep modified the milestones: v0.121.0, v0.122.0 Dec 6, 2023
@bep bep modified the milestones: v0.122.0, v0.123.0, v0.124.0 Jan 27, 2024
@bep bep modified the milestones: v0.124.0, v0.125.0 Mar 4, 2024
@jmooring jmooring added the Stale label Apr 8, 2024
@github-actions github-actions bot closed this as completed Jun 4, 2024
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants