diff --git a/.github/badges/branches.svg b/.github/badges/branches.svg
index f97e335c..bb5b45e8 100644
--- a/.github/badges/branches.svg
+++ b/.github/badges/branches.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/.github/badges/jacoco.svg b/.github/badges/jacoco.svg
index 5e7bd949..2554fd02 100644
--- a/.github/badges/jacoco.svg
+++ b/.github/badges/jacoco.svg
@@ -1 +1 @@
-
+
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8f492cf5..620c8b57 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,11 @@
The changelog for `Superwall`. Also see the [releases](https://github.com/superwall/Superwall-Android/releases) on GitHub.
+## 2.7.13
+
+## Fixes
+- Fix `device.appVersionPadded` and `device.sdkVersionPadded` emitting non-ASCII digits on devices whose default locale uses a non-Latin numbering system (e.g. `ar-EG`, `fa-IR`, `bn-BD`), which caused audience-rule version comparisons to misbucket affected users.
+
## 2.7.12
## Enhancements
diff --git a/superwall/src/main/java/com/superwall/sdk/network/device/DeviceHelper.kt b/superwall/src/main/java/com/superwall/sdk/network/device/DeviceHelper.kt
index d61ca204..f6265d65 100644
--- a/superwall/src/main/java/com/superwall/sdk/network/device/DeviceHelper.kt
+++ b/superwall/src/main/java/com/superwall/sdk/network/device/DeviceHelper.kt
@@ -653,7 +653,7 @@ class DeviceHelper(
}
}
-private fun String.asPadded(): String {
+internal fun String.asPadded(): String {
val components = split("-")
if (components.isEmpty()) {
return ""
@@ -673,7 +673,7 @@ private fun String.asPadded(): String {
// Pad beta number and add to appendix
if (appendixComponents.size > 1) {
appendixVersion =
- String.format("%03d", appendixComponents[1].toIntOrNull() ?: 0)
+ String.format(Locale.US, "%03d", appendixComponents[1].toIntOrNull() ?: 0)
appendix += ".$appendixVersion"
}
}
@@ -682,15 +682,15 @@ private fun String.asPadded(): String {
val versionComponents = versionNumber.split(".")
var newVersion = ""
if (versionComponents.isNotEmpty()) {
- val major = String.format("%03d", versionComponents[0].toIntOrNull() ?: 0)
+ val major = String.format(Locale.US, "%03d", versionComponents[0].toIntOrNull() ?: 0)
newVersion += major
}
if (versionComponents.size > 1) {
- val minor = String.format("%03d", versionComponents[1].toIntOrNull() ?: 0)
+ val minor = String.format(Locale.US, "%03d", versionComponents[1].toIntOrNull() ?: 0)
newVersion += ".$minor"
}
if (versionComponents.size > 2) {
- val patch = String.format("%03d", versionComponents[2].toIntOrNull() ?: 0)
+ val patch = String.format(Locale.US, "%03d", versionComponents[2].toIntOrNull() ?: 0)
newVersion += ".$patch"
}
diff --git a/superwall/src/test/java/com/superwall/sdk/network/device/DeviceHelperAsPaddedTest.kt b/superwall/src/test/java/com/superwall/sdk/network/device/DeviceHelperAsPaddedTest.kt
new file mode 100644
index 00000000..2ed41707
--- /dev/null
+++ b/superwall/src/test/java/com/superwall/sdk/network/device/DeviceHelperAsPaddedTest.kt
@@ -0,0 +1,60 @@
+package com.superwall.sdk.network.device
+
+import org.junit.After
+import org.junit.Assert.assertEquals
+import org.junit.Before
+import org.junit.Test
+import java.util.Locale
+
+class DeviceHelperAsPaddedTest {
+ private lateinit var previousLocale: Locale
+
+ @Before
+ fun setUp() {
+ previousLocale = Locale.getDefault()
+ }
+
+ @After
+ fun tearDown() {
+ Locale.setDefault(previousLocale)
+ }
+
+ @Test
+ fun `pads major, minor and patch with ASCII digits under en-US locale`() {
+ Locale.setDefault(Locale.US)
+ assertEquals("000.000.003", "0.0.3".asPadded())
+ assertEquals("001.002.003", "1.2.3".asPadded())
+ assertEquals("012.034.056", "12.34.56".asPadded())
+ }
+
+ @Test
+ fun `keeps ASCII digits when default locale renders digits as Arabic-Indic`() {
+ Locale.setDefault(Locale.forLanguageTag("ar-EG"))
+ assertEquals("000.000.003", "0.0.3".asPadded())
+ assertEquals("001.002.003", "1.2.3".asPadded())
+ }
+
+ @Test
+ fun `keeps ASCII digits when default locale renders digits as Extended Arabic-Indic`() {
+ Locale.setDefault(Locale.forLanguageTag("fa-IR"))
+ assertEquals("000.000.003", "0.0.3".asPadded())
+ }
+
+ @Test
+ fun `keeps ASCII digits when default locale renders digits as Bengali`() {
+ Locale.setDefault(Locale.forLanguageTag("bn-BD"))
+ assertEquals("000.000.003", "0.0.3".asPadded())
+ }
+
+ @Test
+ fun `pads beta appendix numerically with ASCII digits under non-Latin locale`() {
+ Locale.setDefault(Locale.forLanguageTag("ar-EG"))
+ assertEquals("001.002.003-beta.004", "1.2.3-beta.4".asPadded())
+ }
+
+ @Test
+ fun `preserves non-numeric appendix without a dot`() {
+ Locale.setDefault(Locale.forLanguageTag("ar-EG"))
+ assertEquals("001.002.003-rc", "1.2.3-rc".asPadded())
+ }
+}