惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Apple Machine Learning Research
Apple Machine Learning Research
aimingoo的专栏
aimingoo的专栏
H
Help Net Security
腾讯CDC
T
Tailwind CSS Blog
Hugging Face - Blog
Hugging Face - Blog
人人都是产品经理
人人都是产品经理
酷 壳 – CoolShell
酷 壳 – CoolShell
MongoDB | Blog
MongoDB | Blog
宝玉的分享
宝玉的分享
有赞技术团队
有赞技术团队
美团技术团队
雷峰网
雷峰网
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 司徒正美
博客园_首页
Recent Announcements
Recent Announcements
云风的 BLOG
云风的 BLOG
B
Blog RSS Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
D
Docker
博客园 - Franky
Jina AI
Jina AI

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(android): bound inline chat image payloads · openclaw...
obviyus · 2026-05-18 · via Recent Commits to openclaw:main

File tree

  • apps/android/app/src

    • main/java/ai/openclaw/app/ui/chat

    • test/java/ai/openclaw/app/ui/chat

Original file line numberDiff line numberDiff line change

@@ -13,7 +13,7 @@ import kotlin.math.max

1313

import kotlin.math.roundToInt

1414
1515

private const val CHAT_ATTACHMENT_MAX_WIDTH = 1600

16-

private const val CHAT_ATTACHMENT_MAX_BASE64_CHARS = 300 * 1024

16+

internal const val CHAT_IMAGE_MAX_BASE64_CHARS = 300 * 1024

1717

private const val CHAT_ATTACHMENT_START_QUALITY = 85

1818

private const val CHAT_DECODE_MAX_DIMENSION = 1600

1919

private const val CHAT_IMAGE_CACHE_BYTES = 16 * 1024 * 1024

@@ -35,7 +35,7 @@ internal fun loadSizedImageAttachment(

3535

if (bitmap == null) {

3636

throw IllegalStateException("unsupported attachment")

3737

}

38-

val maxBytes = (CHAT_ATTACHMENT_MAX_BASE64_CHARS / 4) * 3

38+

val maxBytes = (CHAT_IMAGE_MAX_BASE64_CHARS / 4) * 3

3939

val encoded =

4040

JpegSizeLimiter.compressToLimit(

4141

initialWidth = bitmap.width,

Original file line numberDiff line numberDiff line change

@@ -79,6 +79,7 @@ import org.commonmark.node.Image as MarkdownImage

7979

import org.commonmark.node.Text as MarkdownTextNode

8080
8181

private const val LIST_INDENT_DP = 14

82+

private const val DATA_IMAGE_HEADER_MAX_CHARS = 64

8283

private val dataImageRegex = Regex("^data:image/([a-zA-Z0-9+.-]+);base64,([A-Za-z0-9+/=\\n\\r]+)$")

8384
8485

private val markdownParser: Parser by lazy {

@@ -606,9 +607,10 @@ private fun standaloneDataImage(paragraph: Paragraph): ParsedDataImage? {

606607

return parseDataImageDestination(only.destination)

607608

}

608609
609-

private fun parseDataImageDestination(destination: String?): ParsedDataImage? {

610+

internal fun parseDataImageDestination(destination: String?): ParsedDataImage? {

610611

val raw = destination?.trim().orEmpty()

611612

if (raw.isEmpty()) return null

613+

if (raw.length > CHAT_IMAGE_MAX_BASE64_CHARS + DATA_IMAGE_HEADER_MAX_CHARS) return null

612614

val match = dataImageRegex.matchEntire(raw) ?: return null

613615

val subtype =

614616

match.groupValues

@@ -623,6 +625,7 @@ private fun parseDataImageDestination(destination: String?): ParsedDataImage? {

623625

?.trim()

624626

.orEmpty()

625627

if (base64.isEmpty()) return null

628+

if (base64.length > CHAT_IMAGE_MAX_BASE64_CHARS) return null

626629

return ParsedDataImage(mimeType = "image/$subtype", base64 = base64)

627630

}

628631

@@ -650,7 +653,7 @@ private data class TableRenderRow(

650653

val cells: List<AnnotatedString>,

651654

)

652655
653-

private data class ParsedDataImage(

656+

internal data class ParsedDataImage(

654657

val mimeType: String,

655658

val base64: String,

656659

)

Original file line numberDiff line numberDiff line change

@@ -2,6 +2,7 @@ package ai.openclaw.app.ui.chat

22
33

import androidx.compose.ui.text.LinkAnnotation

44

import org.junit.Assert.assertEquals

5+

import org.junit.Assert.assertNull

56

import org.junit.Assert.assertTrue

67

import org.junit.Test

78

@@ -39,4 +40,20 @@ class ChatMarkdownTest {

3940

assertEquals("No link here", annotated.text)

4041

assertTrue(annotated.getLinkAnnotations(0, annotated.length).isEmpty())

4142

}

43+
44+

@Test

45+

fun parseDataImageDestinationAcceptsBoundedPayloads() {

46+

val parsed = parseDataImageDestination("data:image/png;base64,QUJD")

47+
48+

assertEquals(ParsedDataImage(mimeType = "image/png", base64 = "QUJD"), parsed)

49+

}

50+
51+

@Test

52+

fun parseDataImageDestinationRejectsOversizedPayloads() {

53+

val oversized = "A".repeat(CHAT_IMAGE_MAX_BASE64_CHARS + 1)

54+
55+

val parsed = parseDataImageDestination("data:image/png;base64,$oversized")

56+
57+

assertNull(parsed)

58+

}

4259

}