Fossil SCM

Improvements to escaping of filenames that are passed down into subprocesses on Windows.

drh 2024-02-22 20:07 trunk
Commit fc0b9325f02b16b3832e37365e2d9e66ab373663d168c05e72c6aa92a508f68a
1 file changed +3 -1
+3 -1
--- src/blob.c
+++ src/blob.c
@@ -1575,11 +1575,11 @@
15751575
** 5 First byte of a 4-byte UTF-8
15761576
*/
15771577
static const char aSafeChar[256] = {
15781578
#ifdef _WIN32
15791579
/* Windows
1580
-** Prohibit: all control characters, including tab, \r and \n
1580
+** Prohibit: all control characters, including tab, \r and \n. Also %
15811581
** Escape: (space) " # $ % & ' ( ) * ; < > ? [ ] ^ ` { | }
15821582
*/
15831583
/* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xa xb xc xd xe xf */
15841584
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 0x */
15851585
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 1x */
@@ -1700,10 +1700,12 @@
17001700
blob_append_char(pBlob, '.');
17011701
}
17021702
for(i=0; (c = (unsigned char)zIn[i])!=0; i++){
17031703
blob_append_char(pBlob, (char)c);
17041704
if( c=='"' ) blob_append_char(pBlob, '"');
1705
+ if( c=='\\' ) blob_append_char(pBlob, '\\');
1706
+ if( c=='%' ) blob_append(pBlob, "%cd:~,%", 7);
17051707
}
17061708
blob_append_char(pBlob, '"');
17071709
#else
17081710
/* Quoting strategy for unix:
17091711
** If the name does not contain ', then surround the whole thing
17101712
--- src/blob.c
+++ src/blob.c
@@ -1575,11 +1575,11 @@
1575 ** 5 First byte of a 4-byte UTF-8
1576 */
1577 static const char aSafeChar[256] = {
1578 #ifdef _WIN32
1579 /* Windows
1580 ** Prohibit: all control characters, including tab, \r and \n
1581 ** Escape: (space) " # $ % & ' ( ) * ; < > ? [ ] ^ ` { | }
1582 */
1583 /* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xa xb xc xd xe xf */
1584 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 0x */
1585 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 1x */
@@ -1700,10 +1700,12 @@
1700 blob_append_char(pBlob, '.');
1701 }
1702 for(i=0; (c = (unsigned char)zIn[i])!=0; i++){
1703 blob_append_char(pBlob, (char)c);
1704 if( c=='"' ) blob_append_char(pBlob, '"');
 
 
1705 }
1706 blob_append_char(pBlob, '"');
1707 #else
1708 /* Quoting strategy for unix:
1709 ** If the name does not contain ', then surround the whole thing
1710
--- src/blob.c
+++ src/blob.c
@@ -1575,11 +1575,11 @@
1575 ** 5 First byte of a 4-byte UTF-8
1576 */
1577 static const char aSafeChar[256] = {
1578 #ifdef _WIN32
1579 /* Windows
1580 ** Prohibit: all control characters, including tab, \r and \n. Also %
1581 ** Escape: (space) " # $ % & ' ( ) * ; < > ? [ ] ^ ` { | }
1582 */
1583 /* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xa xb xc xd xe xf */
1584 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 0x */
1585 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 1x */
@@ -1700,10 +1700,12 @@
1700 blob_append_char(pBlob, '.');
1701 }
1702 for(i=0; (c = (unsigned char)zIn[i])!=0; i++){
1703 blob_append_char(pBlob, (char)c);
1704 if( c=='"' ) blob_append_char(pBlob, '"');
1705 if( c=='\\' ) blob_append_char(pBlob, '\\');
1706 if( c=='%' ) blob_append(pBlob, "%cd:~,%", 7);
1707 }
1708 blob_append_char(pBlob, '"');
1709 #else
1710 /* Quoting strategy for unix:
1711 ** If the name does not contain ', then surround the whole thing
1712

Keyboard Shortcuts

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