Skip to content

text/template: A terminator is erroneously detected in a field that starts with the same character as the right delimiter #52165

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

Closed
mprahl opened this issue Apr 5, 2022 · 1 comment
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@mprahl
Copy link
Contributor

mprahl commented Apr 5, 2022

What version of Go are you using (go version)?

$ go version                                          
go version go1.18 linux/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/mprahl/.cache/go-build"
GOENV="/home/mprahl/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/mprahl/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/mprahl/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.18"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/mprahl/git/go/src/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build4256537278=/tmp/go-build -gno-record-gcc-switches"

What did you do?

package main

import (
	"os"
	"text/template"
)

func main() {
	tmpl, err := template.New("test").Delims("{{hub", "hub}}").Parse(`{{hub .Object.host hub}}`)
	if err != nil {
		panic(err)
	}

	err = tmpl.Execute(os.Stdout, struct{ Object map[string]string }{map[string]string{"host": "value"}})
	if err != nil {
		panic(err)
	}
}

What did you expect to see?

go run test.go
value

What did you see instead?

go run test.go
panic: template: test:1: unexpected <.> in operand

goroutine 1 [running]:
main.main()
        /tmp/test.go:11 +0x2ba
exit status 2
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/398475 mentions this issue: text/template: Fix terminator detection in fields

@seankhliao seankhliao added the NeedsFix The path to resolution is known, but the work has not been done. label Apr 5, 2022
@dmitshur dmitshur added this to the Go1.19 milestone May 16, 2022
@golang golang locked and limited conversation to collaborators May 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants