Fix linkify helper index out of bounds with parenthesis (#6140)
When parenthesis were mismatched by having more opening parenthesis than closing ones, we could end up incorrectly making the URLSpan `end` value greater than the actual text length, causing an `IndexOutOfBoundsException`
This commit is contained in:
committed by
GitHub
parent
2a2073fce0
commit
13d5068b6d
+1
-1
@@ -97,7 +97,7 @@ object LinkifyHelper {
|
||||
val closingParenthesisCount = linkifiedTextLastPath.count { it == ')' }
|
||||
val openingParenthesisCount = linkifiedTextLastPath.count { it == '(' }
|
||||
// If it's not part of a pair, remove it from the link span by adjusting the end index
|
||||
end -= closingParenthesisCount - openingParenthesisCount
|
||||
end -= (closingParenthesisCount - openingParenthesisCount).coerceAtLeast(0)
|
||||
}
|
||||
return end
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user