Molly sending empty mime type #8

Closed
opened 2020-06-20 17:47:33 +00:00 by sloum · 8 comments

** Duplicate of this issue for AV-98 **

I was unsure if molly-brown supported cgi currently or not. So I decided to make a cgi folder in my user folder on rawtext.club and added a simple python script: gemini://rawtext.club/~sloum/cgi/test. All the script does is print 40 The script works\r\n to stdout (I did an error code as a part of my debugging this issue, it had formerly been a 20).

AV-98 and Bombadillo both have issues with visiting that link. They do not receive the above message. Instead they receive: 20 \r\n. My guess is that this is because molly does not support cgi (at least in the way I was trying, but I could find no docs ont he subject... though the code looks like it is supported - I know we've talked about it but I forget).

I believe what is happening is that molly does not supply a mime if none can be discerned. This means that the response header was likely: 20 \r\n. Neither of our clients like that response. Molly should get updated to deal with an empty mime (the file test gives no hint as to its type without looking at a shebang, which I guess the go mime library does not do). I would suggest returning text/plain when a mime cannot be discerned.

** Duplicate of [this issue](https://tildegit.org/solderpunk/AV-98/issues/20) for AV-98 ** I was unsure if molly-brown supported cgi currently or not. So I decided to make a cgi folder in my user folder on rawtext.club and added a simple python script: `gemini://rawtext.club/~sloum/cgi/test`. All the script does is print `40 The script works\r\n` to stdout (I did an error code as a part of my debugging this issue, it had formerly been a 20). AV-98 and Bombadillo both have issues with visiting that link. They do not receive the above message. Instead they receive: `20 \r\n`. My guess is that this is because molly does not support cgi (at least in the way I was trying, but I could find no docs ont he subject... though the code looks like it is supported - I know we've talked about it but I forget). I believe what is happening is that molly does not supply a mime if none can be discerned. This means that the response header was likely: 20 \r\n. Neither of our clients like that response. Molly should get updated to deal with an empty mime (the file `test` gives no hint as to its type without looking at a shebang, which I guess the go mime library does not do). I would suggest returning text/plain when a mime cannot be discerned.
Author

As an added note. If I add .txt to the file (which is set to 755 for its perms) I get 20 text/plain\r\n as the header returned from the server and I get the contents of the python file.

As an added note. If I add `.txt` to the file (which is set to `755` for its perms) I get `20 text/plain\r\n` as the header returned from the server and I get the contents of the python file.

CGI works when you create a folder called cgi-bin (can be configured in molly.conf) in your root and put executable files in there which prints the gemini header (20 text/plain\r\n) and the text to stdout. Be aware that molly-brown does not fix ends of line, so simple bash script using echo will not work, you will have to fix the ends of line manually. This bug is not related to CGI, because molly doesn't consider files in cgi/ a cgi script by default.

CGI works when you create a folder called `cgi-bin` (can be configured in molly.conf) in your root and put executable files in there which prints the gemini header (`20 text/plain\r\n`) and the text to stdout. Be aware that molly-brown does not fix ends of line, so simple bash script using echo will not work, you will have to fix the ends of line manually. This bug is not related to CGI, because molly doesn't consider files in `cgi/` a cgi script by default.
Owner

I think that, as per Issue #5, what's going on here is that the script isn't being run at all.

However, you've found a genuine bug here - Molly tries to guess MIME types from file extensions, and it looks like when there's no exception the result is a "20 \r\n" header, which is not guaranteed to be appropriate.

Not only is it a bug that Molly sends this, but it's a bug that AV-98 and Bombadillo choke on it! The spec does explicitly say that if a status 2x response has no then it should default to "text/gemini; charset=utf-8". Failures all round. :)

I'm going away for a few days tomorrow and will be relaxing off grid the whole time. When I get back, I have some vacation time off work and hope to do a lot of work on both AV-98 and Molly Brown in that time. I'll address this and all other recent Issues then.

I *think* that, as per Issue #5, what's going on here is that the script isn't being run at all. However, you've found a genuine bug here - Molly tries to guess MIME types from file extensions, and it looks like when there's no exception the result is a "20 \r\n" header, which is not guaranteed to be appropriate. Not only is it a bug that Molly sends this, but it's a bug that AV-98 and Bombadillo choke on it! The spec does explicitly say that if a status 2x response has no <META> then it should default to "text/gemini; charset=utf-8". Failures all round. :) I'm going away for a few days tomorrow and will be relaxing off grid the whole time. When I get back, I have some vacation time off work and hope to do a lot of work on both AV-98 and Molly Brown in that time. I'll address this and all other recent Issues then.
Owner

Now I'm a little confused, it looks like the issue with empty MIME types was actually fixed 3 weeks ago: 532dd83414

Now I'm a little confused, it looks like the issue with empty MIME types was actually fixed 3 weeks ago: https://tildegit.org/solderpunk/molly-brown/commit/532dd8341464f646446b91dc44cb9be7bb00ac6f
Owner

Sloum, were you running an older build when you had this problem? If not it's possible there is an alternate code path that still serves an empty MIME type.

Sloum, were you running an older build when you had this problem? If not it's possible there is an alternate code path that still serves an empty MIME type.
Author

This came up on rawtext.club and I believe he is running an older build there. So if it has been resolved by a semi-recent PR I think it is probably solid. I know cmccabe was planning on upgrading to the newest version (in an attempt to solve the cgi issues we are having) and I can verify that this is fixed at that time and add a comment here once I do so. ????

This came up on rawtext.club and I believe he is running an older build there. So if it has been resolved by a semi-recent PR I think it is probably solid. I know cmccabe was planning on upgrading to the newest version (in an attempt to solve the cgi issues we are having) and I can verify that this is fixed at that time and add a comment here once I do so. ????
Owner

I'll close this because I'm pretty sure Molly doesn't do this anymore and hasn't for a while, but feel free to reopen it if you ever see evidence otherwise.

The corresponding AV-98 issue is still relevant, though, and I'll leave that open until I fix it.

I'll close this because I'm pretty sure Molly doesn't do this anymore and hasn't for a while, but feel free to reopen it if you ever see evidence otherwise. The corresponding AV-98 issue is still relevant, though, and I'll leave that open until I fix it.
Author

Sounds good. I fixed Bombadillo (in an as of yet unreleased branch) to default to text/gemini when a mime is not provided, so I probably wouldnt have noticed the fix. Glad it got worked out though :)

Sounds good. I fixed Bombadillo (in an as of yet unreleased branch) to default to `text/gemini` when a mime is not provided, so I probably wouldnt have noticed the fix. Glad it got worked out though :)
Sign in to join this conversation.
No Label
No Milestone
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: solderpunk/molly-brown#8
No description provided.