From e7b448126bb626b10df913ee38b5011c715c325c Mon Sep 17 00:00:00 2001 From: dankito Date: Sat, 16 May 2020 23:38:50 +0200 Subject: [PATCH] Cutting off everything after '?' of icon's url for icon filename --- .../net/dankito/banking/ui/presenter/BankingPresenter.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/presenter/BankingPresenter.kt b/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/presenter/BankingPresenter.kt index 3001ddf4..9a8e0761 100644 --- a/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/presenter/BankingPresenter.kt +++ b/ui/BankingUiCommon/src/main/java/net/dankito/banking/ui/presenter/BankingPresenter.kt @@ -26,6 +26,7 @@ import java.io.File import java.io.FileOutputStream import java.math.BigDecimal import java.net.URL +import java.net.URLEncoder import java.text.SimpleDateFormat import java.util.* import kotlin.collections.ArrayList @@ -197,7 +198,11 @@ open class BankingPresenter( val bankIconsDir = File(dataFolder, "bank_icons") bankIconsDir.mkdirs() - val bankIconFile = File(bankIconsDir, File(bankIconUrl).name) + var iconFilename = File(bankIconUrl).name + if (iconFilename.contains('?')) { + iconFilename = iconFilename.substring(0, iconFilename.indexOf('?')) + } + val bankIconFile = File(bankIconsDir, URLEncoder.encode(iconFilename, Charsets.US_ASCII.name())) URL(bankIconUrl).openConnection().getInputStream().buffered().use { iconInputStream -> FileOutputStream(bankIconFile).use { fileOutputStream ->