From 348273963796db4b71d43ca39b983146463812a7 Mon Sep 17 00:00:00 2001 From: Gusted Date: Fri, 11 Aug 2023 12:35:30 +0200 Subject: [PATCH] [GITEA] Maintain aspect ratio for auth icons - When specifying an icon URL for a authentication source, it's forced to be an width and height of 20px. However this didn't take into account that icons could have an different aspect ratio of 1:1. - This patch fixes that by instead using `max-width` and `max-height` which will respect other aspect ratios. - Resolves https://codeberg.org/forgejo/forgejo/issues/1234 --- services/auth/source/oauth2/providers.go | 2 +- web_src/css/base.css | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/services/auth/source/oauth2/providers.go b/services/auth/source/oauth2/providers.go index 16620fad6d..67367aacd0 100644 --- a/services/auth/source/oauth2/providers.go +++ b/services/auth/source/oauth2/providers.go @@ -56,7 +56,7 @@ func (p *AuthSourceProvider) DisplayName() string { func (p *AuthSourceProvider) IconHTML() template.HTML { if p.iconURL != "" { - img := fmt.Sprintf(`%s`, + img := fmt.Sprintf(`%s`, html.EscapeString(p.iconURL), html.EscapeString(p.DisplayName()), ) return template.HTML(img) diff --git a/web_src/css/base.css b/web_src/css/base.css index 213f3f88f2..3458f760d3 100644 --- a/web_src/css/base.css +++ b/web_src/css/base.css @@ -2289,3 +2289,8 @@ table th[data-sortt-desc] .svg { flex-wrap: wrap; gap: .25rem; } + +.oauth-provider-icon { + max-height: 20px; + max-width: 20px; +}