mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 00:56:10 +00:00 
			
		
		
		
	Handle wcwidth() and mbtowc() failures in better style and drop
characters where we can't find the width (wcwidth() fails) on input, the same as we drop invalid UTF-8. Suggested by schwarze@.
This commit is contained in:
		
							
								
								
									
										10
									
								
								input.c
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								input.c
									
									
									
									
									
								
							@@ -1960,8 +1960,14 @@ input_utf8_close(struct input_ctx *ictx)
 | 
			
		||||
{
 | 
			
		||||
	struct utf8_data	*ud = &ictx->utf8data;
 | 
			
		||||
 | 
			
		||||
	if (utf8_append(ud, ictx->ch) != UTF8_DONE)
 | 
			
		||||
		fatalx("UTF-8 close invalid %#x", ictx->ch);
 | 
			
		||||
	if (utf8_append(ud, ictx->ch) != UTF8_DONE) {
 | 
			
		||||
		/*
 | 
			
		||||
		 * An error here could be invalid UTF-8 or it could be a
 | 
			
		||||
		 * nonprintable character for which we can't get the
 | 
			
		||||
		 * width. Drop it.
 | 
			
		||||
		 */
 | 
			
		||||
		return (0);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	log_debug("%s %hhu '%*s' (width %hhu)", __func__, ud->size,
 | 
			
		||||
	    (int)ud->size, ud->data, ud->width);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user