mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-24 01:21:10 +00:00
fix(android): preserve emoji in presence reason logs (#108103)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package ai.openclaw.app.node
|
||||
|
||||
import ai.openclaw.app.takeUtf16Safe
|
||||
import android.os.Build
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.json.JsonPrimitive
|
||||
@@ -109,6 +110,6 @@ internal object NodePresenceAliveBeacon {
|
||||
return value
|
||||
.map { ch -> if (ch.isISOControl()) ' ' else ch }
|
||||
.joinToString("")
|
||||
.take(200)
|
||||
.takeUtf16Safe(200)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,4 +98,19 @@ class NodePresenceAliveBeaconTest {
|
||||
assertFalse(sanitized.contains("\t"))
|
||||
assertEquals(200, sanitized.length)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun sanitizeReasonForLog_preservesUtf16BoundariesAtLimit() {
|
||||
val splitPairPrefix = "bad\n${"x".repeat(195)}"
|
||||
assertEquals(
|
||||
"bad ${"x".repeat(195)}",
|
||||
NodePresenceAliveBeacon.sanitizeReasonForLog("$splitPairPrefix😀tail"),
|
||||
)
|
||||
|
||||
val completePairPrefix = "bad\n${"x".repeat(194)}"
|
||||
assertEquals(
|
||||
"bad ${"x".repeat(194)}😀",
|
||||
NodePresenceAliveBeacon.sanitizeReasonForLog("$completePairPrefix😀tail"),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user