Fossil SCM

Fix the backslash-octal escapes on the filename quoting while importing from git.

drh 2015-11-29 17:33 trunk
Commit 09cf1ad8eecf502c225ff5711e50fe865f3ef920
1 file changed +14 -1
+14 -1
--- src/import.c
+++ src/import.c
@@ -463,11 +463,24 @@
463463
if( zName==0 || zName[0]!='"' ) return;
464464
n = (int)strlen(zName);
465465
if( zName[n-1]!='"' ) return;
466466
for(i=0, j=1; j<n-1; j++){
467467
char c = zName[j];
468
- if( c=='\\' ) c = zName[++j];
468
+ int x;
469
+ if( c=='\\' ){
470
+ if( j+3 <= n-1
471
+ && zName[j+1]>='0' && zName[j+1]<='3'
472
+ && zName[j+2]>='0' && zName[j+2]<='7'
473
+ && zName[j+3]>='0' && zName[j+3]<='7'
474
+ && (x = 64*(zName[j+1]-'0') + 8*(zName[j+2]-'0') + zName[j+3]-'0')!=0
475
+ ){
476
+ c = (unsigned char)x;
477
+ j += 3;
478
+ }else{
479
+ c = zName[++j];
480
+ }
481
+ }
469482
zName[i++] = c;
470483
}
471484
zName[i] = 0;
472485
}
473486
474487
--- src/import.c
+++ src/import.c
@@ -463,11 +463,24 @@
463 if( zName==0 || zName[0]!='"' ) return;
464 n = (int)strlen(zName);
465 if( zName[n-1]!='"' ) return;
466 for(i=0, j=1; j<n-1; j++){
467 char c = zName[j];
468 if( c=='\\' ) c = zName[++j];
 
 
 
 
 
 
 
 
 
 
 
 
 
469 zName[i++] = c;
470 }
471 zName[i] = 0;
472 }
473
474
--- src/import.c
+++ src/import.c
@@ -463,11 +463,24 @@
463 if( zName==0 || zName[0]!='"' ) return;
464 n = (int)strlen(zName);
465 if( zName[n-1]!='"' ) return;
466 for(i=0, j=1; j<n-1; j++){
467 char c = zName[j];
468 int x;
469 if( c=='\\' ){
470 if( j+3 <= n-1
471 && zName[j+1]>='0' && zName[j+1]<='3'
472 && zName[j+2]>='0' && zName[j+2]<='7'
473 && zName[j+3]>='0' && zName[j+3]<='7'
474 && (x = 64*(zName[j+1]-'0') + 8*(zName[j+2]-'0') + zName[j+3]-'0')!=0
475 ){
476 c = (unsigned char)x;
477 j += 3;
478 }else{
479 c = zName[++j];
480 }
481 }
482 zName[i++] = c;
483 }
484 zName[i] = 0;
485 }
486
487

Keyboard Shortcuts

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