Skip to content

Commit 37b539f

Browse files
committed
FIX: use of escape char ^ must not be allowed in unquoted file notation
resolves: Oldes/Rebol-issues#1442
1 parent 986f87b commit 37b539f

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

src/core/l-scan.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,9 @@
593593

594594
// Accept ^X encoded char:
595595
else if (c == '^') {
596-
if (src+1 == end) return 0; // nothing follows ^
596+
// checks also if not used in file like: %a^b which must be invalid!
597+
if (src+1 == end || (invalid && strchr(cs_cast(invalid), c)))
598+
return 0; // nothing follows ^ or used in unquoted file
597599
c = Scan_Char(&src);
598600
if (!term && IS_WHITE(c)) break;
599601
src--;

src/core/l-types.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ bad_hex: Trap0(RE_INVALID_CHARS);
648648
***********************************************************************/
649649
{
650650
REBUNI term = 0;
651-
const REBYTE *invalid = cb_cast(":;()[]\"");
651+
const REBYTE *invalid = cb_cast(":;()[]\"^");
652652

653653
if (*cp == '%') cp++, len--;
654654
if (*cp == '"') {

src/tests/units/lexer-test.r3

+3
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ Rebol [
8282
--test-- "Invalid file"
8383
;@@ https://github.com/Oldes/Rebol-issues/issues/1415
8484
--assert all [error? e: try [load {%^^}] e/id = 'invalid]
85+
;@@ https://github.com/Oldes/Rebol-issues/issues/1442
86+
--assert all [error? e: try [load {%a^^b}] e/id = 'invalid]
87+
--assert all [error? e: try [load {%a^^ }] e/id = 'invalid]
8588

8689
===end-group===
8790

src/tests/units/mold-test.r3

+3
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,9 @@ Rebol [
213213
]
214214
;@@ https://github.com/Oldes/Rebol-issues/issues/1415
215215
--assert "%%5E" == mold to-file "^^"
216+
;@@ https://github.com/Oldes/Rebol-issues/issues/1442
217+
--assert "%a%02c" == mold to-file "a^Bc"
218+
--assert "%a%20b" == mold to-file "a^ b"
216219

217220
===end-group===
218221

0 commit comments

Comments
 (0)