Handle invalid UTF-8 reported cmdline more gracefully

This commit is contained in:
Kovid Goyal 2024-05-11 08:34:05 +05:30
parent c17d7614e1
commit dc410fa0c7
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C

View file

@ -2343,7 +2343,9 @@ shell_prompt_marking(Screen *self, char *buf) {
if (strstr(buf + 1, ";cmdline") == buf + 1) {
cmdline = buf + 2;
}
CALLBACK("cmd_output_marking", "Os", Py_True, cmdline);
RAII_PyObject(c, PyUnicode_DecodeUTF8(cmdline, strlen(cmdline), "replace"));
if (c) { CALLBACK("cmd_output_marking", "OO", Py_True, c); }
else PyErr_Print();
} break;
case 'D': {
const char *exit_status = buf[1] == ';' ? buf + 2 : "";