Skip to content

Commit

Permalink
FIX: Length-specified script embedding
Browse files Browse the repository at this point in the history
  • Loading branch information
Oldes committed Nov 12, 2021
1 parent 5ae4871 commit 067fee5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/mezz/sys-load.reb
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,9 @@ load: function [

;-- Try to load the header, handle error:
not all [
set [hdr: data:] either object? data [load-ext-module data] [load-header data]
set [hdr: data: end:] either object? data [load-ext-module data] [load-header data]
if word? hdr [cause-error 'syntax hdr source]
unless tail? end [data: copy/part data end]
]
; data is binary or block now, hdr is object or none

Expand Down Expand Up @@ -537,7 +538,8 @@ load-module: function [
; Get and process the header
not hdr [
; Only happens for string, binary or non-extension file/url source
set [hdr: code:] load-header/required data
set [hdr: code: end:] load-header/required data
unless tail? end [code: copy/part code end]
case [
word? hdr [cause-error 'syntax hdr source]
import none ; /import overrides 'delay option
Expand Down
9 changes: 8 additions & 1 deletion src/tests/units/load-test.r3
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ Rebol [
--assert block? b: load ["print 'hello" "print 'there"]
--assert [print 'hello] = b/1
--assert [print 'there] = b/2

--test-- "Length-specified script embedding"
;@@ https://github.com/Oldes/Rebol-issues/issues/1941
--assert [print "hello"] = load {rebol [length: 14] print "hello" other stuff}
--assert 1 = try [do {rebol [length: 2] 1 other stuff}]
--assert [lib-local a] = words-of import {rebol [length: 5] a: 1 b: 2 print "evil code"}
--assert [lib-local a] = words-of import/check {rebol [length: 5 checksum: #{E9A16FDEC8FF093599E2AA10C30D2D98D1C541C5}] a: 1 b: 2 print "evil code"} #{E9A16FDEC8FF093599E2AA10C30D2D98D1C541C5}

--test-- "issue-858"
;@@ https://github.com/Oldes/Rebol-issues/issues/858
--assert [<] = load mold [ < ]
Expand All @@ -78,7 +86,6 @@ Rebol [

===end-group===


===start-group=== "find-script native"
--test-- "find-script"
;@@ https://github.com/Oldes/Rebol-issues/issues/182
Expand Down

0 comments on commit 067fee5

Please sign in to comment.