mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-15 06:40:30 +05:30
sanitize file names
This commit is contained in:
parent
0e24a0981b
commit
e7c4040c20
@ -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\\._]+", "_")
|
||||||
|
}
|
@ -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.DOWNLOAD_SUCCESS_NOTIFICATION_ID
|
||||||
import com.github.libretube.constants.DownloadType
|
import com.github.libretube.constants.DownloadType
|
||||||
import com.github.libretube.extensions.TAG
|
import com.github.libretube.extensions.TAG
|
||||||
|
import com.github.libretube.extensions.sanitize
|
||||||
import com.github.libretube.util.DownloadHelper
|
import com.github.libretube.util.DownloadHelper
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
@ -37,7 +38,7 @@ class DownloadService : Service() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||||
videoName = intent?.getStringExtra("videoName")!!
|
videoName = intent?.getStringExtra("videoName")!!.sanitize()
|
||||||
videoUrl = intent.getStringExtra("videoUrl")!!
|
videoUrl = intent.getStringExtra("videoUrl")!!
|
||||||
audioUrl = intent.getStringExtra("audioUrl")!!
|
audioUrl = intent.getStringExtra("audioUrl")!!
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user