Skip to content

fix: swap High/Low in BasePermissions.set() and has()#1020

Merged
vgrem merged 1 commit into
masterfrom
fix/base-permissions-high-low
Jun 11, 2026
Merged

fix: swap High/Low in BasePermissions.set() and has()#1020
vgrem merged 1 commit into
masterfrom
fix/base-permissions-high-low

Conversation

@vgrem

@vgrem vgrem commented Jun 11, 2026

Copy link
Copy Markdown
Owner

Summary

BasePermissions.set() and has() had High and Low swapped internally:

  • Bits 0-31 (lower 32 bits) were stored in self.High
  • Bits 32-63 (upper 32 bits) were stored in self.Low

This caused to_json() to serialize values into the wrong API fields — sending Low bits as High and High bits as Low.

Fix

Swapped the field assignments in set() and field checks in has():

  if bit_pos < self._BITS_PER_INT:
-    self.High |= mask
     self.Low |= mask
+    self.High |= mask

- return bool(self.High & mask) if bit_pos < self._BITS_PER_INT else bool(self.Low & mask)
+ return bool(self.Low & mask) if bit_pos < self._BITS_PER_INT else bool(self.High & mask)

to_json() and set_property() are already correct — they just received swapped values.

Example

Before fix:

Permission Bit Stored in JSON output
ViewListItems (bit 0) Low self.High {"Low": 0, "High": 1}
ManageWeb (bit 35) High self.Low {"Low": 8, "High": 0}

After fix:

Permission Bit Stored in JSON output
ViewListItems (bit 0) Low self.Low {"Low": 1, "High": 0}
ManageWeb (bit 35) High self.High {"Low": 0, "High": 8}

Fixes #959

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
@vgrem
vgrem merged commit e5a500e into master Jun 11, 2026
2 of 3 checks passed
@dksdarkness

Copy link
Copy Markdown

Thank you for fixing it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BasePermissions.to_json() issue?

2 participants