mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-10 01:29:05 -04:00
accept NULs in is_control_egc(), fixing notcurses-input
This commit is contained in:
parent
490c89f694
commit
6ba67a6f21
@ -1201,7 +1201,6 @@ namespace ncpp
|
||||
return nccell_extract (plane, cell, stylemask, channels);
|
||||
}
|
||||
|
||||
// FIXME these can except if fed a sprixel, right (returns NULL)?
|
||||
const char* get_extended_gcluster (Cell &cell) const noexcept
|
||||
{
|
||||
return nccell_extended_gcluster (plane, cell);
|
||||
|
@ -1474,11 +1474,12 @@ plane_blit_sixel(sprixel* spx, char* s, int bytes, int leny, int lenx,
|
||||
return 0;
|
||||
}
|
||||
|
||||
// is it a control character? check C0 and C1, but don't count empty strings.
|
||||
// is it a control character? check C0 and C1, but don't count empty strings,
|
||||
// nor single-byte strings containing only a NUL character.
|
||||
static inline bool
|
||||
is_control_egc(const unsigned char* egc, int bytes){
|
||||
if(bytes == 1){
|
||||
if(iscntrl(*egc)){
|
||||
if(*egc && iscntrl(*egc)){
|
||||
return true;
|
||||
}
|
||||
}else if(bytes == 2){
|
||||
|
@ -1547,13 +1547,13 @@ ncplane_put(ncplane* n, int y, int x, const char* egc, int cols,
|
||||
return -1;
|
||||
}
|
||||
// reject any control character for output other than newline (and then only
|
||||
// on a scrolling plane). this also rejects any 0-length EGC.
|
||||
// on a scrolling plane).
|
||||
if(*egc == '\n'){
|
||||
if(!n->scrolling){
|
||||
logerror("Rejecting newline on non-scrolling plane\n");
|
||||
return -1;
|
||||
}
|
||||
}else if(bytes == 0 || is_control_egc((const unsigned char*)egc, bytes)){
|
||||
}else if(is_control_egc((const unsigned char*)egc, bytes)){
|
||||
logerror("Rejecting %dB control character\n", bytes);
|
||||
return -1;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user