From eb456ef2b0d11e3ca84a2d4ccd8f3237a2a4054d Mon Sep 17 00:00:00 2001
From: Veeti Paananen <veeti.paananen@rojekti.fi>
Date: Wed, 4 Oct 2017 19:32:32 +0300
Subject: [PATCH] Fix implicit locale string formatting bugs

Depending on the phone language the default format may use Arabic
numerals, etc. when not desired.

Bug: fixes #7006
Closes #7040
---
 .../thoughtcrime/securesms/attachments/AttachmentServer.java  | 3 ++-
 src/org/thoughtcrime/securesms/database/XmlBackup.java        | 3 ++-
 src/org/thoughtcrime/securesms/util/TelephonyUtil.java        | 4 +++-
 3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/org/thoughtcrime/securesms/attachments/AttachmentServer.java b/src/org/thoughtcrime/securesms/attachments/AttachmentServer.java
index 39c0d4e8fd..43a7ab263f 100644
--- a/src/org/thoughtcrime/securesms/attachments/AttachmentServer.java
+++ b/src/org/thoughtcrime/securesms/attachments/AttachmentServer.java
@@ -25,6 +25,7 @@ import java.net.SocketException;
 import java.net.SocketTimeoutException;
 import java.net.UnknownHostException;
 import java.security.MessageDigest;
+import java.util.Locale;
 import java.util.Map;
 import java.util.Properties;
 import java.util.StringTokenizer;
@@ -63,7 +64,7 @@ public class AttachmentServer implements Runnable {
   }
 
   public Uri getUri() {
-    return Uri.parse(String.format("http://127.0.0.1:%d/%s", port, auth));
+    return Uri.parse(String.format(Locale.ROOT, "http://127.0.0.1:%d/%s", port, auth));
   }
 
   public void start() {
diff --git a/src/org/thoughtcrime/securesms/database/XmlBackup.java b/src/org/thoughtcrime/securesms/database/XmlBackup.java
index 17f83c8278..a206825a01 100644
--- a/src/org/thoughtcrime/securesms/database/XmlBackup.java
+++ b/src/org/thoughtcrime/securesms/database/XmlBackup.java
@@ -12,6 +12,7 @@ import java.io.FileNotFoundException;
 import java.io.FileWriter;
 import java.io.IOException;
 import java.text.SimpleDateFormat;
+import java.util.Locale;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -182,7 +183,7 @@ public class XmlBackup {
       bufferedWriter.newLine();
       bufferedWriter.write(CREATED_BY);
       bufferedWriter.newLine();
-      bufferedWriter.write(String.format(OPEN_TAG_SMSES, count));
+      bufferedWriter.write(String.format(Locale.ROOT, OPEN_TAG_SMSES, count));
     }
 
     public void writeItem(XmlBackupItem item) throws IOException {
diff --git a/src/org/thoughtcrime/securesms/util/TelephonyUtil.java b/src/org/thoughtcrime/securesms/util/TelephonyUtil.java
index dedb56091a..5d172ea086 100644
--- a/src/org/thoughtcrime/securesms/util/TelephonyUtil.java
+++ b/src/org/thoughtcrime/securesms/util/TelephonyUtil.java
@@ -6,6 +6,8 @@ import android.net.ConnectivityManager;
 import android.telephony.TelephonyManager;
 import android.util.Log;
 
+import java.util.Locale;
+
 public class TelephonyUtil {
   private static final String TAG = TelephonyUtil.class.getSimpleName();
 
@@ -25,7 +27,7 @@ public class TelephonyUtil {
       return tm.getNetworkOperator();
     } else if (configMcc != 0 && configMnc != 0) {
       Log.w(TAG, "Choosing MCC+MNC info from current context's Configuration");
-      return String.format("%03d%d",
+      return String.format(Locale.ROOT, "%03d%d",
           configMcc,
           configMnc == Configuration.MNC_ZERO ? 0 : configMnc);
     } else {