Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support SVG avatars #8707

Open
strk opened this issue Oct 27, 2019 · 10 comments
Open

Support SVG avatars #8707

strk opened this issue Oct 27, 2019 · 10 comments
Labels
type/enhancement An improvement of existing functionality

Comments

@strk
Copy link
Member

strk commented Oct 27, 2019

SVG images are not supported as avatars (cannot be uploaded, reported to "not be an image").
I'm not sure this is a duplicate of #1095 so I'm filing it separately

@lunny
Copy link
Member

lunny commented Nov 2, 2019

I think it's the same. Since it cannot be rendered safely, we cannot allow it uploaded.

@stale
Copy link

stale bot commented Jan 1, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.

@stale stale bot added the issue/stale label Jan 1, 2020
@stale
Copy link

stale bot commented Jan 15, 2020

This issue has been automatically closed because of inactivity. You can re-open it if needed.

@stale stale bot closed this as completed Jan 15, 2020
@dmolineus
Copy link

The issue still occurs. Would be great if it get reopen.

@lunny lunny added the issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented label Jan 23, 2020
@lunny lunny reopened this Jan 23, 2020
@stale stale bot removed the issue/stale label Jan 23, 2020
@iFrozenPhoenix
Copy link

@lunny could this issue eventually being resolved by using the method implemented in this pull request #14101?

@lunny
Copy link
Member

lunny commented Nov 12, 2021

I don't know if there is a risk for that.

@wxiaoguang
Copy link
Contributor

wxiaoguang commented Nov 12, 2021

Some reference:

@wxiaoguang wxiaoguang changed the title SVG "is not an image" (uploading avatar) Use SVG as avatar for user/org/repo Nov 12, 2021
@wxiaoguang wxiaoguang added type/enhancement An improvement of existing functionality and removed issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented labels Nov 12, 2021
@iFrozenPhoenix
Copy link

iFrozenPhoenix commented Nov 12, 2021

Thanks for the references.
@wxiaoguang
I've looked at the code and found out that it is already implemented. But for an unknown reason it doesn't work. So I think this issue should be considered as a bug.

The error message "The uploaded file is not an image." is the locale value for the variable "uploaded_avatar_not_a_image" which is present in the 2 files "routers/web/repo/setting.go" and "routers/web/user/setting/profile.go".

For an uploaded image there is the following content type check.

st := typesniffer.DetectContentType(data)
if !(st.IsImage() && !st.IsSvgImage()) {
	return errors.New(ctx.Tr("settings.uploaded_avatar_not_a_image"))
}

EDIT: I've found the line where it is rejected. It's the second ! in the function above

@silverwind
Copy link
Member

If there is a battle-tested SVG sanitizer available in golang, we could reconsider.

@iFrozenPhoenix
Copy link

@silverwind I've done a quick search on gh and Google for one, but unfortunately I found just a few simple tag cleaners (removes script tags, so far away from battle tested).

As far as I have seen, the current method for providing security with svgs is by using an adequate content security policy (http header) or (better and) using img tags for displaying the svg image.

Additionally I would suggest that svg uploads must be enabled in the ini config.

I think the gitea admins should be able to decide on their own if they want to use this functionality and eventually have a rest risk of that it can be exploited. For a public instance it can make sense to forbid it, but for private instances the adminis should have the possibility to allow it.

@silverwind silverwind changed the title Use SVG as avatar for user/org/repo Support SVG avatars Apr 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement An improvement of existing functionality
Projects
None yet
Development

No branches or pull requests

6 participants