Fossil SCM

Oops, make it work correct now.

jan.nijtmans 2013-01-21 13:12 UTC disallow-invalid-utf8-in-filenames
Commit 7dabede3b38835601315188dd2cd2d530200f38f
1 file changed +3 -3
+3 -3
--- src/file.c
+++ src/file.c
@@ -517,11 +517,11 @@
517517
* Windows XP and earlier cannot handle them.
518518
*/
519519
return 0;
520520
}
521521
/* This is a 3-byte UTF-8 character */
522
- unicode = ((c&0x0f)<<12) + ((c&0x3f)<<6) + (c&0x3f);
522
+ unicode = ((c&0x0f)<<12) + ((z[i+1]&0x3f)<<6) + (z[i+2]&0x3f);
523523
if( unicode <= 0x07ff ){
524524
/* overlong form */
525525
return 0;
526526
}else if( unicode>=0xe000 ){
527527
/* U+E000..U+FFFF */
@@ -537,17 +537,17 @@
537537
/* U+D800..U+DFFF are for surrogate pairs. */
538538
return 0;
539539
}
540540
}
541541
do{
542
- if( (z[1]&0xc0)!=0x80 ){
542
+ if( (z[i+1]&0xc0)!=0x80 ){
543543
/* Invalid continuation byte (multi-byte UTF-8) */
544544
return 0;
545545
}
546546
/* The hi-bits of c are used to keep track of the number of expected
547547
* continuation-bytes, so we don't need a separate counter. */
548
- c<<=1; ++z;
548
+ c<<=1; ++i;
549549
}while( c>=0xc0 );
550550
}else if( c=='\\' ){
551551
return 0;
552552
}
553553
if( c=='/' ){
554554
--- src/file.c
+++ src/file.c
@@ -517,11 +517,11 @@
517 * Windows XP and earlier cannot handle them.
518 */
519 return 0;
520 }
521 /* This is a 3-byte UTF-8 character */
522 unicode = ((c&0x0f)<<12) + ((c&0x3f)<<6) + (c&0x3f);
523 if( unicode <= 0x07ff ){
524 /* overlong form */
525 return 0;
526 }else if( unicode>=0xe000 ){
527 /* U+E000..U+FFFF */
@@ -537,17 +537,17 @@
537 /* U+D800..U+DFFF are for surrogate pairs. */
538 return 0;
539 }
540 }
541 do{
542 if( (z[1]&0xc0)!=0x80 ){
543 /* Invalid continuation byte (multi-byte UTF-8) */
544 return 0;
545 }
546 /* The hi-bits of c are used to keep track of the number of expected
547 * continuation-bytes, so we don't need a separate counter. */
548 c<<=1; ++z;
549 }while( c>=0xc0 );
550 }else if( c=='\\' ){
551 return 0;
552 }
553 if( c=='/' ){
554
--- src/file.c
+++ src/file.c
@@ -517,11 +517,11 @@
517 * Windows XP and earlier cannot handle them.
518 */
519 return 0;
520 }
521 /* This is a 3-byte UTF-8 character */
522 unicode = ((c&0x0f)<<12) + ((z[i+1]&0x3f)<<6) + (z[i+2]&0x3f);
523 if( unicode <= 0x07ff ){
524 /* overlong form */
525 return 0;
526 }else if( unicode>=0xe000 ){
527 /* U+E000..U+FFFF */
@@ -537,17 +537,17 @@
537 /* U+D800..U+DFFF are for surrogate pairs. */
538 return 0;
539 }
540 }
541 do{
542 if( (z[i+1]&0xc0)!=0x80 ){
543 /* Invalid continuation byte (multi-byte UTF-8) */
544 return 0;
545 }
546 /* The hi-bits of c are used to keep track of the number of expected
547 * continuation-bytes, so we don't need a separate counter. */
548 c<<=1; ++i;
549 }while( c>=0xc0 );
550 }else if( c=='\\' ){
551 return 0;
552 }
553 if( c=='/' ){
554

Keyboard Shortcuts

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