gofiber / gofiber/template

Clarification Request: Why are template layout no longer being cloned?

Open
#216 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
314
Forks
61
Avg merge
4h 35m
Merged PRs (30d)
12

Description

Hi,

I was trying to adapt the template loading and embedding logic for my Echo-based project when I noticed this part here:

https://github.com/gofiber/template/blob/2fde445c06e9f7695cc0f549ef73121640849788/html/html.go#L211

I expected to see lay.Clone() being called here, because the current solution attaches the embed func globally. This could be a potential security threat, if someone ends up rendering main.html by mistake.

Checking the history, I saw that there was a version that cloned the template, but it was replaced, because a cloned template cannot be executed multiple times. But if you are always only executing the copy, why would the original template get executed in the first place?

I would love to hear your thoughts.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with html/html.go around line 211, then review the referenced history showing the change from lay.Clone() and the discussion about repeated execution. Reproduce the template-loading path if possible and determine whether the original template can be rendered unintentionally. Done means the intended behavior and any required follow-up are clearly agreed.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.