Add a check for `fscommand:` URLs
This commit is contained in:
parent
c2eb96eed0
commit
b61f264ac7
|
@ -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);
|
||||
|
|
|
@ -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(())
|
||||
}
|
|
@ -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),
|
||||
|
|
Loading…
Reference in New Issue