From 4ee37a7c647c8ec35aa8a321fc0d5af0ad7b17b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=80=20?= =?UTF-8?q?=D0=97=D0=B0=D1=86=D0=B5=D0=BF=D0=B8=D0=BD?= Date: Tue, 18 Jun 2019 19:13:22 +0300 Subject: [PATCH] [android] Added utf-8 encoding for inapp details bundle for web catalog header --- .../bookmarks/BookmarksCatalogFragment.java | 24 ++++++++++++++++++- .../maps/purchase/PurchaseUtils.java | 2 +- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/android/src/com/mapswithme/maps/bookmarks/BookmarksCatalogFragment.java b/android/src/com/mapswithme/maps/bookmarks/BookmarksCatalogFragment.java index 5a6f1f6077..071455d6ee 100644 --- a/android/src/com/mapswithme/maps/bookmarks/BookmarksCatalogFragment.java +++ b/android/src/com/mapswithme/maps/bookmarks/BookmarksCatalogFragment.java @@ -39,6 +39,7 @@ import com.mapswithme.maps.purchase.PurchaseController; import com.mapswithme.maps.purchase.PurchaseFactory; import com.mapswithme.maps.purchase.PurchaseUtils; import com.mapswithme.util.ConnectionState; +import com.mapswithme.util.CrashlyticsUtils; import com.mapswithme.util.HttpClient; import com.mapswithme.util.UiUtils; import com.mapswithme.util.Utils; @@ -46,7 +47,9 @@ import com.mapswithme.util.log.Logger; import com.mapswithme.util.log.LoggerFactory; import com.mapswithme.util.statistics.Statistics; +import java.io.UnsupportedEncodingException; import java.lang.ref.WeakReference; +import java.net.URLEncoder; import java.util.Arrays; import java.util.HashMap; import java.util.List; @@ -385,7 +388,26 @@ public class BookmarksCatalogFragment extends BaseWebViewMwmFragment } LOGGER.i(TAG, "Product details for web catalog loaded: " + details); - loadCatalog(PurchaseUtils.toProductDetailsBundle(details)); + loadCatalog(toDetailsBundle(details)); + } + + @Nullable + private String toDetailsBundle(@NonNull List details) + { + String bundle = PurchaseUtils.toProductDetailsBundle(details); + String encodedBundle = null; + try + { + encodedBundle = URLEncoder.encode(bundle, "UTF-8"); + } + catch (UnsupportedEncodingException e) + { + String msg = "Failed to encode details bundle '" + bundle + "': "; + LOGGER.e(TAG, msg, e); + CrashlyticsUtils.logException(new RuntimeException(msg, e)); + } + + return encodedBundle; } @Override diff --git a/android/src/com/mapswithme/maps/purchase/PurchaseUtils.java b/android/src/com/mapswithme/maps/purchase/PurchaseUtils.java index 07c1cba099..a74b8922a3 100644 --- a/android/src/com/mapswithme/maps/purchase/PurchaseUtils.java +++ b/android/src/com/mapswithme/maps/purchase/PurchaseUtils.java @@ -71,7 +71,7 @@ public class PurchaseUtils priceJson.put("price_string", Utils.formatCurrencyString(price, currencyCode)); bundleJson.put(details.getSku(), priceJson); } - catch (JSONException e) + catch (Exception e) { Logger logger = LoggerFactory.INSTANCE.getLogger(LoggerFactory.Type.BILLING); String tag = PurchaseUtils.class.getSimpleName();