prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Auth provider title and image override do not work for auth providers with '-' in it
  **Describe the issue**
  
  The new feature to override the name and image for an auth provider (introduced in 159ae591e91e7c2065ede9c39f14d743f5ab07e5) does not work for auth providers with '-' in them. 
  
  <!--
  A clear and concise description of the problem you are facing.
  -->
  
  **I already tried**
  
  Describe the steps you tried to solve the problem yourself.
  
  - [x] I've read and searched [the docs](https://docs.weblate.org/) and did not find the answer there.
        If you didn’t try already, try to search there what you wrote above.
  
  **To Reproduce the issue**
  
  Steps to reproduce the behavior:
  
  1. Add an auth to your settings - e.g. `SOCIAL_AUTH_AZUREAD_TENANT_OAUTH2_KEY`
  2. Set the title and image override (`SOCIAL_AUTH_AZUREAD_TENANT_OAUTH2_TITLE` and `SOCIAL_AUTH_AZUREAD_TENANT_OAUTH2_IMAGE`)
  3. Go to the login page
  4. The title and image are not overriden
  
  **Expected behavior**
  
  The title and image should be overridden. 
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `weblate/accounts/templatetags/authnames.py`
  Content:
  ```
  1 #
  2 # Copyright © 2012 - 2021 Michal Čihař <michal@cihar.com>
  3 #
  4 # This file is part of Weblate <https://weblate.org/>
  5 #
  6 # This program is free software: you can redistribute it and/or modify
  7 # it under the terms of the GNU General Public License as published by
  8 # the Free Software Foundation, either version 3 of the License, or
  9 # (at your option) any later version.
  10 #
  11 # This program is distributed in the hope that it will be useful,
  12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14 # GNU General Public License for more details.
  15 #
  16 # You should have received a copy of the GNU General Public License
  17 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
  18 #
  19 """Provide user friendly names for social authentication methods."""
  20 
  21 from django import template
  22 from django.conf import settings
  23 from django.contrib.staticfiles.storage import staticfiles_storage
  24 from django.utils.safestring import mark_safe
  25 from django.utils.translation import gettext_lazy
  26 
  27 register = template.Library()
  28 
  29 SOCIALS = {
  30     "auth0": {"name": "Auth0", "image": "auth0.svg"},
  31     "saml": {"name": "SAML", "image": "saml.svg"},
  32     "google": {"name": "Google", "image": "google.svg"},
  33     "google-oauth2": {"name": "Google", "image": "google.svg"},
  34     "google-plus": {"name": "Google+", "image": "google.svg"},
  35     "password": {"name": gettext_lazy("Password"), "image": "password.svg"},
  36     "email": {"name": gettext_lazy("E-mail"), "image": "email.svg"},
  37     "ubuntu": {"name": "Ubuntu", "image": "ubuntu.svg"},
  38     "opensuse": {"name": "openSUSE", "image": "opensuse.svg"},
  39     "fedora": {"name": "Fedora", "image": "fedora.svg"},
  40     "facebook": {"name": "Facebook", "image": "facebook.svg"},
  41     "github": {"name": "GitHub", "image": "github.svg"},
  42     "github-enterprise": {"name": "GitHub Enterprise", "image": "github.svg"},
  43     "bitbucket": {"name": "Bitbucket", "image": "bitbucket.svg"},
  44     "bitbucket-oauth2": {"name": "Bitbucket", "image": "bitbucket.svg"},
  45     "azuread-oauth2": {"name": "Azure", "image": "azure.svg"},
  46     "azuread-tenant-oauth2": {"name": "Azure", "image": "azure.svg"},
  47     "gitlab": {"name": "GitLab", "image": "gitlab.svg"},
  48     "amazon": {"name": "Amazon", "image": "amazon.svg"},
  49     "twitter": {"name": "Twitter", "image": "twitter.svg"},
  50     "stackoverflow": {"name": "Stack Overflow", "image": "stackoverflow.svg"},
  51 }
  52 
  53 IMAGE_SOCIAL_TEMPLATE = """
  54 <img class="auth-image" src="{image}" />
  55 """
  56 
  57 SOCIAL_TEMPLATE = """
  58 {icon}
  59 {separator}
  60 {name}
  61 """
  62 
  63 
  64 def get_auth_params(auth: str):
  65     """Returns authentication parameters."""
  66     # Fallback values
  67     params = {"name": auth, "image": "password.svg"}
  68 
  69     # Hardcoded names
  70     if auth in SOCIALS:
  71         params.update(SOCIALS[auth])
  72 
  73     # Settings override
  74     settings_params = {
  75         "name": f"SOCIAL_AUTH_{auth.upper()}_TITLE",
  76         "image": f"SOCIAL_AUTH_{auth.upper()}_IMAGE",
  77     }
  78     for target, source in settings_params.items():
  79         value = getattr(settings, source, None)
  80         if value:
  81             params[target] = value
  82 
  83     return params
  84 
  85 
  86 @register.simple_tag
  87 def auth_name(auth: str, separator: str = "<br />"):
  88     """Create HTML markup for social authentication method."""
  89     params = get_auth_params(auth)
  90 
  91     if not params["image"].startswith("http"):
  92         params["image"] = staticfiles_storage.url("auth/" + params["image"])
  93     params["icon"] = IMAGE_SOCIAL_TEMPLATE.format(separator=separator, **params)
  94 
  95     return mark_safe(SOCIAL_TEMPLATE.format(separator=separator, **params))
  96 
  97 
  98 def get_auth_name(auth: str):
  99     """Get nice name for authentication backend."""
  100     return get_auth_params(auth)["name"]
  101
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/weblate/accounts/templatetags/authnames.py b/weblate/accounts/templatetags/authnames.py
  --- a/weblate/accounts/templatetags/authnames.py
  +++ b/weblate/accounts/templatetags/authnames.py
  @@ -72,8 +72,8 @@
   
       # Settings override
       settings_params = {
  -        "name": f"SOCIAL_AUTH_{auth.upper()}_TITLE",
  -        "image": f"SOCIAL_AUTH_{auth.upper()}_IMAGE",
  +        "name": f"SOCIAL_AUTH_{auth.upper().replace('-','_')}_TITLE",
  +        "image": f"SOCIAL_AUTH_{auth.upper().replace('-','_')}_IMAGE",
       }
       for target, source in settings_params.items():
           value = getattr(settings, source, None)
  
verification_info: {"golden_diff": "diff --git a/weblate/accounts/templatetags/authnames.py b/weblate/accounts/templatetags/authnames.py\n--- a/weblate/accounts/templatetags/authnames.py\n+++ b/weblate/accounts/templatetags/authnames.py\n@@ -72,8 +72,8 @@\n \n     # Settings override\n     settings_params = {\n-        \"name\": f\"SOCIAL_AUTH_{auth.upper()}_TITLE\",\n-        \"image\": f\"SOCIAL_AUTH_{auth.upper()}_IMAGE\",\n+        \"name\": f\"SOCIAL_AUTH_{auth.upper().replace('-','_')}_TITLE\",\n+        \"image\": f\"SOCIAL_AUTH_{auth.upper().replace('-','_')}_IMAGE\",\n     }\n     for target, source in settings_params.items():\n         value = getattr(settings, source, None)\n", "issue": "Auth provider title and image override do not work for auth providers with '-' in it\n**Describe the issue**\r\n\r\nThe new feature to override the name and image for an auth provider (introduced in 159ae591e91e7c2065ede9c39f14d743f5ab07e5) does not work for auth providers with '-' in them. \r\n\r\n<!--\r\nA clear and concise description of the problem you are facing.\r\n-->\r\n\r\n**I already tried**\r\n\r\nDescribe the steps you tried to solve the problem yourself.\r\n\r\n- [x] I've read and searched [the docs](https://docs.weblate.org/) and did not find the answer there.\r\n      If you didn\u2019t try already, try to search there what you wrote above.\r\n\r\n**To Reproduce the issue**\r\n\r\nSteps to reproduce the behavior:\r\n\r\n1. Add an auth to your settings - e.g. `SOCIAL_AUTH_AZUREAD_TENANT_OAUTH2_KEY`\r\n2. Set the title and image override (`SOCIAL_AUTH_AZUREAD_TENANT_OAUTH2_TITLE` and `SOCIAL_AUTH_AZUREAD_TENANT_OAUTH2_IMAGE`)\r\n3. Go to the login page\r\n4. The title and image are not overriden\r\n\r\n**Expected behavior**\r\n\r\nThe title and image should be overridden. \r\n\n", "before_files": [{"content": "#\n# Copyright \u00a9 2012 - 2021 Michal \u010ciha\u0159 <michal@cihar.com>\n#\n# This file is part of Weblate <https://weblate.org/>\n#\n# This program is free software: you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation, either version 3 of the License, or\n# (at your option) any later version.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program.  If not, see <https://www.gnu.org/licenses/>.\n#\n\"\"\"Provide user friendly names for social authentication methods.\"\"\"\n\nfrom django import template\nfrom django.conf import settings\nfrom django.contrib.staticfiles.storage import staticfiles_storage\nfrom django.utils.safestring import mark_safe\nfrom django.utils.translation import gettext_lazy\n\nregister = template.Library()\n\nSOCIALS = {\n    \"auth0\": {\"name\": \"Auth0\", \"image\": \"auth0.svg\"},\n    \"saml\": {\"name\": \"SAML\", \"image\": \"saml.svg\"},\n    \"google\": {\"name\": \"Google\", \"image\": \"google.svg\"},\n    \"google-oauth2\": {\"name\": \"Google\", \"image\": \"google.svg\"},\n    \"google-plus\": {\"name\": \"Google+\", \"image\": \"google.svg\"},\n    \"password\": {\"name\": gettext_lazy(\"Password\"), \"image\": \"password.svg\"},\n    \"email\": {\"name\": gettext_lazy(\"E-mail\"), \"image\": \"email.svg\"},\n    \"ubuntu\": {\"name\": \"Ubuntu\", \"image\": \"ubuntu.svg\"},\n    \"opensuse\": {\"name\": \"openSUSE\", \"image\": \"opensuse.svg\"},\n    \"fedora\": {\"name\": \"Fedora\", \"image\": \"fedora.svg\"},\n    \"facebook\": {\"name\": \"Facebook\", \"image\": \"facebook.svg\"},\n    \"github\": {\"name\": \"GitHub\", \"image\": \"github.svg\"},\n    \"github-enterprise\": {\"name\": \"GitHub Enterprise\", \"image\": \"github.svg\"},\n    \"bitbucket\": {\"name\": \"Bitbucket\", \"image\": \"bitbucket.svg\"},\n    \"bitbucket-oauth2\": {\"name\": \"Bitbucket\", \"image\": \"bitbucket.svg\"},\n    \"azuread-oauth2\": {\"name\": \"Azure\", \"image\": \"azure.svg\"},\n    \"azuread-tenant-oauth2\": {\"name\": \"Azure\", \"image\": \"azure.svg\"},\n    \"gitlab\": {\"name\": \"GitLab\", \"image\": \"gitlab.svg\"},\n    \"amazon\": {\"name\": \"Amazon\", \"image\": \"amazon.svg\"},\n    \"twitter\": {\"name\": \"Twitter\", \"image\": \"twitter.svg\"},\n    \"stackoverflow\": {\"name\": \"Stack Overflow\", \"image\": \"stackoverflow.svg\"},\n}\n\nIMAGE_SOCIAL_TEMPLATE = \"\"\"\n<img class=\"auth-image\" src=\"{image}\" />\n\"\"\"\n\nSOCIAL_TEMPLATE = \"\"\"\n{icon}\n{separator}\n{name}\n\"\"\"\n\n\ndef get_auth_params(auth: str):\n    \"\"\"Returns authentication parameters.\"\"\"\n    # Fallback values\n    params = {\"name\": auth, \"image\": \"password.svg\"}\n\n    # Hardcoded names\n    if auth in SOCIALS:\n        params.update(SOCIALS[auth])\n\n    # Settings override\n    settings_params = {\n        \"name\": f\"SOCIAL_AUTH_{auth.upper()}_TITLE\",\n        \"image\": f\"SOCIAL_AUTH_{auth.upper()}_IMAGE\",\n    }\n    for target, source in settings_params.items():\n        value = getattr(settings, source, None)\n        if value:\n            params[target] = value\n\n    return params\n\n\n@register.simple_tag\ndef auth_name(auth: str, separator: str = \"<br />\"):\n    \"\"\"Create HTML markup for social authentication method.\"\"\"\n    params = get_auth_params(auth)\n\n    if not params[\"image\"].startswith(\"http\"):\n        params[\"image\"] = staticfiles_storage.url(\"auth/\" + params[\"image\"])\n    params[\"icon\"] = IMAGE_SOCIAL_TEMPLATE.format(separator=separator, **params)\n\n    return mark_safe(SOCIAL_TEMPLATE.format(separator=separator, **params))\n\n\ndef get_auth_name(auth: str):\n    \"\"\"Get nice name for authentication backend.\"\"\"\n    return get_auth_params(auth)[\"name\"]\n", "path": "weblate/accounts/templatetags/authnames.py"}], "after_files": [{"content": "#\n# Copyright \u00a9 2012 - 2021 Michal \u010ciha\u0159 <michal@cihar.com>\n#\n# This file is part of Weblate <https://weblate.org/>\n#\n# This program is free software: you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation, either version 3 of the License, or\n# (at your option) any later version.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program.  If not, see <https://www.gnu.org/licenses/>.\n#\n\"\"\"Provide user friendly names for social authentication methods.\"\"\"\n\nfrom django import template\nfrom django.conf import settings\nfrom django.contrib.staticfiles.storage import staticfiles_storage\nfrom django.utils.safestring import mark_safe\nfrom django.utils.translation import gettext_lazy\n\nregister = template.Library()\n\nSOCIALS = {\n    \"auth0\": {\"name\": \"Auth0\", \"image\": \"auth0.svg\"},\n    \"saml\": {\"name\": \"SAML\", \"image\": \"saml.svg\"},\n    \"google\": {\"name\": \"Google\", \"image\": \"google.svg\"},\n    \"google-oauth2\": {\"name\": \"Google\", \"image\": \"google.svg\"},\n    \"google-plus\": {\"name\": \"Google+\", \"image\": \"google.svg\"},\n    \"password\": {\"name\": gettext_lazy(\"Password\"), \"image\": \"password.svg\"},\n    \"email\": {\"name\": gettext_lazy(\"E-mail\"), \"image\": \"email.svg\"},\n    \"ubuntu\": {\"name\": \"Ubuntu\", \"image\": \"ubuntu.svg\"},\n    \"opensuse\": {\"name\": \"openSUSE\", \"image\": \"opensuse.svg\"},\n    \"fedora\": {\"name\": \"Fedora\", \"image\": \"fedora.svg\"},\n    \"facebook\": {\"name\": \"Facebook\", \"image\": \"facebook.svg\"},\n    \"github\": {\"name\": \"GitHub\", \"image\": \"github.svg\"},\n    \"github-enterprise\": {\"name\": \"GitHub Enterprise\", \"image\": \"github.svg\"},\n    \"bitbucket\": {\"name\": \"Bitbucket\", \"image\": \"bitbucket.svg\"},\n    \"bitbucket-oauth2\": {\"name\": \"Bitbucket\", \"image\": \"bitbucket.svg\"},\n    \"azuread-oauth2\": {\"name\": \"Azure\", \"image\": \"azure.svg\"},\n    \"azuread-tenant-oauth2\": {\"name\": \"Azure\", \"image\": \"azure.svg\"},\n    \"gitlab\": {\"name\": \"GitLab\", \"image\": \"gitlab.svg\"},\n    \"amazon\": {\"name\": \"Amazon\", \"image\": \"amazon.svg\"},\n    \"twitter\": {\"name\": \"Twitter\", \"image\": \"twitter.svg\"},\n    \"stackoverflow\": {\"name\": \"Stack Overflow\", \"image\": \"stackoverflow.svg\"},\n}\n\nIMAGE_SOCIAL_TEMPLATE = \"\"\"\n<img class=\"auth-image\" src=\"{image}\" />\n\"\"\"\n\nSOCIAL_TEMPLATE = \"\"\"\n{icon}\n{separator}\n{name}\n\"\"\"\n\n\ndef get_auth_params(auth: str):\n    \"\"\"Returns authentication parameters.\"\"\"\n    # Fallback values\n    params = {\"name\": auth, \"image\": \"password.svg\"}\n\n    # Hardcoded names\n    if auth in SOCIALS:\n        params.update(SOCIALS[auth])\n\n    # Settings override\n    settings_params = {\n        \"name\": f\"SOCIAL_AUTH_{auth.upper().replace('-','_')}_TITLE\",\n        \"image\": f\"SOCIAL_AUTH_{auth.upper().replace('-','_')}_IMAGE\",\n    }\n    for target, source in settings_params.items():\n        value = getattr(settings, source, None)\n        if value:\n            params[target] = value\n\n    return params\n\n\n@register.simple_tag\ndef auth_name(auth: str, separator: str = \"<br />\"):\n    \"\"\"Create HTML markup for social authentication method.\"\"\"\n    params = get_auth_params(auth)\n\n    if not params[\"image\"].startswith(\"http\"):\n        params[\"image\"] = staticfiles_storage.url(\"auth/\" + params[\"image\"])\n    params[\"icon\"] = IMAGE_SOCIAL_TEMPLATE.format(separator=separator, **params)\n\n    return mark_safe(SOCIAL_TEMPLATE.format(separator=separator, **params))\n\n\ndef get_auth_name(auth: str):\n    \"\"\"Get nice name for authentication backend.\"\"\"\n    return get_auth_params(auth)[\"name\"]\n", "path": "weblate/accounts/templatetags/authnames.py"}]}