AmendHub

jcs

/

subtext

/

amendments

/

132

session: Fix newline handling in session_field_input

We may only get \r, but we need to send \r\n and add it to the buffer
as well.

jcs made amendment 132 5 months ago
--- session.c Tue Jun 7 22:09:22 2022 +++ session.c Wed Jun 8 21:55:55 2022 @@ -647,11 +647,8 @@ session_field_input(struct session *session, unsigned break; case '\r': case '\n': - if (multiline) { - if (c == '\r') - c = '\n'; + if (multiline) goto append_char; - } return field; case KEY_RIGHT: if (ipos == ilen) @@ -663,7 +660,7 @@ session_field_input(struct session *session, unsigned break; default: append_char: - if ((c < 32 || c > 127) && (c != '\n')) + if ((c < 32 || c > 127) && (c != '\r' && c != '\n')) break; if (ilen >= size - 1) break; @@ -689,6 +686,12 @@ append_char: ansi(session, ANSI_RESTORE_SAVED_CURSOR, ANSI_END)); } } + + if (chc == '\r') { + c = '\n'; + goto append_char; + } + session_flush(session); } }