From 08c935bef2f70dc2131b74f52f4fc8260161dc59 Mon Sep 17 00:00:00 2001 From: hniksic Date: Mon, 14 Jan 2002 07:17:34 -0800 Subject: [PATCH] [svn] Strip trailing whitespace in header_process(). Published in . --- src/ChangeLog | 5 +++++ src/headers.c | 14 ++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index f75634a3..9bec4d66 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2002-01-14 Hrvoje Niksic + + * headers.c (header_get): Strip trailing whitespace from the + header. + 2002-01-14 Hrvoje Niksic * url.c (parse_uname): URL-decode *USER and *PASSWD. diff --git a/src/headers.c b/src/headers.c index 7f8693a3..4f65c2b5 100644 --- a/src/headers.c +++ b/src/headers.c @@ -64,8 +64,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ as much memory as necessary for it to fit. It need not contain a `:', thus you can use it to retrieve, say, HTTP status line. - The trailing CRLF or LF are stripped from the header, and it is - zero-terminated. #### Is this well-behaved? */ + All trailing whitespace is stripped from the header, and it is + zero-terminated. */ int header_get (struct rbuf *rbuf, char **hdr, enum header_get_flags flags) { @@ -101,11 +101,13 @@ header_get (struct rbuf *rbuf, char **hdr, enum header_get_flags flags) if (next == '\t' || next == ' ') continue; } - /* The header ends. */ + + /* Strip trailing whitespace. (*hdr)[i] is the newline; + decrement I until it points to the last available + whitespace. */ + while (i > 0 && ISSPACE ((*hdr)[i - 1])) + --i; (*hdr)[i] = '\0'; - /* Get rid of '\r'. */ - if (i > 0 && (*hdr)[i - 1] == '\r') - (*hdr)[i - 1] = '\0'; break; } } -- 2.39.2