commit 03f3bc09c347b58c21769509ca96b74ab2e09ed8
Author: Alejandro G. Castro <alex@igalia.com>
Date:   Tue Oct 6 14:48:52 2009 +0200

    Fixed problem with the content sniffing.
    
    The content sniffing was not correct when there was not
    meta-information about the file, we have to check the length
    of the pattern.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=597545

diff --git a/libsoup/soup-content-sniffer.c b/libsoup/soup-content-sniffer.c
index ed57e7c..d55aab5 100644
--- a/libsoup/soup-content-sniffer.c
+++ b/libsoup/soup-content-sniffer.c
@@ -279,7 +279,8 @@ sniff_unknown (SoupContentSniffer *sniffer, SoupMessage *msg,
 			int index_pattern = 0;
 			gboolean skip_row = FALSE;
 
-			while (index_stream < resource_length) {
+			while ((index_stream < resource_length) &&
+			       (index_pattern <= type_row->pattern_length)) {
 				/* Skip insignificant white space ("WS" in the spec) */
 				if (type_row->pattern[index_pattern] == ' ') {
 					if (resource[index_stream] == '\x09' ||
diff --git a/tests/resources/test_noinfo.html b/tests/resources/test_noinfo.html
new file mode 100644
index 0000000..31ffc13
--- /dev/null
+++ b/tests/resources/test_noinfo.html
@@ -0,0 +1,8 @@
+<html>
+<head>
+<title></title>
+</head>
+<body>
+<h1>GNOME!</h1>
+</body>
+</html>
diff --git a/tests/sniffing-test.c b/tests/sniffing-test.c
index 26ddc16..60d1c18 100644
--- a/tests/sniffing-test.c
+++ b/tests/sniffing-test.c
@@ -493,6 +493,7 @@ main (int argc, char **argv)
 	/* Test the unknown sniffing path */
 
 	test_sniffing ("/unknown/test.html", "text/html");
+	test_sniffing ("/unknown/test_noinfo.html", "text/html");
 	test_sniffing ("/unknown/home.gif", "image/gif");
 	test_sniffing ("/unknown/mbox", "application/mbox");
 
