unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* Bug in http module of guile-www
@ 2004-07-14  7:38 Robert Marlow
  2004-07-14 22:41 ` Thien-Thi Nguyen
  2004-07-14 22:58 ` Kevin Ryde
  0 siblings, 2 replies; 4+ messages in thread
From: Robert Marlow @ 2004-07-14  7:38 UTC (permalink / raw)


Hi all (I hope I'm posting this to the correct list. IIRC you guys also
handle guile-www)

I happened accross a bug in the HTTP module of guile-www which seemed to
trigger when I visited a page which gave no headers and just whitespace
in the body. In such a case the variable "second" of parse-status-line
gets bound to #f which messes up the later make-shared-substrings which
use it.

Admittedly I didn't really study the http module too much to figure out
what that procedure was meant to do or the exact nature of the fail, but
I did produce a quick fix which worked for my purposes. Whether it's
correct or not I have no idea. Anyway, it's simple enough for those who
would know such things to digest and decide:

139,140c139,144
<         (make-shared-substring statline (1+ first) second)
<         (make-shared-substring statline (1+ second)))))
---
>         (if second
>             (make-shared-substring statline (1+ first) second)
>             #f)
>         (if second
>             (make-shared-substring statline (1+ second))
>             #f))))


Apologies it's not in unified diff. The diff on this machine doesn't
seem to support it.

-- 
Regards,

Robert Marlow




_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-guile


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Bug in http module of guile-www
  2004-07-14  7:38 Bug in http module of guile-www Robert Marlow
@ 2004-07-14 22:41 ` Thien-Thi Nguyen
  2004-07-15  1:37   ` Kevin Ryde
  2004-07-14 22:58 ` Kevin Ryde
  1 sibling, 1 reply; 4+ messages in thread
From: Thien-Thi Nguyen @ 2004-07-14 22:41 UTC (permalink / raw)
  Cc: bug-guile

   From: Robert Marlow <bobstopper@bobturf.org>
   Date: Wed, 14 Jul 2004 15:38:17 +0800

   I happened accross a bug in the HTTP module of guile-www which seemed to
   trigger when I visited a page which gave no headers and just whitespace
   in the body. In such a case the variable "second" of parse-status-line
   gets bound to #f which messes up the later make-shared-substrings which
   use it.

in the status line (which has the form: VERSION CODE TEXT), i believe
TEXT is optional, but i don't have the http spec (RFC 2616) handy to
confirm this.  if TEXT is actually optional, that indicates a bug in
http.scm.  if TEXT is required, that indicates a bug in the server's
http implementation.

note that the status line cannot be omitted altogether; the most minimal
valid HTTP response a server can send is STATUS-LINE, CRLF, CRLF.  you
may wish to check the server response for conformance using a command
like "w3m -dump_head" or similar.

   [patch]

unfortunately the patch is incorrect because it allows the possibility
to derive #f for CODE, which is illegal (CODE must be a 3-digit sequence
like "404" or "200").  assuming TEXT is indeed optional, i have changed
`parse-status-line' (in cvs) to handle a missing TEXT component by
returning the empty string.  the proc now reads as follows:

(define (parse-status-line statline)
  ;; Handle:     VERSION CODE
  ;; as well as: VERSION CODE TEXT
  ;; For the former, use the null string for TEXT.
  (let* ((first (string-index statline #\space))
         (second (string-index statline #\space (1+ first))))
    (list (make-shared-substring statline 0 first)
          (make-shared-substring statline (1+ first)
                                 (or second (string-length statline)))
          (if second
              (make-shared-substring statline (1+ second))
              ""))))

and will appear in guile-www 2.6 (to be released shortly).

thi


_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-guile


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Bug in http module of guile-www
  2004-07-14  7:38 Bug in http module of guile-www Robert Marlow
  2004-07-14 22:41 ` Thien-Thi Nguyen
@ 2004-07-14 22:58 ` Kevin Ryde
  1 sibling, 0 replies; 4+ messages in thread
From: Kevin Ryde @ 2004-07-14 22:58 UTC (permalink / raw)
  Cc: bug-guile

Robert Marlow <bobstopper@bobturf.org> writes:
>
> I happened accross a bug in the HTTP module of guile-www which seemed to
> trigger when I visited a page which gave no headers and just whitespace
> in the body.

Thanks.  But I'm guessing it's actually an empty reason phrase in the
status line which provokes this.

> 139,140c139,144

parse-status-line I take it.

>>         (if second
>>             (make-shared-substring statline (1+ first) second)
>>             #f)

No, that would be to end of string to get the status code.


>>         (if second
>>             (make-shared-substring statline (1+ second))
>>             #f))))

And I think that would be better as "" for an empty reason phrase.


_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-guile


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Bug in http module of guile-www
  2004-07-14 22:41 ` Thien-Thi Nguyen
@ 2004-07-15  1:37   ` Kevin Ryde
  0 siblings, 0 replies; 4+ messages in thread
From: Kevin Ryde @ 2004-07-15  1:37 UTC (permalink / raw)


Thien-Thi Nguyen <ttn@surf.glug.org> writes:
>
> in the status line (which has the form: VERSION CODE TEXT), i believe
> TEXT is optional,

Yep, in rfc1945 at least.  (My reading would be that the second space
is mandatory, though the code strips all trailing whitespace so loses
that).


_______________________________________________
Bug-guile mailing list
Bug-guile@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-guile


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-07-15  1:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-14  7:38 Bug in http module of guile-www Robert Marlow
2004-07-14 22:41 ` Thien-Thi Nguyen
2004-07-15  1:37   ` Kevin Ryde
2004-07-14 22:58 ` Kevin Ryde

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).