[fenix] For https://github.com/mozilla-mobile/fenix/issues/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.
pull/600/head
mcarare 2 years ago committed by mergify[bot]
parent f40f360679
commit 3ffc6a01f8

@ -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()
}

Loading…
Cancel
Save