[libsoup] Bug 579318 – stupid servers that return garbled headers



commit e9e6ad876de480794d09c6304bc6ef5f4d265b12
Author: Dan Winship <danw gnome org>
Date:   Sun Apr 19 11:22:49 2009 -0400

    Bug 579318 â?? stupid servers that return garbled headers
    
    soup_headers_parse: don't pass bad header lines to
    soup_message_headers_append, since it will emit warnings in that case
    now. Also, don't bail out because one line of the headers is bad.
    Instead, just skip the bad line and continue with the next good line.
---
 libsoup/soup-headers.c |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/libsoup/soup-headers.c b/libsoup/soup-headers.c
index 58f48ba..f815db3 100644
--- a/libsoup/soup-headers.c
+++ b/libsoup/soup-headers.c
@@ -67,15 +67,24 @@ soup_headers_parse (const char *str, int len, SoupMessageHeaders *dest)
 	while (*(value_end + 1)) {
 		name = value_end + 1;
 		name_end = strchr (name, ':');
-		if (!name_end)
-			goto done;
+		if (!name_end || name + strcspn (name, " \t\r\n") < name_end) {
+			/* Bad header; just ignore this line. Note
+			 * that if it has continuation lines, we'll
+			 * end up ignoring them too since they'll
+			 * start with spaces.
+			 */
+			value_end = strchr (name, '\n');
+			if (!value_end)
+				goto done;
+			continue;
+		}
 
 		/* Find the end of the value; ie, an end-of-line that
 		 * isn't followed by a continuation line.
 		 */
 		value = name_end + 1;
 		value_end = strchr (name, '\n');
-		if (!value_end || value_end < name_end)
+		if (!value_end)
 			goto done;
 		while (*(value_end + 1) == ' ' || *(value_end + 1) == '\t') {
 			value_end = strchr (value_end + 1, '\n');



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]