Skip to content

Commit

Permalink
User Settings > Personal allows creation of invalid display names moi…
Browse files Browse the repository at this point in the history
  • Loading branch information
RogerHaase committed Jul 12, 2024
1 parent 7af9860 commit f274623
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
6 changes: 4 additions & 2 deletions docs/user/accounts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ Name
Alias names are only useful at login.

Display-Name
The display name can be used to override your username, so you will still log in using your username
but your display name will be displayed to other users and in your history page.
The display name can be used if a wiki's custom auth method creates cryptic user names.
You will still login using your username or alias, but your display-name will be used
instead of your name to create your home page in the users namespace. Links in history pages
and footers will use your display-name.

Timezone
Setting this value will display edit times converted to your local time zone. For
Expand Down
12 changes: 12 additions & 0 deletions src/moin/apps/frontend/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2455,6 +2455,18 @@ class UserSettingsUIForm(Form):
)
)
success = False
if form[DISPLAY_NAME]:
display_name = str(form[DISPLAY_NAME])
if not user.normalizeName(display_name) == display_name:
response["flash"].append(
(
_("The displayname '{name}' contains invalid characters").format(
name=display_name
),
"error",
)
)
success = False
if part == "notification":
if (
form["email"].value != flaskg.user.email
Expand Down
13 changes: 6 additions & 7 deletions src/moin/themes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,18 +382,17 @@ def userhome(self):
:returns: arguments of user homepage link in tuple (wiki_href, display_name, title, exists)
"""
user = self.user
name = user.name0
display_name = user.display_name or name
name = user.display_name or user.name0
wikiname, itemname = getInterwikiHome(name)
title = f"{display_name} @ {wikiname}"
# link to (interwiki) user homepage
if is_local_wiki(wikiname):
exists = self.storage.has_item(itemname)
else:
# We cannot check if wiki pages exists in remote wikis
exists = True
wiki_href = url_for_item(itemname, wiki_name=wikiname, namespace=NAMESPACE_USERS)
return wiki_href, display_name, title, exists
title = wiki_href
return wiki_href, name, title, exists

def split_navilink(self, text):
"""
Expand Down Expand Up @@ -655,13 +654,13 @@ def get_editor_info(meta, external=False):
if userid:
u = user.User(userid)
name = u.name0
name = u.display_name or name
text = name
display_name = u.display_name or name
if title:
# we already have some address info
title = f"{display_name} @ {title}"
title = f"{name} @ {title}"
else:
title = display_name
title = name
if u.mailto_author and u.email:
email = u.email
css = "editor mail"
Expand Down

0 comments on commit f274623

Please sign in to comment.