Hello,
this should be the last minor PARQ update for now. It only updates the
get_header_value.
If there are no comments I will now focus on PARQ server side. Hopefully
I get that one ready before 0.92 gets released.
Index: src/parq.c
===================================================================
RCS file: /cvsroot/gtk-gnutella/gtk-gnutella-current/src/parq.c,v
retrieving revision 1.4
diff -u -r1.4 parq.c
--- src/parq.c 3 Feb 2003 22:18:52 -0000 1.4
+++ src/parq.c 4 Feb 2003 20:37:55 -0000
@@ -57,9 +57,13 @@
gchar *lowercase_header = s;
gchar *end;
gboolean found_right_attribute = FALSE;
+ gboolean found_equal_sign = FALSE;
size_t attrlen;
+
gchar e;
gchar b;
+ gchar es;
+
g_assert(s != NULL);
g_assert(attribute != NULL);
@@ -96,15 +100,52 @@
e == ' ' || e == '=' || e == '\0'
);
}
-
+
/*
* If we weren't looking at the right value. Move on to the next.
* If there are no valid values, the while loop will abort with
* lowercase_header == NULL
+ * If we did find a valid position we want to make sure the next
+ * char is an '='. So we need to move ahead anyway.
*/
- if (!found_right_attribute)
- lowercase_header++;
-
+
+ lowercase_header += attrlen;
+
+ if (found_right_attribute) {
+
+ /*
+ * OK, so we found a possible valid attribute. Now make sure the
+ * first character is an '=', ignoring white spaces.
+ * If we don't, we didn't find a valid attribute.
+ */
+
+ found_equal_sign = FALSE;
+
+ do {
+ es = *lowercase_header;
+
+ found_right_attribute = es == '=' || es == ' ' || es == '\0';
+ found_equal_sign = es == '=';
+
+ if (!found_equal_sign)
+ es = *(++lowercase_header);
+
+ } while (
+ !found_equal_sign &&
+ found_right_attribute &&
+ lowercase_header != NULL
+ );
+
+ if (!found_right_attribute) {
+
+ /*
+ * Looks like we were parsing an invalid http header.
+ * something like val1 = 3; val2 ; val3=66
+ */
+
+ g_warning("Error while parsing values in: %s", s);
+ }
+ }
} while (!found_right_attribute && lowercase_header != NULL);