Merge pull request #1322 from Bnyro/backup

sanitize file names
This commit is contained in:
Bnyro 2022-09-18 17:14:58 +02:00 committed by GitHub
commit eaf115e489
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -0,0 +1,8 @@
package com.github.libretube.extensions
/**
* Replace file name specific chars
*/
fun String.sanitize(): String {
return this.replace("[^a-zA-Z0-9\\._]+", "_")
}

View File

@ -18,6 +18,7 @@ import com.github.libretube.constants.DOWNLOAD_FAILURE_NOTIFICATION_ID
import com.github.libretube.constants.DOWNLOAD_SUCCESS_NOTIFICATION_ID
import com.github.libretube.constants.DownloadType
import com.github.libretube.extensions.TAG
import com.github.libretube.extensions.sanitize
import com.github.libretube.util.DownloadHelper
import java.io.File
@ -37,7 +38,7 @@ class DownloadService : Service() {
}
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
videoName = intent?.getStringExtra("videoName")!!
videoName = intent?.getStringExtra("videoName")!!.sanitize()
videoUrl = intent.getStringExtra("videoUrl")!!
audioUrl = intent.getStringExtra("audioUrl")!!