Fatal error when server does not return mime in header #20

Closed
opened 2020-06-20 17:42:18 +00:00 by sloum · 2 comments

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 to stdout (I did an error code as a part of my debugging this issue, it had formerly been a 20).

In Bombadillo I get the message: "Improperly formatted mimetype received from server". This does ok, but didnt tell me the issue (but does not kill the program). So I tried AV-98 and got the following:

Traceback (most recent call last):
  File "/usr/lib/python3.6/cmd.py", line 214, in onecmd
    func = getattr(self, 'do_' + cmd)
AttributeError: 'GeminiClient' object has no attribute 'do_g'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/av98", line 1008, in <module>
    main()
  File "/usr/local/bin/av98", line 1003, in main
    gc.cmdloop()
  File "/usr/lib/python3.6/cmd.py", line 138, in cmdloop
    stop = self.onecmd(line)
  File "/usr/lib/python3.6/cmd.py", line 216, in onecmd
    return self.default(line)
  File "/usr/local/bin/av98", line 529, in default
    return self.onecmd(expanded)
  File "/usr/lib/python3.6/cmd.py", line 217, in onecmd
    return func(arg)
  File "/usr/local/bin/av98", line 624, in do_go
    self._go_to_gi(GeminiItem(line))
  File "/usr/local/bin/av98", line 269, in _go_to_gi
    status, meta = header.split(maxsplit=1)
ValueError: not enough values to unpack (expected 2, got 1)

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. I will open a similar issue for molly 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.

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` to stdout (I did an error code as a part of my debugging this issue, it had formerly been a 20). In Bombadillo I get the message: "Improperly formatted mimetype received from server". This does ok, but didnt tell me the issue (but does not kill the program). So I tried AV-98 and got the following: ```python3 Traceback (most recent call last): File "/usr/lib/python3.6/cmd.py", line 214, in onecmd func = getattr(self, 'do_' + cmd) AttributeError: 'GeminiClient' object has no attribute 'do_g' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/bin/av98", line 1008, in <module> main() File "/usr/local/bin/av98", line 1003, in main gc.cmdloop() File "/usr/lib/python3.6/cmd.py", line 138, in cmdloop stop = self.onecmd(line) File "/usr/lib/python3.6/cmd.py", line 216, in onecmd return self.default(line) File "/usr/local/bin/av98", line 529, in default return self.onecmd(expanded) File "/usr/lib/python3.6/cmd.py", line 217, in onecmd return func(arg) File "/usr/local/bin/av98", line 624, in do_go self._go_to_gi(GeminiItem(line)) File "/usr/local/bin/av98", line 269, in _go_to_gi status, meta = header.split(maxsplit=1) ValueError: not enough values to unpack (expected 2, got 1) ``` 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. I will open a similar issue for molly 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.
Contributor

If relevant: fixed in my fork (https://tildegit.org/continue/AV-98).

If relevant: fixed in my fork (https://tildegit.org/continue/AV-98).
Owner

Pretty embarrassed that such a trivial bug stayed open for 3 years, but I'm happy to close this issue now after merging the PR that @continue provided.

Pretty embarrassed that such a trivial bug stayed open for 3 years, but I'm happy to close this issue now after merging the PR that @continue provided.
Sign in to join this conversation.
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/AV-98#20
No description provided.