Bug - Fixed sven golly kills password, i think

It only happened the once, so I'm not sure that it's from Sven Golly, as it could also be chat related, but just after submitting my items for Azazel's unicorn, my character pane (which uses CHIT) lost all its styling. It was still CHIT, just no CSS.
I tried to look at the css manually, and got a blank page, so I went into the gCLI to find a bunch of this:
Code:
Talking to Sven Golly at the Hey Deze Arena

> sven Bognort=4673&Stinkface=4670&Flargwurm=4671&Jim=4672

Giving giant marshmallow to Bognort
Giving beer-scented teddy bear to Stinkface
Giving booze-soaked cherry to Flargwurm
Giving comfy pillow to Jim
You acquire an item: Azazel's unicorn
Items given to bandmembers.
Missing password hash
Path: "/KoLmafia/chit.css"
Missing password hash
Path: "/KoLmafia/chit.js"
With the last 4 lines repeating every time the charpane refreshes.

I'm pretty sure chatting requires a password hash, and I can still chat just fine (as well as adventure anywhere I want).

ADDITIONAL: I just noticed that the charpane seems to be coming from 127.0.0.1/KoLMafia/charpane.php instead of the normal 127.0.0.1/charpane.php

This .. kind of makes sense why it can't find chit.css/js, but it doesn't make sense as to why it -does- find charpane.php (since, technically, it shouldn't exist either, right?) nor does this make sense to me why my passhash seems to be missing.
 
Last edited:

Theraze

Active member
Looks like the chit files are missing a password hash (&pwd) somewhere, which would be a scripting error, not a mafia bug.
 

slyz

Developer
I found this in RelayAgent.java:
PHP:
// If we last ran a command, the browser will
// submit requests with a bogus root.
if ( referer.indexOf( "/KoLmafia" ) != -1 &&
	 this.path.startsWith( "/KoLmafia" ) &&
	 this.path.indexOf( ".php" ) != -1 )
{
	this.path = this.path.substring( 9 );
	this.request.constructURLString( this.path, usePostMethod );
}
continue;
Mafia removes the "/KoLmafia" that was added to the path before submitting the request, but I guess that would explain why CHIT loses its CSS.
 

Veracity

Developer
Staff member
Interesting. This whole "/KoLmafia" thing is a pain. Here's what's happening:

When KoLmafia decorates a page in the relay browser, sometimes it adds a link or a button that asks KoLmafia to run a KoLmafia CLI command. The comand will submit a series of requests to KoL and the result text from the final request is given back to the browser to display. Examples are the "solve" buttons for the Lava Maze or Dvorak's Revenge, the "Go to goal" button for the Louvre, and the whole Sven Golly form that we insert. All such commands turn into a URL that looks something like "/KoLmafia/submitCommand?cmd=x", say; we also have executeCommand, specialCommand, and parameterizedCommand to do variants, but they all start with /KoLmafia.

So, the browser sees that it submits a command starting with "/KoLmafia" and gets back a response text. If the response contains other links that are relative - like "charpane.php" - it submits them as "/KoLmafia/charpane.php". If we pass those straight on through, we get a blank page.

I struggled with this a lot and ended up with the kludgy solution that slyz quoted. If somebody (like hola ;)) who knows more about how KoLmafia, the Relay Browser, and the user's browser interact is able to come up with a way to make the browser submit things from /KoLmafia only if we explicitly put that link onto the page, we could get rid of the kludge - but it was/is beyond me.

The code that slyz cites removes a bogus browser-submitted /KoLmafia only for .php files. Perhaps it could/should remove it from eny kind of files - like chit's .css files.
 

matt.chugg

Moderator
Interesting. If somebody (like hola ;)) who knows more about how KoLmafia, the Relay Browser, and the user's browser interact is able to come up with a way to make the browser submit things from /KoLmafia only if we explicitly put that link onto the page, we could get rid of the kludge - but it was/is beyond me.


I'm not this person, but I do have a suggestion. I think the problem is because the buttons are part of a form, which submits a page. if the buttons wern't in a form, and did their processing by passing information to kolmafia using ajax, then it wouldn't require the page to reload thus causing the problem? maybe. just trying to help with an idea!
 

matt.chugg

Moderator
I will try and look at the mafia code for the relay, as I think there may be a way to prevent the /kolmafia part in urls that don't need it at the point where the page is generated, possibly using a base href tag instead of replacing all urls with absolute ones.
 

Veracity

Developer
Staff member
Revision 10350 adds a "base" tag to every HTML page we fetch in the Relay Browser. It also removes the kludge to strip out the "/KoLmafia" from paths that the browser inserts after having submitted a specialCommand since the browser won't do that any more.

I tested in the Gallery with the "Go to Goal" button, which submits a specialCommand. Everything went swimmingly.
 
Top