8000 golang template parse error while parsing index.html · Issue #373 · hypermodeinc/ratel · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

golang template parse error while parsing index.html #373

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

Open
fre 8000 ddyisaac opened this issue Mar 26, 2025 · 2 comments
Open

golang template parse error while parsing index.html #373

freddyisaac opened this issue Mar 26, 2025 · 2 comments

Comments

@freddyisaac
Copy link

Describe the bug

The file client/build/index.html throws an error when parsed by the golang html/template package.

To Reproduce

Steps to reproduce the behavior:

  1. build server using ./scripts/build.prod.sh --server
  2. execute the server ./build/ratel

Expected behavior

I would have expected the error not to occur

Screenshots

The exact error is

panic: Error parsing "index.html" contents

goroutine 1 [running]:
github.com/dgraph-io/ratel/server.prepareIndexContent()
/home/freddy.isaac/projects/ratel/server/server.go:112 +0x4c8
github.com/dgraph-io/ratel/server.Run()
/home/freddy.isaac/projects/ratel/server/server.go:42 +0x25
main.main()
/home/freddy.isaac/projects/ratel/main.go:11 +0xf

It is occurring on line 17 of the file index.html which is currently

       function isTemplateAnnotation(str) {
            return (
                str.indexOf("{{") === 0 &&
                str.lastIndexOf("}}") === str.length - 2
            );
        }

However changing this code to be

       function isTemplateAnnotation(str) {
            return str.indexOf("{{") === 0 && str.lastIndexOf("}}") === str.length - 2;
        }

does however parse OK!

I believe that this may be an issue with the golang html/template package and have opened a ticket here to clarify

golang/go#73061

Environment

  • OS: Ubuntu
  • Go
  • v1.24.1 but I have verified this back as far as v1.16

Additional context

Copy link
linear bot commented Mar 26, 2025

@freddyisaac
Copy link
Author
freddyisaac commented Mar 26, 2025

Of course the golang people just closed it a functions as designed so I decided to play with it a bit
If you use

<script>
		function foo(str) {
                return str.indexOf({{"{{"}}) === 0 &&
                    str.lastIndexOf("}}") === str.length - 2;
            }
</script>

The you get this

<script>
		function foo(str) {
                return str.indexOf("{{") === 0 &&
                    str.lastIndexOf("}}") === str.length - 2;
            }
</script>

which may be what was intended ?

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

No branches or pull requests

2 participants
0