Skip to content

Commit de73f73

Browse files
committed
FIX: crash when resolving file name containing a colon char on Posix systems
resolves: Oldes/Rebol-issues#2538
1 parent ee7ff8e commit de73f73

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/core/s-file.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
for (i = 0; i < len;) {
6868
c = uni ? ((REBUNI*)bp)[i] : ((REBYTE*)bp)[i];
6969
i++;
70+
#ifdef TO_WINDOWS
7071
if (c == ':') {
7172
// Handle the vol:dir/file format:
7273
if (colon || slash) return 0; // no prior : or / allowed
@@ -77,7 +78,9 @@
7778
}
7879
c = '/'; // replace : with a /
7980
}
80-
else if (c == '\\' || c== '/') {
81+
else
82+
#endif
83+
if (c == '\\' || c== '/') {
8184
if (slash > 0) continue;
8285
c = '/';
8386
slash = 1;

src/tests/units/file-test.r3

+11
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,17 @@ secure [%/ allow]
6161
--assert %/rodan/shareddocs = to-rebol-file "\\rodan\shareddocs"
6262
--assert %/rodan/shareddocs/ = to-rebol-file "\\rodan\shareddocs\"
6363

64+
if find [Linux macOS] system/platform [
65+
--test-- "issue-2538"
66+
;@@ https://github.com/Oldes/Rebol-issues/issues/2538
67+
cd (mkdir %issue-2538)
68+
call/shell/wait "touch a:0:0"
69+
--assert %a%3A0%3A0 == f: first read %.
70+
--assert %a%3A0%3A0 == second split-path query/mode f 'name
71+
delete f
72+
cd ..
73+
]
74+
6475
===end-group===
6576

6677
===start-group=== "suffix?"

0 commit comments

Comments
 (0)