Skip to content

Commit

Permalink
fix: Safe intent extra checks (#1816)
Browse files Browse the repository at this point in the history
  • Loading branch information
quickdesh authored Nov 9, 2024
1 parent 7976495 commit 37e1834
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ class ExternalIntents {
*/
suspend fun getExternalIntent(
context: Context,
animeId: Long?,
episodeId: Long?,
animeId: Long,
episodeId: Long,
chosenVideo: Video?,
): Intent? {
anime = getAnime.await(animeId!!) ?: return null
anime = getAnime.await(animeId) ?: return null
source = sourceManager.get(anime.source) ?: return null
episode = getEpisodesByAnimeId.await(anime.id).find { it.id == episodeId } ?: return null

Expand Down Expand Up @@ -555,7 +555,7 @@ class ExternalIntents {
* @param animeId the id of the anime.
* @param episodeId the id of the episode.
*/
suspend fun newIntent(context: Context, animeId: Long?, episodeId: Long?, video: Video?): Intent? {
suspend fun newIntent(context: Context, animeId: Long, episodeId: Long, video: Video?): Intent? {
return externalIntents.getExternalIntent(context, animeId, episodeId, video)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ class PlayerActivity : BaseActivity() {
}

override fun onNewIntent(intent: Intent) {
val animeId = intent.extras!!.getLong("animeId", -1)
val episodeId = intent.extras!!.getLong("episodeId", -1)
val vidList = intent.extras!!.getString("vidList", "")
val vidIndex = intent.extras!!.getInt("vidIndex", 0)
val animeId = intent.extras?.getLong("animeId") ?: -1
val episodeId = intent.extras?.getLong("episodeId") ?: -1
val vidList = intent.extras?.getString("vidList") ?: ""
val vidIndex = intent.extras?.getInt("vidIndex") ?: 0
if (animeId == -1L || episodeId == -1L) {
finish()
return
Expand Down

0 comments on commit 37e1834

Please sign in to comment.