Skip to content

GUACAMOLE-2237: Server-side terminal multiline paste fix.#658

Open
bbennett-ks wants to merge 1 commit into
apache:staging/1.6.1from
bbennett-ks:GUACAMOLE-2237-Multiline-Paste-improvements
Open

GUACAMOLE-2237: Server-side terminal multiline paste fix.#658
bbennett-ks wants to merge 1 commit into
apache:staging/1.6.1from
bbennett-ks:GUACAMOLE-2237-Multiline-Paste-improvements

Conversation

@bbennett-ks
Copy link
Copy Markdown
Contributor

@bbennett-ks bbennett-ks commented Apr 14, 2026

For terminal-based protocols, pasted terminal contents are now normalized on the server before being written to stdin: line endings are converted so \n and \r\n become \r. This applies to both terminal paste shortcuts (Ctrl+Shift+V & Cmd+V) as well as for mouse click (middle & right). Doing this server-side is required because these paths ultimately paste from the terminal’s server-side clipboard buffer & mouse paste in particular does not give the client an normalize at paste time.

This does not change clipboard synchronization itself: Clipboard contents are still stored and exchanged as before, only the terminal-emulator paste path is normalized immediately before pasting.

Similar client-side changes are under review: GUACAMOLE-2237 (client 1201). Both sets of changes are independent, addressing different core issues.

Unit Tests

Added the following unit tests:

PASS: test_terminal 1 - [selection_point] enclose_text: OK
PASS: test_terminal 2 - [selection_point] enclose_wide_text: OK
PASS: test_terminal 3 - [selection_point] is_point_after: OK
PASS: test_terminal 4 - [selection_point] rounding: OK
PASS: test_terminal 5 - [selection_point] rounding_wide: OK
PASS: test_terminal 6 - [paste] lf_to_cr: OK                 New!
PASS: test_terminal 7 - [paste] crlf_to_single_cr: OK        New!
PASS: test_terminal 8 - [paste] bare_cr_passthrough: OK      New!
PASS: test_terminal 9 - [paste] mixed_endings: OK            New!
PASS: test_terminal 10 - [paste] consecutive_endings: OK     New!
PASS: test_terminal 11 - [paste] trailing_cr: OK             New!
PASS: test_terminal 12 - [paste] no_endings: OK              New!
PASS: test_terminal 13 - [paste] empty: OK                   New!
PASS: test_terminal 14 - [paste] embedded_nul: OK            New!
============================================================================
Testsuite summary for guacamole-server 1.6.1
============================================================================

Manual Tests

Copying the following (Linux/Chrome Browser):
image

  • Via Ctrl+V/Click/Right Click
  • Via Browser Paste Menu
image

@mike-jumper
Copy link
Copy Markdown
Contributor

Doesn't the terminal emulator already normalize line endings in the server-side clipboard via:

/* Convert clipboard contents */
guac_iconv(GUAC_READ_UTF8_NORMALIZED, &data, length,
GUAC_WRITE_UTF8, &output, output_buf_size);

?

@bbennett-ks bbennett-ks force-pushed the GUACAMOLE-2237-Multiline-Paste-improvements branch from d10733e to 3e71efc Compare April 15, 2026 15:42
@bbennett-ks
Copy link
Copy Markdown
Contributor Author

Doesn't the terminal emulator already normalize line endings in the server-side clipboard via:

/* Convert clipboard contents */
guac_iconv(GUAC_READ_UTF8_NORMALIZED, &data, length,
GUAC_WRITE_UTF8, &output, output_buf_size);

Yeah, this are is confusing. I updated the function header to clarify. We normalize to LF when we ingest clipboard data and we (re)normalize to CR when sending to keyboard as LF isn't universally treated (e.g. Windows) as the Enter key.

@bbennett-ks bbennett-ks force-pushed the GUACAMOLE-2237-Multiline-Paste-improvements branch from 3e71efc to 8b40d39 Compare May 27, 2026 04:37
Comment thread src/terminal/terminal.c Outdated
@bbennett-ks bbennett-ks force-pushed the GUACAMOLE-2237-Multiline-Paste-improvements branch from 8b40d39 to acc7998 Compare June 1, 2026 14:26
Copy link
Copy Markdown
Contributor

@necouchman necouchman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. @mike-jumper Any further concerns?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants