LivingWithHippos/unchained-android

[BUG] Http trackers in magnets trigger the standard web regex and breaks link recognition

LivingWithHippos opened this issue · 0 comments

how to reproduce:

  1. find a magnet link with an http tracker like ...&tr=http://tracker.trackerfix.com...
  2. share it with unchained
  3. it will get recognized as a normal hoster link and be sent to the hosters api instead of the magnets api breaking the unlock

the breaking code is

val urlPattern =
    "https?://(-\\.)?([\\w]+\\.)+([\\w]{2,})+(#([\\w\\-]+))?(/[\\w\\-\\.,?^=%&:/~+#]*)?"

val simpleWebRegex = Regex(urlPattern)

fun String.isSimpleWebUrl(): Boolean = simpleWebRegex.containsMatchIn(this)

since containsMatchIn just checks if there's a match anywhere in the string.

Move isSimpleWebUrl as last check when checking a link