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

import19: correct capitalization of special users #1569

Merged
merged 1 commit into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/moin/cli/migration/moin19/import19.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from moin.constants.contenttypes import CONTENTTYPE_USER, CHARSET19, CONTENTTYPE_MARKUP_OUT
from moin.constants.itemtypes import ITEMTYPE_DEFAULT
from moin.constants.namespaces import NAMESPACE_DEFAULT, NAMESPACE_USERPROFILES
from moin.constants.rights import SPECIAL_USERS
from moin.storage.error import NoSuchRevisionError
from moin.utils.mimetype import MimeType
from moin.utils.crypto import make_uuid, hash_hexdigest
Expand Down Expand Up @@ -78,6 +79,8 @@ def cli():
}
MIGR_STAT_KEYS = ['revs', 'items', 'attachments', 'users', 'missing_user', 'missing_file', 'del_item']

special_users_lower = [user.lower() for user in SPECIAL_USERS]

last_moin19_rev = {}
user_names = []
custom_namespaces = []
Expand Down Expand Up @@ -652,9 +655,15 @@ def regenerate_acl(acl_string, acl_rights_valid=ACL_RIGHTS_CONTENTS):
if (entries, rights) == (['Default'], []):
result.append("Default")
else:
entries_valid = []
for entry in entries:
if entry.lower() in special_users_lower and entry != entry.capitalize():
entries_valid.append(entry.capitalize())
else:
entries_valid.append(entry)
result.append("{0}{1}:{2}".format(
modifier,
','.join(entries),
','.join(entries_valid),
','.join(rights) # iterator has removed invalid rights
))
result = ' '.join(result)
Expand Down
4 changes: 4 additions & 0 deletions src/moin/constants/rights.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright: 2011 MoinMoin:ThomasWaldmann
# Copyright: 2024 MoinMoin:UlrichB
# License: GNU GPL v2 (or any later version), see LICENSE.txt for details.

"""
Expand Down Expand Up @@ -38,3 +39,6 @@

# rights that control access to operations on contents
ACL_RIGHTS_CONTENTS = [READ, PUBREAD, WRITE, CREATE, ADMIN, DESTROY, ]

# special user groups - order is important
SPECIAL_USERS = ['All', 'Known', 'Trusted', ]