mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-07-05 16:35:10 +00:00
Avoid going out of bounds for special URL chars ending mail contents.
This commit is contained in:
@@ -195,18 +195,27 @@ static int cssEscapingCount;
|
||||
startLocation--;
|
||||
matchRange.location = startLocation + 1;
|
||||
|
||||
currentUrlRange = [selfCopy _rangeOfURLInRange: matchRange];
|
||||
if (![ranges hasRangeIntersection: currentUrlRange])
|
||||
if (currentUrlRange.length > matchLength)
|
||||
[newRanges addNonNSObject: ¤tUrlRange
|
||||
withSize: sizeof (NSRange)
|
||||
copy: YES];
|
||||
|
||||
rest.location = NSMaxRange (currentUrlRange);
|
||||
length = [selfCopy length];
|
||||
rest.length = length - rest.location;
|
||||
matchRange = [selfCopy rangeOfString: match
|
||||
options: 0 range: rest];
|
||||
// We avoid going out of bounds if the mail content actually finishes
|
||||
// with the @ (or something else) character
|
||||
if (matchRange.location < [selfCopy length])
|
||||
{
|
||||
currentUrlRange = [selfCopy _rangeOfURLInRange: matchRange];
|
||||
if (![ranges hasRangeIntersection: currentUrlRange])
|
||||
if (currentUrlRange.length > matchLength)
|
||||
[newRanges addNonNSObject: ¤tUrlRange
|
||||
withSize: sizeof (NSRange)
|
||||
copy: YES];
|
||||
|
||||
rest.location = NSMaxRange (currentUrlRange);
|
||||
length = [selfCopy length];
|
||||
rest.length = length - rest.location;
|
||||
matchRange = [selfCopy rangeOfString: match
|
||||
options: 0 range: rest];
|
||||
}
|
||||
else
|
||||
{
|
||||
matchRange.location = NSNotFound;
|
||||
}
|
||||
}
|
||||
|
||||
// Make the substitutions, keep track of the new offset
|
||||
|
||||
Reference in New Issue
Block a user