[libsoup] Be more aggressive when looking for the termination boundary



commit 2d9397799e9e32a2d1e363d9b062aaa4acd24077
Author: Gustavo Noronha Silva <gns gnome org>
Date:   Mon Oct 8 17:10:19 2012 -0300

    Be more aggressive when looking for the termination boundary
    
    Turns out some servers may send line feeds and carriage return after the final
    boundary. That's the case for the following WebKit LayoutTest:
    
        http/tests/multipart/load-last-non-html-frame.php
    
    https://bugzilla.gnome.org/show_bug.cgi?id=685752

 libsoup/soup-multipart-input-stream.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/libsoup/soup-multipart-input-stream.c b/libsoup/soup-multipart-input-stream.c
index b1738ef..0867f84 100644
--- a/libsoup/soup-multipart-input-stream.c
+++ b/libsoup/soup-multipart-input-stream.c
@@ -378,8 +378,10 @@ soup_multipart_input_stream_read_headers (SoupMultipartInputStream  *multipart,
 			got_boundary = TRUE;
 
 			/* Now check for possible multipart termination. */
-			buf = &read_buf[nread - 2];
-			if (nread >= 2 && !memcmp (buf, "--", 2)) {
+			buf = &read_buf[nread - 4];
+			if ((nread >= 4 && !memcmp (buf, "--\r\n", 4)) ||
+			    (nread >= 3 && !memcmp (buf + 1, "--\n", 3)) ||
+			    (nread >= 3 && !memcmp (buf + 2, "--", 2))) {
 				g_byte_array_set_size (priv->meta_buf, 0);
 				return FALSE;
 			}



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