Skip to content

CFString: honour kCFCompareAnchored in string search - #81

Merged
rfm merged 1 commit into
gnustep:masterfrom
DTW-Thalion:fix/cfstring-anchored
Sep 6, 2026
Merged

rfm merged 1 commit into
gnustep:masterfrom
DTW-Thalion:fix/cfstring-anchored

Conversation

@DTW-Thalion

Copy link
Copy Markdown
Contributor

CFStringFindWithOptionsAndLocale did not implement kCFCompareAnchored, so the
option was silently ignored. As a result CFStringHasPrefix and CFStringHasSuffix,
which rely on anchoring, returned true for any substring:
CFStringHasPrefix(CFSTR("Hello, World"), CFSTR("World")) was true. The fix rejects
a match that does not begin at the range start (or, with kCFCompareBackwards, end
at the range end). Verified against Apple CoreFoundation.

The search ignored kCFCompareAnchored, so CFStringHasPrefix and CFStringHasSuffix
matched a substring anywhere in the string. Reject a match that does not sit at
the anchored end of the search range.
@DTW-Thalion
DTW-Thalion force-pushed the fix/cfstring-anchored branch from 02bcda4 to 3bd54b1 Compare July 24, 2026 15:12
@DTW-Thalion DTW-Thalion reopened this Jul 24, 2026
@DTW-Thalion DTW-Thalion reopened this Jul 27, 2026
@rfm
rfm merged commit b18bc1d into gnustep:master Sep 6, 2026
3 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants