Skip to content

Commit 38d0d43

Browse files
authored
Fixed the issue with decimal point in Subscription-Userinfo field (MetaCubeX#547)
MetaCubeX#292
1 parent 131097a commit 38d0d43

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

service/src/main/java/com/github/kr328/clash/service/ProfileManager.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,13 @@ class ProfileManager(private val context: Context) : IProfileManager,
160160
val info = flag.split("=")
161161
when {
162162
info[0].contains("upload") && info[1].isNotEmpty() -> upload =
163-
BigDecimal(info[1]).longValueExact()
163+
BigDecimal(info[1].split('.').first()).longValueExact()
164164

165165
info[0].contains("download") && info[1].isNotEmpty() -> download =
166-
BigDecimal(info[1]).longValueExact()
166+
BigDecimal(info[1].split('.').first()).longValueExact()
167167

168168
info[0].contains("total") && info[1].isNotEmpty() -> total =
169-
BigDecimal(info[1]).longValueExact()
169+
BigDecimal(info[1].split('.').first()).longValueExact()
170170

171171
info[0].contains("expire") && info[1].isNotEmpty() -> {
172172
if (info[1].isNotEmpty()) {

service/src/main/java/com/github/kr328/clash/service/ProfileProcessor.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import kotlinx.coroutines.sync.withLock
2121
import kotlinx.coroutines.withContext
2222
import okhttp3.OkHttpClient
2323
import okhttp3.Request
24+
import java.math.BigDecimal
2425
import java.net.URL
2526
import java.util.*
2627
import java.util.concurrent.TimeUnit
@@ -88,13 +89,13 @@ object ProfileProcessor {
8889
val info = flag.split("=")
8990
when {
9091
info[0].contains("upload") && info[1].isNotEmpty() -> upload =
91-
info[1].toLong()
92+
BigDecimal(info[1].split('.').first()).longValueExact()
9293

9394
info[0].contains("download") && info[1].isNotEmpty() -> download =
94-
info[1].toLong()
95+
BigDecimal(info[1].split('.').first()).longValueExact()
9596

9697
info[0].contains("total") && info[1].isNotEmpty() -> total =
97-
info[1].toLong()
98+
BigDecimal(info[1].split('.').first()).longValueExact()
9899

99100
info[0].contains("expire") && info[1].isNotEmpty() -> expire =
100101
(info[1].toDouble() * 1000).toLong()

0 commit comments

Comments
 (0)