Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gnumeric/plugins/html/ChangeLog,v
retrieving revision 1.199
diff -u -r1.199 ChangeLog
--- ChangeLog	13 Jun 2005 04:40:06 -0000	1.199
+++ ChangeLog	14 Jul 2005 18:37:22 -0000
@@ -1,3 +1,10 @@
+2005-07-15  Jon K Hellan  <hellan@acm.org>
+
+	http://bugzilla.gnome.org/show_bug.cgi?id=304480
+	* plugin.xml.in: probe=TRUE for html importer.
+	* html_read.[ch] (html_file_probe): New. Probe for html and Excel
+	quasi html.
+
 2005-06-13  Jody Goldberg <jody@gnome.org>
 
 	* Release 1.5.2
Index: html.h
===================================================================
RCS file: /cvs/gnome/gnumeric/plugins/html/html.h,v
retrieving revision 1.23
diff -u -r1.23 html.h
--- html.h	4 Mar 2005 17:58:21 -0000	1.23
+++ html.h	14 Jul 2005 18:37:22 -0000
@@ -39,6 +39,10 @@
 void html_file_open (GOFileOpener const *fo, IOContext *io_context, 
 		     WorkbookView *wb_view, GsfInput *input);
 
+gboolean html_file_probe (GOFileOpener const *fo, GsfInput *input, 
+			  FileProbeLevel pl);
+
+
 #define G_PLUGIN_FOR_HTML "GPFH/0.5"
 
 #endif
Index: html_read.c
===================================================================
RCS file: /cvs/gnome/gnumeric/plugins/html/html_read.c,v
retrieving revision 1.100
diff -u -r1.100 html_read.c
--- html_read.c	26 Jun 2005 00:53:57 -0000	1.100
+++ html_read.c	14 Jul 2005 18:37:22 -0000
@@ -46,6 +46,7 @@
 #include <ranges.h>
 #include <goffice/app/io-context.h>
 #include <goffice/app/error-info.h>
+#include <goffice/utils/go-glib-extras.h>
 
 #include <gsf/gsf-input.h>
 #include <libxml/HTMLparser.h>
@@ -474,6 +475,9 @@
 
 	g_return_if_fail (input != NULL);
 
+	if (gsf_input_seek (input, 0, G_SEEK_SET))
+		return;
+
 	size = gsf_input_size (input);
 	if (size >= 4) {
 		size -= 4;
@@ -541,3 +545,51 @@
 		gnumeric_io_error_info_set (io_context,
 			error_info_new_str (_("Unable to parse the html.")));
 }
+
+/* Quick and dirty html probe. */
+gboolean 
+html_file_probe (GOFileOpener const *fo, GsfInput *input, FileProbeLevel pl)
+{
+	gsf_off_t size = 200;
+	guint8 const* buf = gsf_input_read (input, size, NULL);
+	gchar *ustr, *ulstr;
+	gboolean res = FALSE;
+	gchar *magic;
+
+	/* Avoid seeking in large streams - try to read, fall back if 
+	 * stream is too short */
+	if (!buf) {
+		size = gsf_input_size (input);
+		buf = gsf_input_read (input, size, NULL);
+		if (!buf)
+			return res;
+	}
+
+	(void) go_guess_encoding (buf, size, NULL, &ustr);
+	printf ("ustr: %s\n", ustr);
+	if (!ustr)
+		return res;
+	ulstr = g_utf8_strdown (ustr, -1);
+	g_free (ustr);
+	if (!ulstr)
+		return res;
+
+	magic = (gchar *) "<table";
+	if (g_strstr_len (ulstr, -1, magic) == ulstr) {
+		res = TRUE;
+	} else  {
+		magic = (gchar *) "<html";
+		if (g_strstr_len (ulstr, -1, magic)) {
+			res = TRUE;
+		} else {
+			magic = (gchar *) "<!DOCTYPE html";
+			if (g_strstr_len (ulstr, -1, magic)) {
+				res = TRUE;
+			}
+		}
+	}
+	g_free (ulstr);
+
+	return res;
+}
+
Index: plugin.xml.in
===================================================================
RCS file: /cvs/gnome/gnumeric/plugins/html/plugin.xml.in,v
retrieving revision 1.19
diff -u -r1.19 plugin.xml.in
--- plugin.xml.in	24 Sep 2004 01:33:20 -0000	1.19
+++ plugin.xml.in	14 Jul 2005 18:37:22 -0000
@@ -8,7 +8,7 @@
 		<attribute name="module_file" value="html"/>
 	</loader>
 	<services>
-		<service type="file_opener" id="html" priority="100" probe="FALSE">
+		<service type="file_opener" id="html" priority="100" probe="TRUE">
 			<information>
 				<_description>HTML (*.html, *.htm)</_description>
 			</information>
