Verified Commit ed209a33 authored by Titouan Thibaud's avatar Titouan Thibaud Committed by ma1
Browse files

Bug 1945705 - Fix malformed download filename extracted from...

Bug 1945705 - Fix malformed download filename extracted from contentDisposition r=android-reviewers,rsainani

Differential Revision: https://phabricator.services.mozilla.com/D241072
parent 848293a7
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -57,7 +57,6 @@ import mozilla.components.support.base.facts.Action
import mozilla.components.support.base.facts.Fact
import mozilla.components.support.base.facts.collect
import mozilla.components.support.base.log.logger.Logger
import mozilla.components.support.ktx.kotlin.decode
import mozilla.components.support.ktx.kotlin.isEmail
import mozilla.components.support.ktx.kotlin.isExtensionUrl
import mozilla.components.support.ktx.kotlin.isGeoLocation
@@ -1524,7 +1523,7 @@ class GeckoEngineSession(
                        url = url,
                        contentLength = contentLength,
                        contentType = DownloadUtils.sanitizeMimeType(contentType),
                        fileName = fileName.sanitizeFileName().decode(),
                        fileName = fileName.sanitizeFileName(),
                        response = response,
                        isPrivate = privateMode,
                        openInApp = webResponse.requestExternalApp,
+2 −1
Original line number Diff line number Diff line
@@ -274,8 +274,9 @@ object DownloadUtils {

    private fun parseContentDisposition(contentDisposition: String): String? {
        return try {
            parseContentDispositionWithFileName(contentDisposition)
            val fileName = parseContentDispositionWithFileName(contentDisposition)
                ?: parseContentDispositionWithFileNameAsterisk(contentDisposition)
            Uri.decode(fileName)
        } catch (ex: IllegalStateException) {
            // This function is defined as returning null when it can't parse the header
            null