From bfe538e7e0bb41d7e262ecc7f3f844ae6caef5a7 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 21 Dec 2025 06:08:59 +0000 Subject: [PATCH] Update string.split() to handle whitespace when no args are passed Updated the implementation of the `split` method for String values in `eldritch-core`. When `split()` is called without arguments, it now utilizes `split_whitespace()` to split by any whitespace characters (spaces, tabs, newlines) and treat consecutive whitespace as a single separator. This aligns the behavior with Python's `str.split()` and addresses the user request. Behavior when a specific delimiter is provided remains unchanged. --- .../eldritch-core/src/interpreter/methods.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/implants/lib/eldritchv2/eldritch-core/src/interpreter/methods.rs b/implants/lib/eldritchv2/eldritch-core/src/interpreter/methods.rs index 7b1ce1b62..0b0ac6d3f 100644 --- a/implants/lib/eldritchv2/eldritch-core/src/interpreter/methods.rs +++ b/implants/lib/eldritchv2/eldritch-core/src/interpreter/methods.rs @@ -353,15 +353,18 @@ pub fn call_bound_method(receiver: &Value, method: &str, args: &[Value]) -> Resu } (Value::String(s), "split") => { - let delim = if !args.is_empty() { - args[0].to_string() + let parts: Vec = if args.is_empty() { + // Default split: split by whitespace (runs of whitespace are one separator) + s.split_whitespace() + .map(|p| Value::String(p.to_string())) + .collect() } else { - " ".to_string() + // Split by specific delimiter + let delim = args[0].to_string(); + s.split(&delim) + .map(|p| Value::String(p.to_string())) + .collect() }; - let parts: Vec = s - .split(&delim) - .map(|p| Value::String(p.to_string())) - .collect(); Ok(Value::List(Arc::new(RwLock::new(parts)))) } (Value::String(s), "splitlines") => {