Skip to content

Commit 2fc285f

Browse files
committed
removing preceding whitespaces, tabs, and newlines for evals only
1 parent d7e1322 commit 2fc285f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

vm/src/stdlib/builtins.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,15 @@ mod builtins {
256256
));
257257
}
258258

259+
// Check for newlines, tabs, or whitespaces at start
260+
let wsp_arr = [9, 10, 32];
261+
let mut i = 0;
262+
while i < source.len() && wsp_arr.contains(&source[i]) {
263+
i = i + 1;
264+
}
265+
// Slice off whitespaces
266+
let source = &source[i..source.len()];
267+
259268
let source = std::str::from_utf8(source).map_err(|err| {
260269
let msg = format!(
261270
"(unicode error) 'utf-8' codec can't decode byte 0x{:x?} in position {}: invalid start byte",

0 commit comments

Comments
 (0)