[PR #1404] [MERGED] allow newlines in in-line go templates #1595

Closed
opened 2026-05-07 01:02:49 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/binwiederhier/ntfy/pull/1404
Author: @wunter8
Created: 7/27/2025
Status: Merged
Merged: 7/27/2025
Merged by: @binwiederhier

Base: mainHead: inline-template-newlines


📝 Commits (1)

  • 0d36ab8 allow newlines in in-line go templates

📊 Changes

2 files changed (+64 additions, -3 deletions)

View changed files

📝 server/server.go (+9 -3)
📝 server/server_test.go (+55 -0)

📄 Description

Before the changes in this PR, there was a difference between

message: {{.foo}}{{"\n"}}{{.bar}}

in a template YAML file and

m={{.foo}}{{"\n"}}{{.bar}}

in an inline template (in a URL/header param).

The inline template version would break (be considered an invalid template), because we were replacing all "\n" in the message field with literal newlines, making the template look like this:

{{.foo}}{{"
"}}{{.bar}}

Doing that before we rendered the template caused problems. This changes the code so that when an inline template is being used, we don't replace "\n" with literal newlines until after the template is rendered.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/binwiederhier/ntfy/pull/1404 **Author:** [@wunter8](https://github.com/wunter8) **Created:** 7/27/2025 **Status:** ✅ Merged **Merged:** 7/27/2025 **Merged by:** [@binwiederhier](https://github.com/binwiederhier) **Base:** `main` ← **Head:** `inline-template-newlines` --- ### 📝 Commits (1) - [`0d36ab8`](https://github.com/binwiederhier/ntfy/commit/0d36ab8af37760670358127d89e27c6ee102e154) allow newlines in in-line go templates ### 📊 Changes **2 files changed** (+64 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `server/server.go` (+9 -3) 📝 `server/server_test.go` (+55 -0) </details> ### 📄 Description Before the changes in this PR, there was a difference between ``` message: {{.foo}}{{"\n"}}{{.bar}} ``` in a template YAML file and ``` m={{.foo}}{{"\n"}}{{.bar}} ``` in an inline template (in a URL/header param). The inline template version would break (be considered an invalid template), because we were replacing all "\n" in the message field with literal newlines, making the template look like this: ``` {{.foo}}{{" "}}{{.bar}} ``` Doing that before we rendered the template caused problems. This changes the code so that when an inline template is being used, we don't replace "\n" with literal newlines until after the template is rendered. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-07 01:02:49 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ntfy#1595
No description provided.