[PR #4863] [MERGED] Fix trimming of markup section names #17525

Closed
opened 2025-11-02 13:52:51 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/go-gitea/gitea/pull/4863
Author: @Eisfunke
Created: 9/3/2018
Status: Merged
Merged: 9/4/2018
Merged by: @techknowlogick

Base: masterHead: markup-trim-fix


📝 Commits (1)

  • d6edaf0 Fix trimming of markup section names

📊 Changes

1 file changed (+1 additions, -1 deletions)

View changed files

📝 modules/setting/setting.go (+1 -1)

📄 Description

This small fix corrects the trimming of markup section names in the settings parser.

Previously, TrimLeft(sec.Name(), "markup.") was used, which trims all characters contained in the second string.

So, for example, the section name markup.moo was incorrectly trimmed to oo.

The correct function for this is TrimPrefix which uses the second string as, well, a prefix. Now, for example, markup.moo gets correctly trimmed to moo.

(I noticed this when trying to overwrite markdown parsing with a app.ini section markup.markdown.
Wiki pages are currently hardcoded to use markdown markup type. The function Wiki in routers/repo/wiki.go complains as wiki pages are .md files which returned down as markup type instead of the expected markdown.)

Signed-off-by: Nicolas Lenz nicolas@eisfunke.com


🔄 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/go-gitea/gitea/pull/4863 **Author:** [@Eisfunke](https://github.com/Eisfunke) **Created:** 9/3/2018 **Status:** ✅ Merged **Merged:** 9/4/2018 **Merged by:** [@techknowlogick](https://github.com/techknowlogick) **Base:** `master` ← **Head:** `markup-trim-fix` --- ### 📝 Commits (1) - [`d6edaf0`](https://github.com/go-gitea/gitea/commit/d6edaf0aca3a50921e7d34f1e26be4e2a9babb09) Fix trimming of markup section names ### 📊 Changes **1 file changed** (+1 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `modules/setting/setting.go` (+1 -1) </details> ### 📄 Description This small fix corrects the trimming of markup section names in the settings parser. Previously, `TrimLeft(sec.Name(), "markup.")` was used, which [trims all characters contained in the second string](https://godoc.org/strings#TrimLeft). So, for example, the section name `markup.moo` was incorrectly trimmed to `oo`. The correct function for this is [`TrimPrefix`](https://godoc.org/strings#TrimPrefix) which uses the second string as, well, a prefix. Now, for example, `markup.moo` gets correctly trimmed to `moo`. (I noticed this when trying to overwrite markdown parsing with a app.ini section `markup.markdown`. Wiki pages are currently hardcoded to use `markdown` markup type. The function `Wiki` in routers/repo/wiki.go complains as wiki pages are `.md` files which returned `down` as markup type instead of the expected `markdown`.) Signed-off-by: Nicolas Lenz <nicolas@eisfunke.com> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-02 13:52:51 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#17525