From 7f22f525fc7272ef1552548fd70cfab9470f043d Mon Sep 17 00:00:00 2001 From: Enrique Sanchez Cardoso Date: Mon, 19 Jan 2026 18:41:20 +0100 Subject: [PATCH] feat: strip newlines on og image rendering (#10914) Replace newlines from the repo description with spaces to match in-app rendering. Related issue: #10823 ## Checklist The [contributor guide](https://forgejo.org/docs/next/contributor/) contains information that will be helpful to first time contributors. There also are a few [conditions for merging Pull Requests in Forgejo repositories](https://codeberg.org/forgejo/governance/src/branch/main/PullRequestsAgreement.md). You are also welcome to join the [Forgejo development chatroom](https://matrix.to/#/#forgejo-development:matrix.org). ### Tests - I added test coverage for Go changes... - [ ] in their respective `*_test.go` for unit tests. - [ ] in the `tests/integration` directory if it involves interactions with a live Forgejo server. - I added test coverage for JavaScript changes... - [ ] in `web_src/js/*.test.js` if it can be unit tested. - [ ] in `tests/e2e/*.test.e2e.js` if it requires interactions with a live Forgejo server (see also the [developer guide for JavaScript testing](https://codeberg.org/forgejo/forgejo/src/branch/forgejo/tests/e2e/README.md#end-to-end-tests)). ### Documentation - [ ] I created a pull request [to the documentation](https://codeberg.org/forgejo/docs) to explain to Forgejo users how to use this change. - [x] I did not document these changes and I do not expect someone else to do it. ### Release notes - [x] This change will be noticed by a Forgejo user or admin (feature, bug fix, performance, etc.). I suggest to include a release note for this change. - [ ] This change is not visible to a Forgejo user or admin (refactor, dependency upgrade, etc.). I think there is no need to add a release note for this change. *The decision if the pull request will be shown in the release notes is up to the mergers / release team.* The content of the `release-notes/.md` file will serve as the basis for the release notes. If the file does not exist, the title of the pull request will be used instead. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/10914 Reviewed-by: Mathieu Fenniak Co-authored-by: Enrique Sanchez Cardoso Co-committed-by: Enrique Sanchez Cardoso --- routers/web/repo/card.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/routers/web/repo/card.go b/routers/web/repo/card.go index c8bab8cc49..dd0cedae2d 100644 --- a/routers/web/repo/card.go +++ b/routers/web/repo/card.go @@ -152,7 +152,13 @@ func drawRepoSummaryCard(ctx *context.Context, repo *repo_model.Repository) (*ca } issueDescription.SetMargin(10) - _, err = issueDescription.DrawText(repo.Description, color.Gray{128}, 36, card.Top, card.Left) + // Replace new lines with spaces to match repo description in-app rendering + issueDescriptionText := strings.NewReplacer( + "\r\n", " ", + "\r", " ", + "\n", " ", + ).Replace(repo.Description) + _, err = issueDescription.DrawText(issueDescriptionText, color.Gray{128}, 36, card.Top, card.Left) if err != nil { return nil, err }