avatar_default.png broken on some pages #12391

Closed
opened 2025-11-02 10:08:19 -06:00 by GiteaMirror · 8 comments
Owner

Originally created by @JanRomero on GitHub (Jan 26, 2024).

Description

New users who have not uploaded a custom avatar are shown with a broken image in our installation. The HTML generated for the big image on the user profile looks like this, which is clearly wrong:

/avatars/%2Fassets%2Fimg%2Favatar_default.png?size=512
As you can see, the path contains escaped forward slashes and is wrongly prefixed with “/avatars”.

In the install directory the image is set up under /custom/public/assets/img/avatar_default.png. I’m pretty sure that’s correct, because it is shown nicely on anonymous commits, where the generated HTML looks as expected.

Our config in app.ini looks like this. This is the entire section and it’s reflected in the admin panel. We don’t have any other avatar settings in the UI or in app.ini that I’m aware of.

[picture]
DISABLE_GRAVATAR = true
ENABLE_FEDERATED_AVATAR = false

If this is indeed a bug, I imagine it lives here, but I’m only browsing the source on github and don’t know what I’m doing: 534917d576/models/avatars/avatar.go (L60)

Thank you very much! Sorry if this is a misconfiguration on my end.

Screenshots

Gitea Version

1.21.4

Can you reproduce the bug on the Gitea demo site?

No

Operating System

Windows

Browser Version

Any

Originally created by @JanRomero on GitHub (Jan 26, 2024). ### Description New users who have not uploaded a custom avatar are shown with a broken image in our installation. The HTML generated for the big image on the user profile looks like this, which is clearly wrong: ![/avatars/%2Fassets%2Fimg%2Favatar_default.png?size=512](https://github.com/go-gitea/gitea/assets/7873027/8bb3e267-5ed1-4697-b151-00d13461862c) As you can see, the path contains escaped forward slashes and is wrongly prefixed with “/avatars”. In the install directory the image is set up under `/custom/public/assets/img/avatar_default.png`. I’m pretty sure that’s correct, because it is shown nicely on anonymous commits, where [the generated HTML](https://github.com/go-gitea/gitea/assets/7873027/e56cb83d-8333-4900-942a-1f2548101f53) looks as expected. Our config in app.ini looks like this. This is the entire section and it’s reflected in the admin panel. We don’t have any other avatar settings in the UI or in app.ini that I’m aware of. ``` [picture] DISABLE_GRAVATAR = true ENABLE_FEDERATED_AVATAR = false ``` If this is indeed a bug, I imagine it lives here, but I’m only browsing the source on github and don’t know what I’m doing: https://github.com/go-gitea/gitea/blob/534917d57670d82703567131e2b33fd945e6f8cb/models/avatars/avatar.go#L60 Thank you very much! Sorry if this is a misconfiguration on my end. ### Screenshots ![](https://github.com/go-gitea/gitea/assets/7873027/a37f534f-65f8-4852-846a-1290288bdda9) ### Gitea Version 1.21.4 ### Can you reproduce the bug on the Gitea demo site? No ### Operating System Windows ### Browser Version Any
GiteaMirror added the type/bug label 2025-11-02 10:08:19 -06:00
Author
Owner

@wxiaoguang commented on GitHub (Jan 26, 2024):

It seems that you manually filled incorrect value to user's Avatar database column.

You should keep the user's Avatar database column empty if they doesn't have an avatar.

If you filled anything into user's Avatar database column , that value will be used as an existing avatar: "/avatars/" + escape(user.Avatar), then that's what you saw.

@wxiaoguang commented on GitHub (Jan 26, 2024): It seems that you manually filled incorrect value to user's Avatar database column. You should keep the user's Avatar database column empty if they doesn't have an avatar. If you filled anything into user's Avatar database column , that value will be used as an existing avatar: `"/avatars/" + escape(user.Avatar)`, then that's what you saw.
Author
Owner

@KN4CK3R commented on GitHub (Jan 26, 2024):

Looked at this too and there must be something invalid in the database. The field should just contain a hash and not some path.

@KN4CK3R commented on GitHub (Jan 26, 2024): Looked at this too and there must be something invalid in the database. The field should just contain a hash and not some path.
Author
Owner

@JanRomero commented on GitHub (Jan 26, 2024):

Hi, thanks for the quick replies. You’re right, the database column contains “/assets/img/avatar_default.png” for new users. They are created automatically on their first visit by the SPNEGO auth source, so I guess the problem lies there?

If I remove my avatar as an existing user, I get a hash in the database showing as some auto-generated geometry in the frontend (I feel like I should get avatar_default.png, but as long as it’s not a broken image I don’t mind).

@JanRomero commented on GitHub (Jan 26, 2024): Hi, thanks for the quick replies. You’re right, the database column contains “/assets/img/avatar_default.png” for new users. They are created automatically on their first visit by the SPNEGO auth source, so I guess the problem lies there? If I remove my avatar as an existing user, I get a hash in the database showing as some auto-generated geometry in the frontend (I feel like I should get avatar_default.png, but as long as it’s not a broken image I don’t mind).
Author
Owner

@wxiaoguang commented on GitHub (Jan 26, 2024):

the database column contains “/assets/img/avatar_default.png” for new users. They are created automatically on their first visit by the SPNEGO auth source, so I guess the problem lies there?

It looks like a bug ...... as old as #8463

@wxiaoguang commented on GitHub (Jan 26, 2024): > the database column contains “/assets/img/avatar_default.png” for new users. They are created automatically on their first visit by the SPNEGO auth source, so I guess the problem lies there? It looks like a bug ...... as old as #8463
Author
Owner

@KN4CK3R commented on GitHub (Jan 26, 2024):

Yep, that's wrong:
Avatar: avatars.DefaultAvatarLink(),

@wxiaoguang You or me?

@KN4CK3R commented on GitHub (Jan 26, 2024): Yep, that's wrong: `Avatar: avatars.DefaultAvatarLink(),` @wxiaoguang You or me?
Author
Owner

@wxiaoguang commented on GitHub (Jan 26, 2024):

Too late in my timezone, will go to bed 🤣 feel free to propose a fix 🙏

@wxiaoguang commented on GitHub (Jan 26, 2024): Too late in my timezone, will go to bed 🤣 feel free to propose a fix 🙏
Author
Owner

@JanRomero commented on GitHub (Jan 26, 2024):

Awesome, you guys are really fast! Appreciate it! Sorry I didn’t post the relevant details immediately.

@JanRomero commented on GitHub (Jan 26, 2024): Awesome, you guys are really fast! Appreciate it! Sorry I didn’t post the relevant details immediately.
Author
Owner

@wxiaoguang commented on GitHub (Feb 21, 2024):

wait for backport

@wxiaoguang commented on GitHub (Feb 21, 2024): wait for backport
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#12391