That looks remarkably simple. What could possibly go wrong?
I'm looking at how relay scripts get executed. KoLmafiaASH.getClientHTML( RelayRequest request ) looks up the script and then calls KoLmafiaASH.getClientHTML( RelayRequest request, File toExecute ) to actually run it. That latter method gets the interpreter and executes the script. In particular, it does relayScript.initializeRelayScript( relayRequest ). Interpreter.initializeRelayScript() does the KoLmafia.forceContinue(). So, assuming that KoLmafiaASH.getClientHTML is called ONLY when StaticEntity.isRelayThread() will return true, the continuationState is sandboxed, just as you desire.
It looks like the KoLmafiaASH method is called only in the run() method of a RelayRequest, which should only be called in its own thread from the RelayAgent, so that all looks good.
So, the only thing to check: is it really the case that the only time we have RelayRequest is via the RelayAgent? grepping for "new RelayRequest" says "not quite".
Code:
./KoLmafiaASH.java:161: RelayRequest relayRequest = new RelayRequest( false );
./KoLmafiaASH.java:197: RelayRequest relayRequest = new RelayRequest( false );
./request/UseItemRequest.java:1147: RelayRequest request = new RelayRequest( false );
./textui/RuntimeLibrary.java:2067: new GenericRequest( "" ) : new RelayRequest( false );
./webui/RelayAgent.java:104: this.request = new RelayRequest( true );
The KoLmafiaASH and RelayAgent calls are exactly what are expected. But what about the others?
UseItemRequest:
Code:
case ItemPool.MACGUFFIN_DIARY:
// Make it a RelayRequest since we don't want a charpane refresh
RelayRequest request = new RelayRequest( false );
request.constructURLString( "diary.php?textversion=1" );
RequestThread.postRequest( request );
Well, that looks harmless. If you do this in the browser, it will be in its own thread, anyway.
The RuntimeLibrary one is in visit_url:
Code:
// See if we are inside a relay override
RelayRequest relayRequest = interpreter.getRelayRequest();
// If so, use a RelayRequest rather than a GenericRequest
GenericRequest request = ( relayRequest == null ) ?
new GenericRequest( "" ) : new RelayRequest( false );
So that looks good too.
I'd be tempted to just do a bit more testing and then submit it into the wild.