1212from django .conf import settings
1313from django .contrib .staticfiles .storage import staticfiles_storage
1414from django .utils .html import format_html
15- from django .utils .safestring import mark_safe
1615from django .utils .translation import gettext_lazy
1716
1817from weblate .accounts .utils import get_key_name
5958 "recovery" : gettext_lazy ("Use recovery codes" ),
6059}
6160
62- IMAGE_SOCIAL_TEMPLATE = """
63- <img class="auth-image" src="{image}" />
64- """
61+ IMAGE_SOCIAL_TEMPLATE = (
62+ """ <img class="auth-image" src="{image}" alt="" aria-hidden="true" />"""
63+ )
6564
66- SOCIAL_TEMPLATE = """
67- {icon}
68- {separator}
69- {name}
70- """
65+ SOCIAL_TEMPLATE = """{icon}<span class="auth-name">{name}</span>"""
7166
7267
7368def get_auth_params (auth : str ) -> dict [str , StrOrPromise ]:
@@ -92,22 +87,19 @@ def get_auth_params(auth: str) -> dict[str, StrOrPromise]:
9287 return params
9388
9489
95- auth_name_default_separator = mark_safe ("<br />" )
96-
97-
9890@register .simple_tag
99- def auth_name (auth : str , separator : str = auth_name_default_separator , only : str = "" ):
91+ def auth_name (auth : str , only : str = "" ):
10092 """Create HTML markup for social authentication method."""
10193 params = get_auth_params (auth )
10294
10395 if not params ["image" ].startswith (("http" , "data:" )):
10496 params ["image" ] = staticfiles_storage .url (f"auth/{ params ['image' ]} " )
105- params ["icon" ] = format_html (IMAGE_SOCIAL_TEMPLATE , separator = separator , ** params )
97+ params ["icon" ] = format_html (IMAGE_SOCIAL_TEMPLATE , ** params )
10698
10799 if only :
108100 return params [only ]
109101
110- return format_html (SOCIAL_TEMPLATE , separator = separator , ** params )
102+ return format_html (SOCIAL_TEMPLATE , ** params )
111103
112104
113105def get_auth_name (auth : str ):
@@ -117,7 +109,7 @@ def get_auth_name(auth: str):
117109
118110@register .simple_tag
119111def key_name (device : Device ) -> str :
120- return format_html ('<span class="auth -name">{}</span>' , get_key_name (device ))
112+ return format_html ('<span class="key -name">{}</span>' , get_key_name (device ))
121113
122114
123115@register .simple_tag
0 commit comments