mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-06-27 19:31:46 +00:00
Wayland: Pass valid UTF-8 as title
When stripping CSI sequences from the title, dont mutilate interleaved multi-byte UTF-8 sequences. Fixes #8067
This commit is contained in:
parent
e625f0aa02
commit
ebb733bad0
2 changed files with 12 additions and 3 deletions
|
|
@ -95,6 +95,8 @@ Detailed list of changes
|
|||
|
||||
- clipboard kitten: Fix a bug causing kitten to hang in filter mode when input data size is not divisible by 3 and larger than 8KB (:iss:`8059`)
|
||||
|
||||
- Wayland: Fix an abort when a client program tries to set an invalid title containing interleaved escape codes and UTF-8 multi-byte characters (:iss:`8067`)
|
||||
|
||||
0.37.0 [2024-10-30]
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
|
|
|||
13
kitty/glfw.c
13
kitty/glfw.c
|
|
@ -8,6 +8,7 @@
|
|||
#include "cleanup.h"
|
||||
#include "monotonic.h"
|
||||
#include "charsets.h"
|
||||
#include "control-codes.h"
|
||||
#include <structmember.h>
|
||||
#include "glfw-wrapper.h"
|
||||
#include "gl.h"
|
||||
|
|
@ -71,7 +72,7 @@ strip_csi_(const char *title, char *buf, size_t bufsz) {
|
|||
*dest = 0; *last = 0;
|
||||
|
||||
for (; *title && dest < last; title++) {
|
||||
const char ch = *title;
|
||||
const unsigned char ch = *title;
|
||||
switch (state) {
|
||||
case NORMAL: {
|
||||
if (ch == 0x1b) { state = IN_ESC; }
|
||||
|
|
@ -79,10 +80,16 @@ strip_csi_(const char *title, char *buf, size_t bufsz) {
|
|||
} break;
|
||||
case IN_ESC: {
|
||||
if (ch == '[') { state = IN_CSI; }
|
||||
else { state = NORMAL; }
|
||||
else {
|
||||
if (ch >= ' ' && ch != DEL) *(dest++) = ch;
|
||||
state = NORMAL;
|
||||
}
|
||||
} break;
|
||||
case IN_CSI: {
|
||||
if (!(('0' <= ch && ch <= '9') || ch == ';' || ch == ':')) state = NORMAL;
|
||||
if (!(('0' <= ch && ch <= '9') || ch == ';' || ch == ':')) {
|
||||
if (ch >= ' ' && ch != DEL) *(dest++) = ch;
|
||||
state = NORMAL;
|
||||
}
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue