Repository navigation
Conversation
encode_sort_controls built each SortKey with three assignments, the first two ending in commas, which Ruby parses as one multiple assignment. control[0] received the array of all three encoded fields, so after join every SortKey carried five elements: type, rule, reverse, rule, reverse. The fields also used universal tags. RFC 2891 defines orderingRule as [0] and reverseOrder as [1] BOOLEAN DEFAULT FALSE. Build each SortKey explicitly, encode the optional fields as context-specific 0x80 and 0x81, omit orderingRule when none is given and reverseOrder when false, and cover the produced bytes with tests. Co-authored-by: Claude Mythos 5.1 <noreply@anthropic.com>
wtn
force-pushed
the
sort
branch
2 times, most recently
from
October 31, 2026 05:39
722f27a to
6260ef9
Compare
wtn
marked this pull request as ready for review
October 31, 2026 05:42
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since 4c24b4e (January 2012),
encode_sort_controlsbuilds the SortKey with assignments ending in commas. Ruby parses them as one multiple assignment, so the rule and reverse flag are sent twice:The rule and reverse flag also use universal tags. RFC 2891 tags them
[0]and[1]. Because the control isn't critical, a server that can't decode it may ignore it and return unsorted results.Fix
The rule is now encoded as
0x80and left out when empty. The reverse flag is encoded as0x81and left out when false. Sorting should take effect on servers that ignored the malformed control, and the reverse flag should give descending order.The new tests decode the control and compare the encoded value for a key with a rule and reverse flag. Without the change they fail with
<[["cn"]]> expected but was <[["cn", "", false, "", false]]>.