Gitea doesn't handle newline ('\n') in file specified by INTERNAL_TOKEN_URI #5423

Closed
opened 2025-11-02 06:24:33 -06:00 by GiteaMirror · 1 comment
Owner

Originally created by @paradon on GitHub (May 18, 2020).

Description

If the content in the file referenced by INTERNAL_TOKEN_URI ends with a newline, all commits fail with an internal server error.

As gitea generate secret appends a newline to its output, this means that, (where app.ini contains INTERNAL_TOKEN_URI = file:/data/gitea/conf/internal-token), generating this file as below will cause this error:

gitea generate secret INTERNAL_TOKEN >/data/gitea/conf/internal-token

Screenshots

image

Originally created by @paradon on GitHub (May 18, 2020). <!-- NOTE: If your issue is a security concern, please send an email to security@gitea.io instead of opening a public issue --> <!-- 1. Please speak English, this is the language all maintainers can speak and write. 2. Please ask questions or configuration/deploy problems on our Discord server (https://discord.gg/gitea) or forum (https://discourse.gitea.io). 3. Please take a moment to check that your issue doesn't already exist. 4. Please give all relevant information below for bug reports, because incomplete details will be handled as an invalid report. --> - Gitea version (or commit ref): 1.11.5 - Git version: 2.24.1 - Operating system: Docker - Database (use `[x]`): - [ ] PostgreSQL - [x] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - [x] Not relevant - Log gist: https://gist.github.com/paradon/c48ab42740c8731b625313cf9d66e41c ## Description If the content in the file referenced by INTERNAL_TOKEN_URI ends with a newline, all commits fail with an internal server error. As `gitea generate secret` appends a newline to its output, this means that, (where app.ini contains `INTERNAL_TOKEN_URI = file:/data/gitea/conf/internal-token`), generating this file as below will cause this error: ``` gitea generate secret INTERNAL_TOKEN >/data/gitea/conf/internal-token ``` ## Screenshots ![image](https://user-images.githubusercontent.com/31676142/82269096-b0f97680-99c4-11ea-8b1e-311ed45f2118.png) <!-- **If this issue involves the Web Interface, please include a screenshot** -->
GiteaMirror added the type/bug label 2025-11-02 06:24:33 -06:00
Author
Owner

@zeripath commented on GitHub (May 19, 2020):

I also note that this uses ioutil.ReadAll which will not work on Symlinks...

@zeripath commented on GitHub (May 19, 2020): I also note that this uses ioutil.ReadAll which will not work on Symlinks...
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#5423