Skip to content

Commit ed7ff41

Browse files
author
Vadim Gremyachev
committed
fix: swap High/Low in BasePermissions.set() and has()
self.High was storing Low bits (0-31) and self.Low was storing High bits (32-63), causing to_json() to serialize values into the wrong SharePoint API fields. Fixed by swapping the assignments in set() and the checks in has() so that names match the SharePoint convention: - Low = bits 0-31 - High = bits 32-63 to_json() and set_property() need no changes. Fixes #959
1 parent 2fbdb06 commit ed7ff41

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

office365/sharepoint/permissions/base_permissions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ def set(self, perm: Union[PermissionKind, int]) -> None:
4242
bit_pos = perm.value - 1
4343
mask = 1 << (bit_pos % self._BITS_PER_INT)
4444
if bit_pos < self._BITS_PER_INT:
45-
self.High |= mask
46-
elif self._BITS_PER_INT <= bit_pos < self._MAX_BITS:
4745
self.Low |= mask
46+
elif self._BITS_PER_INT <= bit_pos < self._MAX_BITS:
47+
self.High |= mask
4848

4949
def has(self, perm: Union[PermissionKind, int]) -> bool:
5050
"""Checks if permission is set with support for both enum and integer values."""
@@ -58,7 +58,7 @@ def has(self, perm: Union[PermissionKind, int]) -> bool:
5858
if not 0 <= bit_pos < self._MAX_BITS:
5959
return False
6060
mask = 1 << (bit_pos % self._BITS_PER_INT)
61-
return bool(self.High & mask) if bit_pos < self._BITS_PER_INT else bool(self.Low & mask)
61+
return bool(self.Low & mask) if bit_pos < self._BITS_PER_INT else bool(self.High & mask)
6262

6363
def clear_all(self):
6464
"""Clears all permissions for the current instance."""

0 commit comments

Comments
 (0)