Skip to content

Commit

Permalink
Merge pull request #1569 from UlrichB22/import_acl
Browse files Browse the repository at this point in the history
import19: correct capitalization of special users
  • Loading branch information
RogerHaase authored Jan 2, 2024
2 parents 843c113 + 70c2c48 commit 9fa1521
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
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', ]

0 comments on commit 9fa1521

Please sign in to comment.