From f6e7ecb61ac69d15d1f2b2fbb315c4f5afeb4de1 Mon Sep 17 00:00:00 2001 From: amr Date: Sun, 22 Feb 2026 02:44:48 +0200 Subject: [PATCH 1/2] fix(string): ensure separator is an object before calling Symbol.split --- core/engine/src/builtins/string/mod.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/core/engine/src/builtins/string/mod.rs b/core/engine/src/builtins/string/mod.rs index b166085003e..e2ce2b4ce40 100644 --- a/core/engine/src/builtins/string/mod.rs +++ b/core/engine/src/builtins/string/mod.rs @@ -1915,12 +1915,14 @@ impl String { // 2. If separator is neither undefined nor null, then if !separator.is_null_or_undefined() { - // a. Let splitter be ? GetMethod(separator, @@split). - let splitter = separator.get_method(JsSymbol::split(), context)?; - // b. If splitter is not undefined, then - if let Some(splitter) = splitter { - // i. Return ? Call(splitter, separator, « O, limit »). - return splitter.call(separator, &[this.clone(), limit.clone()], context); + if let Some(separator_obj) = separator.as_object() { + // a. Let splitter be ? GetMethod(separator, @@split). + let splitter = separator_obj.get_method(JsSymbol::split(), context)?; + // b. If splitter is not undefined, then + if let Some(splitter) = splitter { + // i. Return ? Call(splitter, separator, « O, limit »). + return splitter.call(separator, &[this.clone(), limit.clone()], context); + } } } From 859149c9f5a6a368ae4dcf81555d67e10aa3c398 Mon Sep 17 00:00:00 2001 From: amr Date: Sun, 22 Feb 2026 09:41:11 +0200 Subject: [PATCH 2/2] fix(string): ensure separator is an object before calling Symbol.split --- core/engine/src/builtins/string/mod.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/engine/src/builtins/string/mod.rs b/core/engine/src/builtins/string/mod.rs index e2ce2b4ce40..3d1647e3e21 100644 --- a/core/engine/src/builtins/string/mod.rs +++ b/core/engine/src/builtins/string/mod.rs @@ -1470,6 +1470,7 @@ impl String { // 2. If regexp is neither undefined nor null, then let regexp = args.get_or_undefined(0); if !regexp.is_null_or_undefined() { + if regexp.is_object() { // a. Let matcher be ? GetMethod(regexp, @@match). let matcher = regexp.get_method(JsSymbol::r#match(), context)?; // b. If matcher is not undefined, then @@ -1478,7 +1479,7 @@ impl String { return matcher.call(regexp, std::slice::from_ref(o), context); } } - + } // 3. Let S be ? ToString(O). let s = o.to_string(context)?; @@ -2055,6 +2056,7 @@ impl String { // 2. If regexp is neither undefined nor null, then let regexp = args.get_or_undefined(0); if !regexp.is_null_or_undefined() { + if regexp.is_object() { // a. Let isRegExp be ? IsRegExp(regexp). // b. If isRegExp is true, then if let Some(regexp) = RegExp::is_reg_exp(regexp, context)? { @@ -2080,6 +2082,7 @@ impl String { return matcher.call(regexp, std::slice::from_ref(o), context); } } + } // 3. Let S be ? ToString(O). let s = o.to_string(context)?; @@ -2197,6 +2200,7 @@ impl String { // 2. If regexp is neither undefined nor null, then let regexp = args.get_or_undefined(0); if !regexp.is_null_or_undefined() { + if regexp.is_object() { // a. Let searcher be ? GetMethod(regexp, @@search). let searcher = regexp.get_method(JsSymbol::search(), context)?; // b. If searcher is not undefined, then @@ -2205,6 +2209,7 @@ impl String { return searcher.call(regexp, std::slice::from_ref(o), context); } } + } // 3. Let string be ? ToString(O). let string = o.to_string(context)?;