Images and other binary files not shown in diff #6107

Closed
opened 2025-11-02 06:45:18 -06:00 by GiteaMirror · 7 comments
Owner

Originally created by @mleyen on GitHub (Oct 7, 2020).

  • Gitea version (or commit ref): 1.12.5
  • Git version: 2.25.1
  • Operating system: Ubuntu 20.04.1 LTS
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
  • Log gist:

Description

Images no longer display in the Web interface when viewing a commit's diff. Instead, they only display an empty line with the "BIN" label, and no filename. This is true for any binary file, as well as empty files.

Screenshots

test

Originally created by @mleyen on GitHub (Oct 7, 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.12.5 - Git version: 2.25.1 - Operating system: Ubuntu 20.04.1 LTS - Database (use `[x]`): - [ ] PostgreSQL - [ ] MySQL - [ ] MSSQL - [x] SQLite - Can you reproduce the bug at https://try.gitea.io: - [x] Yes (provide [example URL](https://try.gitea.io/mleyen/diff-test/commit/fcf20472ea413ab6752516827a597274dab58513)) - [ ] No - [ ] Not relevant - Log gist: ## Description Images no longer display in the Web interface when viewing a commit's diff. Instead, they only display an empty line with the "BIN" label, and no filename. This is true for any binary file, as well as [empty files](https://try.gitea.io/mleyen/diff-test/commit/9f09e9cfb54a655c102157a828066713dcd483e9). ## Screenshots <!-- **If this issue involves the Web Interface, please include a screenshot** --> ![test](https://user-images.githubusercontent.com/6747270/95330728-44b2dd00-08a9-11eb-86cb-c183f8e6b0c1.png)
GiteaMirror added the issue/regressiontype/bug labels 2025-11-02 06:45:18 -06:00
Author
Owner

@zeripath commented on GitHub (Oct 7, 2020):

Damn this one is gonna be something to do with the new diff header reading code.

@zeripath commented on GitHub (Oct 7, 2020): Damn this one is gonna be something to do with the new diff header reading code.
Author
Owner

@zeripath commented on GitHub (Oct 7, 2020):

The problem will be in here

144fa5a537/services/gitdiff/gitdiff.go (L446)

And the issue will be that the bin diff isn't matched properly.

This is really a lot of fun because it appears that the diff is:

diff --git a/gitea-sm.png b/gitea-sm.png
new file mode 100644
index 0000000..0ae375c
Binary files /dev/null and b/gitea-sm.png differ

Similarly for the empty file problem:

diff --git a/.gitkeep b/.gitkeep
new file mode 100644
index 0000000..e69de29

We can't easily determine the file name from the diff line:

Consider f4c9cf62d8 its diff is:

diff --git a/b b/b b/b b/b b/b b/b
similarity index 100%
rename from b b/b
rename to b b/b b/b b/b
diff --git a/b b/b b/b b/b b/b b/b
similarity index 100%
rename from b
rename to b b/b b/b b/b b/b

I just don't know how we're supposed to be able to parse these diffs in a non-breaking way...

@zeripath commented on GitHub (Oct 7, 2020): The problem will be in here https://github.com/go-gitea/gitea/blob/144fa5a53746387b1c124c10cd7d70cb5cebc26f/services/gitdiff/gitdiff.go#L446 And the issue will be that the bin diff isn't matched properly. This is really a lot of fun because it appears that the diff is: ```diff diff --git a/gitea-sm.png b/gitea-sm.png new file mode 100644 index 0000000..0ae375c Binary files /dev/null and b/gitea-sm.png differ ``` Similarly for the empty file problem: ```diff diff --git a/.gitkeep b/.gitkeep new file mode 100644 index 0000000..e69de29 ``` We can't easily determine the file name from the diff line: Consider https://try.gitea.io/arandomer/pathological/commit/f4c9cf62d8e5c8720e2e11d608306065da05343d its diff is: ```diff diff --git a/b b/b b/b b/b b/b b/b similarity index 100% rename from b b/b rename to b b/b b/b b/b diff --git a/b b/b b/b b/b b/b b/b similarity index 100% rename from b rename to b b/b b/b b/b b/b ``` I just don't know how we're supposed to be able to parse these diffs in a non-breaking way...
Author
Owner

@zeripath commented on GitHub (Oct 7, 2020):

Ah --src-prefix and --dst-prefix can be used to force the damned paths to be escaped.

Now just need to check if we can use those in early gits.

@zeripath commented on GitHub (Oct 7, 2020): Ah --src-prefix and --dst-prefix can be used to force the damned paths to be escaped. Now just need to check if we can use those in early gits.
Author
Owner

@ratuka commented on GitHub (Oct 13, 2020):

Any news about this?

@ratuka commented on GitHub (Oct 13, 2020): Any news about this?
Author
Owner

@Vangelis66 commented on GitHub (Oct 26, 2020):

@wolfbeast:

This bug is still present in the newly migrated (GitHub -> Gitea 1.12.5) MoonchildProductions repositories, e.g.

https://repo.palemoon.org/MoonchildProductions/Pale-Moon/commit/85f7050

GiteaBug

Just thought you should know... 😄
Best regards.

@Vangelis66 commented on GitHub (Oct 26, 2020): @wolfbeast: This bug is **still** present in the newly migrated (GitHub -> **Gitea 1.12.5**) `MoonchildProductions` repositories, e.g. https://repo.palemoon.org/MoonchildProductions/Pale-Moon/commit/85f7050 ![GiteaBug](https://user-images.githubusercontent.com/9669492/97125327-451df580-173c-11eb-92d9-81834be20dbe.jpg) Just thought you should know... 😄 Best regards.
Author
Owner

@wolfbeast commented on GitHub (Oct 26, 2020):

Please don't @ mention me unless you explicitly need my input.

@wolfbeast commented on GitHub (Oct 26, 2020): Please don't @ mention me unless you explicitly need my input.
Author
Owner

@techknowlogick commented on GitHub (Oct 26, 2020):

Locking this as the issue is closed, and will be included in the next release.

@techknowlogick commented on GitHub (Oct 26, 2020): Locking this as the issue is closed, and will be included in the next release.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#6107