For #27538: Return null for clipboard text longer than MAX_URI_LENGTH.

This avoids extra processing of large text that is unlikely to be an URL.
This commit is contained in:
mcarare 2022-11-02 20:04:28 +02:00 committed by mergify[bot]
parent be7c0ba401
commit c67bbb3e03
1 changed files with 5 additions and 0 deletions

View File

@ -11,6 +11,7 @@ import android.os.Build
import android.view.textclassifier.TextClassifier
import androidx.annotation.VisibleForTesting
import androidx.core.content.getSystemService
import mozilla.components.support.ktx.kotlin.MAX_URI_LENGTH
import mozilla.components.support.utils.SafeUrl
import mozilla.components.support.utils.WebURLFinder
import org.mozilla.fenix.perf.Performance.logger
@ -58,6 +59,10 @@ class ClipboardHandler(val context: Context) {
*/
fun extractURL(): String? {
return text?.let {
if (it.length > MAX_URI_LENGTH) {
return null
}
val finder = WebURLFinder(it)
finder.bestWebURL()
}