Simplify hashtag line checker to avoid infinite loop in android matcher (#4779)

https://masto.nyc/@GetMisch/113557332197065306 causes an infinite loop
in the native matcher with the original pattern, trying a different
approach
This commit is contained in:
Levi Bard 2024-12-04 17:08:05 +01:00 committed by GitHub
commit af5d10cd09
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 6 deletions

View file

@ -8,8 +8,6 @@ import kotlin.random.Random
private const val POSSIBLE_CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
const val WORD_BREAK_EXPRESSION = """(^|$|[^\p{L}\p{N}_])"""
const val WORD_BREAK_FROM_SPACE_EXPRESSION = """(^|$|\s)"""
const val HASHTAG_EXPRESSION = "([\\w_]*[\\p{Alpha}_][\\w_]*)"
val hashtagPattern = Pattern.compile(HASHTAG_EXPRESSION, Pattern.CASE_INSENSITIVE or Pattern.MULTILINE)