Fossil SCM

Fix the comment formatter so that it does not crash with ill-formatted VT100 escapes.

drh 2025-02-26 21:03 trunk
Commit 2aa79ed7521b6c6c732ccd2a95d8b320557e5732cd219fad437de5ee56fdfa3d
1 file changed +6 -4
+6 -4
--- src/comformat.c
+++ src/comformat.c
@@ -263,14 +263,16 @@
263263
int maxUTF8 = 1; /* Expected sequence length. */
264264
char c = z[i++];
265265
if( c==0x1b && z[i]=='[' ){
266266
do{
267267
i++;
268
- }while( fossil_isdigit(z[i]) || z[i]==';' );
269
- *pCchUTF8 = i+1;
270
- *pUtf32 = 0x301; /* A zero-width character */
271
- return;
268
+ }while( i<fossil_isdigit(z[i]) || z[i]==';' );
269
+ if( fossil_isalpha(z[i]) ){
270
+ *pCchUTF8 = i+1;
271
+ *pUtf32 = 0x301; /* A zero-width character */
272
+ return;
273
+ }
272274
}
273275
if( (c&0x80)==0x00 ){ /* 7-bit ASCII character. */
274276
*pCchUTF8 = 1;
275277
*pUtf32 = (int)z[0];
276278
return;
277279
--- src/comformat.c
+++ src/comformat.c
@@ -263,14 +263,16 @@
263 int maxUTF8 = 1; /* Expected sequence length. */
264 char c = z[i++];
265 if( c==0x1b && z[i]=='[' ){
266 do{
267 i++;
268 }while( fossil_isdigit(z[i]) || z[i]==';' );
269 *pCchUTF8 = i+1;
270 *pUtf32 = 0x301; /* A zero-width character */
271 return;
 
 
272 }
273 if( (c&0x80)==0x00 ){ /* 7-bit ASCII character. */
274 *pCchUTF8 = 1;
275 *pUtf32 = (int)z[0];
276 return;
277
--- src/comformat.c
+++ src/comformat.c
@@ -263,14 +263,16 @@
263 int maxUTF8 = 1; /* Expected sequence length. */
264 char c = z[i++];
265 if( c==0x1b && z[i]=='[' ){
266 do{
267 i++;
268 }while( i<fossil_isdigit(z[i]) || z[i]==';' );
269 if( fossil_isalpha(z[i]) ){
270 *pCchUTF8 = i+1;
271 *pUtf32 = 0x301; /* A zero-width character */
272 return;
273 }
274 }
275 if( (c&0x80)==0x00 ){ /* 7-bit ASCII character. */
276 *pCchUTF8 = 1;
277 *pUtf32 = (int)z[0];
278 return;
279

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button