Skip to content

Commit

Permalink
Trim trailing NULL character in Extended Clipboard encoding
Browse files Browse the repository at this point in the history
LibVNCClient doesn't seem to do this automatically.
Also added a invalid clip text.

Re: #284
  • Loading branch information
gujjwal00 committed Jan 11, 2025
1 parent 480842f commit 7025b9c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/src/main/cpp/native-vnc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ static void onBell(rfbClient *client) {
}

static void onGotXCutText(rfbClient *client, const char *text, int len, bool is_utf8) {
if (!text || len <= 0) return;

auto obj = getManagedClient(client);
auto env = context.getEnv();
auto cls = context.managedCls;
Expand All @@ -162,6 +164,8 @@ static void onGotXCutTextLatin1(rfbClient *client, const char *text, int len) {
}

static void onGotXCutTextUTF8(rfbClient *client, const char *text, int len) {
if (text && len > 0 && text[len - 1] == '\0')
--len; // LibVNCClient includes terminating NULL in length for UTF8
onGotXCutText(client, text, len, true);
}

Expand Down

0 comments on commit 7025b9c

Please sign in to comment.