diff --git a/core/src/avm1.rs b/core/src/avm1.rs index ce6842b36..0c5e0c080 100644 --- a/core/src/avm1.rs +++ b/core/src/avm1.rs @@ -13,6 +13,7 @@ mod globals; pub mod movie_clip; pub mod object; mod value; +mod fscommand; pub use value::Value; @@ -676,6 +677,10 @@ impl<'gc> Avm1<'gc> { return Ok(()); } + if let Some(fscommand) = fscommand::parse(url) { + return fscommand::handle(fscommand, self, context); + } + context .navigator .navigate_to_url(url.to_owned(), Some(target.to_owned()), None); diff --git a/core/src/avm1/fscommand.rs b/core/src/avm1/fscommand.rs new file mode 100644 index 000000000..5351e63e7 --- /dev/null +++ b/core/src/avm1/fscommand.rs @@ -0,0 +1,20 @@ +//! FSCommand handling + +use crate::avm1::{Avm1, ActionContext, Error}; + +/// Parse an FSCommand URL. +pub fn parse(url: &str) -> Option<&str> { + if url.starts_with("fscommand:") { + Some(&url["fscommand:".len()..]) + } else { + None + } +} + +/// TODO: FSCommand URL handling +pub fn handle(fscommand: &str, _avm: &mut Avm1, _ac: &mut ActionContext) -> Result<(), Error> { + log::warn!("Unhandled FSCommand: {}", fscommand); + + //This should be an error. + Ok(()) +} \ No newline at end of file diff --git a/core/src/avm1/globals.rs b/core/src/avm1/globals.rs index c9be15ca0..4615a08a2 100644 --- a/core/src/avm1/globals.rs +++ b/core/src/avm1/globals.rs @@ -1,11 +1,12 @@ use crate::avm1::{ActionContext, Avm1, Object, Value}; +use crate::avm1::fscommand; use crate::backend::navigator::NavigationMethod; use gc_arena::{GcCell, MutationContext}; use rand::Rng; mod math; -#[allow(non_snake_case)] +#[allow(non_snake_case, unused_must_use)] //can't use errors yet pub fn getURL<'a, 'gc>( avm: &mut Avm1<'gc>, context: &mut ActionContext<'a, 'gc, '_>, @@ -15,6 +16,11 @@ pub fn getURL<'a, 'gc>( //TODO: Error behavior if no arguments are present if let Some(url_val) = args.get(0) { let url = url_val.clone().into_string(); + if let Some(fscommand) = fscommand::parse(&url) { + fscommand::handle(fscommand, avm, context); + return Value::Undefined; + } + let window = args.get(1).map(|v| v.clone().into_string()); let method = match args.get(2) { Some(Value::String(s)) if s == "GET" => Some(NavigationMethod::GET),