mirror of
https://github.com/rustdesk/rustdesk
synced 2026-04-21 13:27:19 +00:00
fix: clear utf8 remainder on base64 failure and allow malformed decode
Address CodeRabbit review feedback: - Clear _utf8Remainder when base64 decode fails to prevent stale bytes from corrupting subsequent chunks - Add allowMalformed: true to utf8.decode() so malformed bytes become U+FFFD instead of throwing FormatException and losing the entire chunk Signed-off-by: wo0d <fengz181x@gmail.com> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
c48aec914b
commit
b187756428
1 changed files with 2 additions and 1 deletions
|
|
@ -342,6 +342,7 @@ class TerminalModel with ChangeNotifier {
|
|||
bytes = base64Decode(data);
|
||||
} catch (e) {
|
||||
// If base64 decode fails, treat as plain text
|
||||
_utf8Remainder.clear();
|
||||
_writeToTerminal(data);
|
||||
return;
|
||||
}
|
||||
|
|
@ -365,7 +366,7 @@ class TerminalModel with ChangeNotifier {
|
|||
}
|
||||
|
||||
if (split > 0) {
|
||||
final text = utf8.decode(bytes.sublist(0, split));
|
||||
final text = utf8.decode(bytes.sublist(0, split), allowMalformed: true);
|
||||
_writeToTerminal(text);
|
||||
}
|
||||
} catch (e) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue