Bug - Fixed Faulty relay browser links

Boesbert

Member
Acquiring a queen cookie after using the automatic solving function creates a description link in the queen cookie icon at the result that is not working. It is formed like this: http://127.0.0.1:60080/KoLmafia/desc_item.php?whichitem=574685883 which gives me a "The 127.0.0.1 page isn’t working

127.0.0.1 didn’t send any data.
ERR_EMPTY_RESPONSE" response.

In the inventory the description link from the queen cookie icon works and is formed like this: http://127.0.0.1:60080/desc_item.php?whichitem=574685883

The same is true for automatically acquiring a lost pill bottle after using a lost key, opening the lost pill bottle and then clicking on any of the description links on the icons of the pills:

These do not work: http://127.0.0.1:60080/KoLmafia/desc_item.php?whichitem=916901143

(example from just now, tested again with r17404)

The regularly formed links in the inventory do work and look like this: http://127.0.0.1:60080/desc_item.php?whichitem=916901143

Also, I just noticed that clicking on the malformed description link produces this in the gcli (from one single click):

Missing password hash
Path: "/KoLmafia/desc_item.php?whichitem=127149792"
Missing password hash
Path: "/KoLmafia/desc_item.php?whichitem=127149792"
Missing password hash
Path: "/KoLmafia/desc_item.php?whichitem=127149792"
Missing password hash
Path: "/KoLmafia/desc_item.php?whichitem=127149792"
Missing password hash
Path: "/KoLmafia/desc_item.php?whichitem=127149792"
Missing password hash
Path: "/KoLmafia/desc_item.php?whichitem=127149792"
Missing password hash
Path: "/KoLmafia/desc_item.php?whichitem=127149792"
Missing password hash
Path: "/KoLmafia/desc_item.php?whichitem=127149792"
Missing password hash
Path: "/KoLmafia/desc_item.php?whichitem=127149792"
Missing password hash
Path: "/KoLmafia/desc_item.php?whichitem=127149792"
Missing password hash
Path: "/KoLmafia/desc_item.php?whichitem=127149792"
Missing password hash
Path: "/KoLmafia/desc_item.php?whichitem=127149792"
Missing password hash
Path: "/KoLmafia/desc_item.php?whichitem=127149792"
Missing password hash
Path: "/KoLmafia/desc_item.php?whichitem=127149792"
Missing password hash
Path: "/KoLmafia/desc_item.php?whichitem=127149792"
Missing password hash
Path: "/KoLmafia/desc_item.php?whichitem=127149792"


This might be related to the top two: Reading the telegram from the result page after buying one forwards you to the inventory page with a "Reading the telegram..." message but not opening it. That link is formed like http://127.0.0.1:60080/inv_use.php?which=3&whichitem=8837&pwd=4b91b8d50c6bd239488aebb6c8e92d73

Using the telegram from the inventory correctly leads you to "The Investigation Begins". The link is formed like http://127.0.0.1:60080/inv_use.php?pwd=4b91b8d50c6bd239488aebb6c8e92d73&which=3&whichitem=8837
 

Veracity

Developer
Staff member
Thanks for telling me that getting the lost pill bottle and opening it generated item images with clickable images. Although I accumulated 235 lost keys over the years, I've never actually looked at that content. And you can do it when overdrunk, which is my character's current state.

I went to the inventory in the Relay Browser
I saw my lost keys
I turned on the DEBUG log using "debug on"
I clicked on the "use" link of the lost key and navigated through until I obtained a lost pill bottle.

Here is the HTML that KoL gave us for that:

Code:
<table class="item" style="float: none" rel="id=5699&s=0&q=0&d=0&g=0&t=1&n=1&m=1&p=0&u=u"><tr><td><img src="https://s3.amazonaws.com/images.kingdomofloathing.com/itemimages/goofballs.gif" alt="The Lost Pill Bottle" title="The Lost Pill Bottle" class=hand onClick='descitem(367129347)'></td><td valign=center class=effect>You acquire an item: <b>The Lost Pill Bottle</b></td></tr></table>
Notice that the image URL is "https://s3.amazonaws.com/images.kingdomofloathing.com/itemimages/goofballs.gif".
Notice that it says onClick='descitem(367129347)' - which must be a Javascript function.

Here is the HTML we sent down to the browser:

Code:
<table class="item" style="float: none" rel="id=5699&s=0&q=0&d=0&g=0&t=1&n=1&m=1&p=0&u=u"><tr><td><img src="/images/itemimages/goofballs.gif" alt="The Lost Pill Bottle" title="The Lost Pill Bottle" class=hand onClick='descitem(367129347)'></td><td valign=center class=effect>You acquire an item: <b>The Lost Pill Bottle</b> <font size=1>[<a href="javascript:singleUse('inv_use.php','which=3&whichitem=5699&pwd=9316d2044e4a18991881ebc708d90672&ajax=1');void(0);">use</a>]</font></td></tr></table>
Notice that the image URL is /images/itemimages/goofballs.gif - KoLmafia's image cache
Notice that it (still) says onClick='descitem(367129347)'
Notice that we added a "use" link: javascript:singleUse('inv_use.php','which=3&whichitem=5699&pwd=9316d2044e4a18991881ebc708d90672&ajax=1');void(0);

