From 8d8bc637502e0837a518d74b7700bf3ee61d6afd Mon Sep 17 00:00:00 2001 From: Elijah Quartey Date: Wed, 13 Mar 2024 15:10:36 -0500 Subject: [PATCH] fix(auth): Android Intent URI Query Parameter Parsing --- .../AmplifyAuthCognitoPlugin.kt | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/auth/amplify_auth_cognito/android/src/main/kotlin/com/amazonaws/amplify/amplify_auth_cognito/AmplifyAuthCognitoPlugin.kt b/packages/auth/amplify_auth_cognito/android/src/main/kotlin/com/amazonaws/amplify/amplify_auth_cognito/AmplifyAuthCognitoPlugin.kt index 65161f9b43..07328b66d3 100644 --- a/packages/auth/amplify_auth_cognito/android/src/main/kotlin/com/amazonaws/amplify/amplify_auth_cognito/AmplifyAuthCognitoPlugin.kt +++ b/packages/auth/amplify_auth_cognito/android/src/main/kotlin/com/amazonaws/amplify/amplify_auth_cognito/AmplifyAuthCognitoPlugin.kt @@ -21,6 +21,7 @@ import io.flutter.embedding.engine.plugins.FlutterPlugin import io.flutter.embedding.engine.plugins.activity.ActivityAware import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding import io.flutter.plugin.common.PluginRegistry +import java.net.URLDecoder import java.util.Locale open class AmplifyAuthCognitoPlugin : @@ -590,15 +591,22 @@ open class AmplifyAuthCognitoPlugin : } } - /** * The query parameters of the URI. */ val Uri.queryParameters: MutableMap get() { val queryParameters = mutableMapOf() - for (name in queryParameterNames) { - queryParameters[name] = getQueryParameter(name) ?: "" + val queryString = this.encodedQuery ?: return queryParameters + val queries = queryString.split("&") + + for (query in queries) { + val idx = query.indexOf("=") + if (idx != -1) { + val name = URLDecoder.decode(query.substring(0, idx), "UTF-8") + val value = URLDecoder.decode(query.substring(idx + 1), "UTF-8") + queryParameters[name] = value + } } return queryParameters }