Skip to content
Snippets Groups Projects
Commit 8fb8a564 authored by George Nachman's avatar George Nachman
Browse files

Don't assume that rangeOfCharacterFromSet:options: always returns a length of...

Don't assume that rangeOfCharacterFromSet:options: always returns a length of 1. This fixes a bug where copying text where a line ends in a surrogate pair fails because it creates an invalid UTF-16 string, chopping the surrogate pair in half. Issue 3544.
parent 03c20d84
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -4049,7 +4049,7 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
if (rangeOfLastWantedCharacter.location == NSNotFound) {
[string deleteCharactersInRange:NSMakeRange(0, string.length)];
} else if (rangeOfLastWantedCharacter.location < string.length - 1) {
NSUInteger i = rangeOfLastWantedCharacter.location + 1;
NSUInteger i = rangeOfLastWantedCharacter.location + rangeOfLastWantedCharacter.length;
[string deleteCharactersInRange:NSMakeRange(i, string.length - i)];
}
}
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment