LivingWithHippos / unchained-android

App to interact with real-debrid API
GNU General Public License v3.0
404 stars 50 forks source link

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

Closed LivingWithHippos closed 1 year ago

LivingWithHippos commented 1 year ago

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