[db] Reject invalid URIs when adding repos

This commit is contained in:
Torsten Grote
2023-08-24 16:19:18 +02:00
committed by Michael Pöhn
parent aaa4b56a9d
commit 40c71e4b06
2 changed files with 26 additions and 1 deletions

View File

@@ -25,6 +25,7 @@ import org.fdroid.database.Repository
import org.fdroid.database.RepositoryDaoInt
import org.fdroid.download.DownloaderFactory
import org.fdroid.download.HttpManager
import org.fdroid.download.HttpManager.Companion.isInvalidHttpUrl
import org.fdroid.download.NotFoundException
import org.fdroid.index.IndexFormatVersion
import org.fdroid.index.SigningException
@@ -125,7 +126,11 @@ internal class RepoAdder(
// get repo url and fingerprint
val nUri = repoUriGetter.getUri(url)
log.info("Parsed URI: $nUri")
// TODO reject non-http(s) Uri here
if (isInvalidHttpUrl(nUri.uri.toString())) {
val e = IllegalArgumentException("Unsupported URI: ${nUri.uri}")
addRepoState.value = AddRepoError(INVALID_INDEX, e)
return
}
// some plumping to receive the repo preview
var receivedRepo: Repository? = null