That is all completely normal KoLmafia/Relay Browser operation.

I clicked on the image - the thing that had the Javascript descitem(367129347)

The Browser requested:

GET /desc_item.php?whichitem=367129347 HTTP/1.1

KoLmafia submitted: https://www.kingdomofloathing.com/desc_item.php?whichitem=367129347

KoL responded with

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html><head><title>Item Description</title><link rel="stylesheet" type="text/css" href="https://s3.amazonaws.com/images.kingdomofloathing.com/styles.css"><style>a.hand {cursor: pointer;}</style><script language=Javascript src="https://s3.amazonaws.com/images.kingdomofloathing.com/scripts/keybinds.min.2.js"></script><script language=Javascript src="https://s3.amazonaws.com/images.kingdomofloathing.com/scripts/window.20111231.js"></script></head><body><div id="description" class=small><center><img src="https://s3.amazonaws.com/images.kingdomofloathing.com/itemimages/goofballs.gif" height=30 width=30 alt="goofballs"><br><b>The Lost Pill Bottle</b></center><p><blockquote>This is a bottle of little blue, red, and purple pills. I mean, three different solid colors of pills, not pills with stripes. The label on the bottle wore off long ago, but it's probably okay to try the pills anyway. What's the worst that could happen?<!-- itemid: 5699 --><br><br>Type: <b>usable</b><br>Cannot be discarded</blockquote><script type="text/javascript"><!--var resizetries = 0;var fsckinresize;setTimeout(fsckinresize = function ()  {var desch = document.getElementById('description').offsetHeight;if (desch < 100 && resizetries < 5) {setTimeout(fsckinresize, 100);resizetries++;}if (desch < 100) desch = 200;//alert('resizing on try #' + resizetries);if (self.resizeTo && window.outerHeight) {self.resizeTo(400, desch + (window.outerHeight - window.innerHeight) + 50);}else if (self.resizeTo ) { self.resizeTo(400, desch+130); }else { window.innerHeight = newh; }}, 100);//--></script></div></body></html>

And we sent the following down to the Browser:

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html><head><title>Item Description</title><link rel="stylesheet" type="text/css" href="/images/styles.css"><style>a.hand {cursor: pointer;}</style><script language=Javascript src="/images/scripts/keybinds.min.2.js"></script><script language=Javascript src="/images/scripts/window.20111231.js"></script><script language="Javascript" src="/basics.js"></script><link rel="stylesheet" href="/basics.1.css" /></head><body><div id="description" class=small><center><img src="/images/itemimages/goofballs.gif" height=30 width=30 alt="goofballs"><br><b>The Lost Pill Bottle</b></center><p><blockquote>This is a bottle of little blue, red, and purple pills. I mean, three different solid colors of pills, not pills with stripes. The label on the bottle wore off long ago, but it's probably okay to try the pills anyway. What's the worst that could happen?<!-- itemid: 5699 --><br><br>Type: <b>usable</b><br>Cannot be discarded</blockquote><script type="text/javascript"><!--var resizetries = 0;var fsckinresize;setTimeout(fsckinresize = function ()  {var desch = document.getElementById('description').offsetHeight;if (desch < 100 && resizetries < 5) {setTimeout(fsckinresize, 100);resizetries++;}if (desch < 100) desch = 200;//alert('resizing on try #' + resizetries);if (self.resizeTo && window.outerHeight) {self.resizeTo(400, desch + (window.outerHeight - window.innerHeight) + 50);}else if (self.resizeTo ) { self.resizeTo(400, desch+130); }else { window.innerHeight = newh; }}, 100);//--></script></div></body><script src="/onfocus.1.js"></script></html>
Again, we rewrote the image URLs to go through our image cache.

This is all perfectly normal.

I used the "use" link to open the bottle and clicked on the images of the pills it gave me. Again, it all worked normally.
 

Veracity

Developer
Staff member
I tried this again just looking at the inventory.

Here is one of the items:

Code:
<table class='item' id="ic5680" rel="id=5680&s=0&q=0&d=0&g=0&t=1&n=235&m=0&p=0&u=u"><td class="img"><img src="https://s3.amazonaws.com/images.kingdomofloathing.com/itemimages/lostkey.gif" class="hand ircm" rel="891641724" onClick='descitem(891641724,0,event);'></td><td id='i5680' valign=middle><b rel="891641724" class="ircm">lost key</b> <span>(235)</span><font size=1><br><a href="inv_use.php?pwd=07844cf459b36d48610759e4f9d0cf98&which=3&whichitem=5680">[use]</a> </font></td></table>
Looks very similar to the "You acquire an item" thing, except:

The image says onClick='descitem(390153181,0,event);' - there is an "event" there
KoL itself has a "use" link which goes to use.php.

I clicked on the image and we requested https://www.kingdomofloathing.com/desc_item.php?whichitem=891641724 exactly as expected.
 
Last edited:

Veracity

Developer
Staff member
Things that puzzle me about your report:

You say that the "description links" are like this: http://127.0.0.1:60080/KoLmafia/desc_item.php?whichitem=574685883
For me, there are no "description links". There is KoL-supplied Javascript like this: descitem(574685883)

There is nothing in KoLmafia which rewrites the Javascript call into anything at all.

What is your Browser?
Do you have Javascript disabled?
What relay scripts are you running?
 

Veracity

Developer
Staff member
Unless somebody can tell me how to reproduce this, then, I'm going to have to mark this Cannot Reproduce.

I am sorry it is happening to you. As I said, there is no code in KoLmafia itself which will replace the "descitem(123456)" Javascript with ".../desc_item.php?whichitem=123456" - with or without a "/KoLmafia" stuck in there.

OK. Get me a DEBUG log, please.

In Preferences/General/Extra Debugging: check "Verbosely log communication between KoLmafia and Browser" and "log decorated responses in debug log"
In the gCLI: debug on
In the Relay Browser, use a lost key and navigate through to get lost pills
In the gCLI: debug off

post the DEBUG_xxx.txt file here.

Thanks.
 

Boesbert

Member
Okay, here it is. I also opened the pill bottle and clicked on the icons of either pills.

View attachment DEBUG_20161121.txt

edit: I realize I might have accidentally been running debug from earlier, so that log might be a bit too large. If you want, I can fix that and post another one later. Sorry about that.
 
Last edited:

Veracity

Developer
Staff member
Whoah. You went through it using "Go to Goal" which is done via "/KoLmafia/specialCommand?cmd=choice-goal&pwd".

-----From Browser-----
POST /KoLmafia/specialCommand?cmd=choice-goal&pwd HTTP/1.1

KoLmafia responds with a "wait" message to the Browser while it automates through the chain of choices.

-----From Browser-----
GET /KoLmafia/specialCommand?cmd=wait&pwd=770507dd55b9ba4402687f1d460d67d6 HTTP/1.1

Eventually, it responds with the text from the final choice. That includes the following:

Code:
<table class="item" style="float: none" rel="id=5699&s=0&q=0&d=0&g=0&t=1&n=1&m=1&p=0&u=u"><tr><td><img src="/images/itemimages/goofballs.gif" alt="The Lost Pill Bottle" title="The Lost Pill Bottle" class=hand onClick='descitem(367129347)'></td><td valign=center class=effect>You acquire an item: <b>The Lost Pill Bottle</b> <font size=1>[<a href="javascript:singleUse('inv_use.php','which=3&whichitem=5699&pwd=770507dd55b9ba4402687f1d460d67d6&ajax=1');void(0);">use</a>]</font></td></tr></table>
Note the "onClick='descitem(367129347)'".

So, when you click on it, Javascript runs the descitem() function, which submits desc_item.php?whichitem=367129347.
Except, since it was in the context of "/KoLmafia", the browser submits:

-----From Browser-----
GET /KoLmafia/desc_item.php?whichitem= 367129347 HTTP/1.1

So, this is all because you did "Go to Goal".

I think I ran into this years ago in a different context. I'll have to see if I can figure out how I dealt with it.
 

Veracity

Developer
Staff member
Code:
------------------------------------------------------------------------
r10639 | shwei | 2012-02-26 14:19:24 -0500 (Sun, 26 Feb 2012) | 1 line

Rather than rely on base tags, change the href refresh location to include a leading forward slash, as it's more likely that the base tag isn't used for a Javascript href change in IE than it is the case that the base tag is missing at random.
------------------------------------------------------------------------
r10638 | shwei | 2012-02-26 14:00:21 -0500 (Sun, 26 Feb 2012) | 1 line

Rather than have each individual base HREF be generated by each automator, just generate one when returning the response.
------------------------------------------------------------------------
r10636 | shwei | 2012-02-26 13:49:57 -0500 (Sun, 26 Feb 2012) | 1 line

Fix missing base tag in /KoLmafia/specialCommand responses.  Remove base tag from general responses.
Or, perhaps, I should say that holatuwol dealt with it almost 7 years ago. I wonder what went wrong since then?
 

Veracity

Developer
Staff member
Interesting. So, holatuwol decided to deal with this by munging relative links to have a / in front of them in the response to a specialCommand. But here we have a javascript function which generates a URL without a / in front of it, so the Browser submits it relative to /KoLmafia.

I may have to go back to inserting a base tag...
 

Veracity

Developer
Staff member
OK, revision 17414 should do it. We put a "base" tag into the response to a specialCommand.

I set a goal for the lost key to be a Lost Pill Bottle
I used a lost key in the Relay Browser
I pressed Go to Goal
When it showed my my Lost Pill Bottle, I clicked on the image and it popped up the description.
I used the "use" link on the Lost Pill Bottle and it gave me pills.
I clicked on images of pills and it popped up descriptions.

The main thing I didn't notice was that you said you used the "automatic solving function" - which is to say, "Go to Goal". Since I had never used the lost key, I didn't even know we HAD a "Go to Goal" for that.

That would be my fault; you did give all the info that was needed.
 
Top