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

Use text/template instead of html/template for config pre-processing #4656

Merged
merged 1 commit into from
Feb 7, 2025

Conversation

hansmi
Copy link
Contributor

@hansmi hansmi commented Feb 4, 2025

Commit c95311d added support for multiple config formats in addition to pre-processing using Go's built-in templating system. The html/template package is equivalent to text/template, except that the former automatically escapes characters for inclusion in HTML.

Configurations aren't plain text, but they're also certainly no HTML. The difference between the packages is noticeable when using printf "%q" for quoting of strings. An example from the included unittest:

  • html/template: key = "with space"
  • text/template: key = "with space"

Commit c95311d added support for multiple config formats in addition to
pre-processing using Go's built-in templating system. The
`html/template` package is equivalent to `text/template`, except that
the former automatically escapes characters for inclusion in HTML.

Configurations aren't plain text, but they're also certainly no HTML.
The difference between the packages is noticeable when using `printf
"%q"` for quoting of strings. An example from the included unittest:

* `html/template`: `key = &fatedier#34;with space&fatedier#34;`
* `text/template`: `key = "with space"`

Signed-off-by: Michael Hanselmann <public@hansmi.ch>
@fatedier fatedier merged commit b8d3ace into fatedier:dev Feb 7, 2025
2 checks passed
github-actions bot added a commit to aiastia-dockerhub/frp that referenced this pull request Feb 7, 2025
* https://github.com/fatedier/frp:
  Use text/template instead of html/template for config pre-processing (fatedier#4656)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants