Skip to content

Content of text file with "LP" after 34 bytes not show in the repository view due to Golang's http.DetectContentType #36325

@mg-cloud

Description

@mg-cloud

Description

I have encounter an issue on the web interface with some basic text file not displayed in the repository content preview.
You have the message "[View Raw]" to download the file as for a binary instead of the content displayed.

After some test, I found that the following 2 lines pasted on demo.gitea.com reproduced the problem.

# syntax=docker/dockerfile:1
ARG ALP

I stored two text file on https://demo.gitea.com/mg-cloud/gitea-issue-raw with, one OK et one KO just by changing the last letter for P to E (adding a space, a new line seems to solve the issue as well).
Test KO
Test OK

See screenshot below.

Gitea Version

1.26.0+dev-209-g26602fd207 on demo.gitea.com

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

Screenshoot with the file not displayed

Image

Screenshoot of a correct display with a character changed

Image

Git Version

No response

Operating System

No response

How are you running Gitea?

Problem reproduced on demo.gitea.com

Database

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue/confirmedIssue has been reviewed and confirmed to be present or accepted to be implementedtype/bugtype/upstreamThis is an issue in one of Gitea's dependencies and should be reported there

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions