From 0cb0339d7fec4aa7791d05f3a6c9afe2879cd578 Mon Sep 17 00:00:00 2001 From: Calise Cheung Date: Tue, 18 Jul 2023 17:55:08 -0700 Subject: [PATCH 1/3] Switch to use Charset.forName("UTF-8").name() in encoding Switching to use Charset.forName("UTF-8").name() to fix the Illegal Charset Name Exception on Android 6 (API 23). (MOB-19119) --- code/app/build.gradle | 4 +++- .../com/adobe/marketing/mobile/edge/identity/URLUtils.java | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/code/app/build.gradle b/code/app/build.gradle index bc005aa9..1cef94c3 100644 --- a/code/app/build.gradle +++ b/code/app/build.gradle @@ -65,7 +65,9 @@ dependencies { implementation "com.adobe.marketing.mobile:core:2.+" implementation 'com.adobe.marketing.mobile:identity:2.+' - implementation 'com.adobe.marketing.mobile:edgeconsent:2.+' + implementation ('com.adobe.marketing.mobile:edgeconsent:2.+') { + transitive = false + } implementation 'com.adobe.marketing.mobile:assurance:2.+' implementation ('com.adobe.marketing.mobile:edge:2.+') { transitive = false diff --git a/code/edgeidentity/src/main/java/com/adobe/marketing/mobile/edge/identity/URLUtils.java b/code/edgeidentity/src/main/java/com/adobe/marketing/mobile/edge/identity/URLUtils.java index 2970d61c..b98e5c63 100644 --- a/code/edgeidentity/src/main/java/com/adobe/marketing/mobile/edge/identity/URLUtils.java +++ b/code/edgeidentity/src/main/java/com/adobe/marketing/mobile/edge/identity/URLUtils.java @@ -17,7 +17,7 @@ import com.adobe.marketing.mobile.util.StringUtils; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; +import java.nio.charset.Charset; class URLUtils { @@ -54,7 +54,7 @@ static String generateURLVariablesPayload(final String ts, final String ecid, fi // No need to encode urlFragment.append("null"); } else { - urlFragment.append(URLEncoder.encode(theIdString, StandardCharsets.UTF_8.toString())); + urlFragment.append(URLEncoder.encode(theIdString, Charset.forName("UTF-8").name())); } } catch (UnsupportedEncodingException e) { Log.debug(LOG_TAG, LOG_SOURCE, String.format("Failed to encode urlVariable string: %s", e)); From 93a6ce80f72ce2b6d69eff50b8f1b675e503e918 Mon Sep 17 00:00:00 2001 From: Calise Cheung Date: Wed, 19 Jul 2023 14:53:33 -0700 Subject: [PATCH 2/3] Add IlegalArgumentException to the try catch. Add IlegalArgumentException to the try catch. --- .../java/com/adobe/marketing/mobile/edge/identity/URLUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/edgeidentity/src/main/java/com/adobe/marketing/mobile/edge/identity/URLUtils.java b/code/edgeidentity/src/main/java/com/adobe/marketing/mobile/edge/identity/URLUtils.java index b98e5c63..76682325 100644 --- a/code/edgeidentity/src/main/java/com/adobe/marketing/mobile/edge/identity/URLUtils.java +++ b/code/edgeidentity/src/main/java/com/adobe/marketing/mobile/edge/identity/URLUtils.java @@ -56,7 +56,7 @@ static String generateURLVariablesPayload(final String ts, final String ecid, fi } else { urlFragment.append(URLEncoder.encode(theIdString, Charset.forName("UTF-8").name())); } - } catch (UnsupportedEncodingException e) { + } catch (UnsupportedEncodingException | IllegalArgumentException e) { Log.debug(LOG_TAG, LOG_SOURCE, String.format("Failed to encode urlVariable string: %s", e)); } return urlFragment.toString(); From f953db9a8fd33bee195e02b746f61fbc7b33189e Mon Sep 17 00:00:00 2001 From: Calise Cheung Date: Thu, 20 Jul 2023 11:18:15 -0700 Subject: [PATCH 3/3] append a null to the urlFragment in catch case append a null to the urlFragment in catch case --- .../java/com/adobe/marketing/mobile/edge/identity/URLUtils.java | 1 + 1 file changed, 1 insertion(+) diff --git a/code/edgeidentity/src/main/java/com/adobe/marketing/mobile/edge/identity/URLUtils.java b/code/edgeidentity/src/main/java/com/adobe/marketing/mobile/edge/identity/URLUtils.java index 76682325..cb76fb4d 100644 --- a/code/edgeidentity/src/main/java/com/adobe/marketing/mobile/edge/identity/URLUtils.java +++ b/code/edgeidentity/src/main/java/com/adobe/marketing/mobile/edge/identity/URLUtils.java @@ -57,6 +57,7 @@ static String generateURLVariablesPayload(final String ts, final String ecid, fi urlFragment.append(URLEncoder.encode(theIdString, Charset.forName("UTF-8").name())); } } catch (UnsupportedEncodingException | IllegalArgumentException e) { + urlFragment.append("null"); Log.debug(LOG_TAG, LOG_SOURCE, String.format("Failed to encode urlVariable string: %s", e)); } return urlFragment.toString();