Skip to content

Commit 9e1b9cf

Browse files
tokangasrlubos
authored andcommitted
applications: serial_lte_modem: Fix handling of quotes with backspace
If the character removed using backspace was a quote, the internal state of the RX handler was not updated correctly. This caused incorrect behavior when handling the following characters. Signed-off-by: Tommi Kangas <[email protected]>
1 parent 71ca697 commit 9e1b9cf

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

applications/serial_lte_modem/src/slm_at_host.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,8 +588,19 @@ static size_t cmd_rx_handler(const uint8_t *buf, const size_t len)
588588
case 0x08: /* Backspace. */
589589
/* Fall through. */
590590
case 0x7F: /* DEL character */
591+
if (at_cmd_len == 0) {
592+
continue;
593+
}
594+
595+
at_cmd_len--;
596+
/* If the removed character was a quote, need to toggle the flag. */
597+
if (prev_character == '"') {
598+
inside_quotes = !inside_quotes;
599+
}
591600
if (at_cmd_len > 0) {
592-
at_cmd_len--;
601+
prev_character = slm_at_buf[at_cmd_len - 1];
602+
} else {
603+
prev_character = '\0';
593604
}
594605
continue;
595606
}

0 commit comments

Comments
 (0)