fix some URLEncoded filenames are not decoded properly

This commit is contained in:
AmirHossein Abdolmotallebi 2024-08-26 13:55:57 +03:30
parent caa5538a9d
commit eff6928930
2 changed files with 6 additions and 0 deletions

View File

@ -12,6 +12,8 @@
### Fixed
- some URLEncoded filenames are not decoded properly
### Security
## 1.0.7

View File

@ -1,4 +1,5 @@
package ir.amirab.downloader.connection.response.headers
import java.net.URLDecoder
fun extractFileNameFromContentDisposition(contentDispositionValue: String): String? {
@ -16,6 +17,9 @@ fun extractFileNameFromContentDisposition(contentDispositionValue: String): Stri
?.groups
?.get("fileName")
?.value?.let {
runCatching { URLDecoder.decode(it, Charsets.UTF_8) }
.getOrNull()
}?.let {
return it
}
return null