Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b64f6dcd authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "[Partner request] Remove https and trailing slash in an https origin"...

Merge "[Partner request] Remove https and trailing slash in an https origin" into udc-dev am: f90961ff am: 18570c5f

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23591487



Change-Id: Ib9c2ce4d47835388b479b1b850957bed6ef66bc8
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 964c8f7f 18570c5f
Loading
Loading
Loading
Loading
+18 −2
Original line number Diff line number Diff line
@@ -66,8 +66,9 @@ class CredentialManagerRepo(
        )

        val originName: String? = when (requestInfo?.type) {
            RequestInfo.TYPE_CREATE -> requestInfo.createCredentialRequest?.origin
            RequestInfo.TYPE_GET -> requestInfo.getCredentialRequest?.origin
            RequestInfo.TYPE_CREATE -> processHttpsOrigin(
                requestInfo.createCredentialRequest?.origin)
            RequestInfo.TYPE_GET -> processHttpsOrigin(requestInfo.getCredentialRequest?.origin)
            else -> null
        }

@@ -247,6 +248,9 @@ class CredentialManagerRepo(
    }

    companion object {
        private const val HTTPS = "https://"
        private const val FORWARD_SLASH = "/"

        fun sendCancellationCode(
            cancelCode: Int,
            requestToken: IBinder?,
@@ -266,5 +270,17 @@ class CredentialManagerRepo(
                CancelUiRequest::class.java
            )
        }

        /** Removes "https://", and the trailing slash if present for an https request. */
        private fun processHttpsOrigin(origin: String?): String? {
            var processed = origin
            if (processed?.startsWith(HTTPS) == true) { // Removes "https://"
                processed = processed.substring(HTTPS.length)
                if (processed?.endsWith(FORWARD_SLASH) == true) { // Removes the trailing slash
                    processed = processed.substring(0, processed.length - 1)
                }
            }
            return processed
        }
    }
}