From 78199c017782067bda94307c7bfc9dc9c1f1eefd Mon Sep 17 00:00:00 2001 From: Chris Young Date: Sat, 10 Aug 2019 14:22:52 +0100 Subject: Amiga: Allow running JS from ARexx Option arexx_allow_exec enables the EXEC command. It is disabled by default and currently undocumented. Theoretically this could be used by a form filler application. --- frontends/amiga/arexx.c | 32 +++++++++++++++++++++++++++++++- frontends/amiga/options.h | 1 + 2 files changed, 32 insertions(+), 1 deletion(-) (limited to 'frontends/amiga') diff --git a/frontends/amiga/arexx.c b/frontends/amiga/arexx.c index 05e780243..243e927f8 100644 --- a/frontends/amiga/arexx.c +++ b/frontends/amiga/arexx.c @@ -69,7 +69,8 @@ enum RX_ACTIVE, RX_CLOSE, RX_HOTLIST, - RX_SLABSTATS + RX_SLABSTATS, + RX_EXEC }; static Object *arexx_obj = NULL; @@ -98,6 +99,7 @@ RXHOOKF(rx_active); RXHOOKF(rx_close); RXHOOKF(rx_hotlist); RXHOOKF(rx_slabstats); +RXHOOKF(rx_exec); STATIC struct ARexxCmd Commands[] = { @@ -118,6 +120,7 @@ STATIC struct ARexxCmd Commands[] = {"CLOSE", RX_CLOSE, rx_close, "W=WINDOW/K/N,T=TAB/K/N", 0, NULL, 0, 0, NULL }, {"HOTLIST", RX_HOTLIST, rx_hotlist, "A=ACTION/A", 0, NULL, 0, 0, NULL }, {"SLABSTATS", RX_SLABSTATS, rx_slabstats, "FILE", 0, NULL, 0, 0, NULL }, + {"EXEC", RX_EXEC, rx_exec, "W=WINDOW/K/N,T=TAB/K/N,COMMAND/A/F", 0, NULL, 0, 0, NULL }, { NULL, 0, NULL, NULL, 0, NULL, 0, 0, NULL } }; @@ -674,6 +677,33 @@ RXHOOKF(rx_hotlist) } } +RXHOOKF(rx_exec) +{ + struct gui_window *gw = ami_gui_get_active_gw(); + bool res = false; + + if(nsoption_bool(arexx_allow_exec) == false) { + cmd->ac_RC = RETURN_FAIL; + return; + } + + if((cmd->ac_ArgList[0]) && (cmd->ac_ArgList[1])) + gw = ami_find_tab(*(ULONG *)cmd->ac_ArgList[0], *(ULONG *)cmd->ac_ArgList[1]); + + if(gw) { + NSLOG(netsurf, WARNING, "Executing js: %s", (char *)cmd->ac_ArgList[2]); + res = browser_window_exec(ami_gui_get_browser_window(gw), + (char *)cmd->ac_ArgList[2], strlen((char *)cmd->ac_ArgList[2])); + } + + if(res == false) { + cmd->ac_RC = RETURN_ERROR; + } else { + cmd->ac_RC = RETURN_OK; + } + +} + RXHOOKF(rx_slabstats) { #ifndef __amigaos4__ diff --git a/frontends/amiga/options.h b/frontends/amiga/options.h index f67a9b683..196b05709 100644 --- a/frontends/amiga/options.h +++ b/frontends/amiga/options.h @@ -47,6 +47,7 @@ NSOPTION_STRING(search_engines_file, "PROGDIR:Resources/SearchEngines") NSOPTION_STRING(arexx_dir, "PROGDIR:Rexx") NSOPTION_STRING(arexx_startup, "Startup.nsrx") NSOPTION_STRING(arexx_shutdown, "Shutdown.nsrx") +NSOPTION_BOOL(arexx_allow_exec, false) NSOPTION_STRING(download_dir, NULL) NSOPTION_BOOL(download_notify, true) NSOPTION_BOOL(download_notify_progress, false) -- cgit v1.2.3