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:
parent
2a2073fce0
commit
13d5068b6d
2 changed files with 19 additions and 1 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue