diff -burN w3m-0.5.orig/backend.c w3m-0.5/backend.c --- w3m-0.5.orig/backend.c Tue Sep 23 06:02:16 2003 +++ w3m-0.5/backend.c Thu Mar 25 14:13:38 2004 @@ -3,6 +3,7 @@ #include #include #include "fm.h" +#include "myctype.h" #include #include "terms.h" @@ -95,7 +96,7 @@ buf = loadGeneralFile(url, NULL, NO_REFERER, 0, request); do_download = FALSE; if (buf != NULL && buf != NO_BUFFER) { - if (!strcasecmp(buf->type, "text/html") && backend_halfdump_buf) { + if (IS_HTML(buf->type) && backend_halfdump_buf) { TextLineListItem *p; Str first, last; int len = 0; @@ -114,7 +115,7 @@ printf("%s", last->ptr); } else { - if (!strcasecmp(buf->type, "text/plain")) { + if (IS_PLAINTEXT(buf->type)) { Line *lp; int len = 0; for (lp = buf->firstLine; lp; lp = lp->next) { diff -burN w3m-0.5.orig/buffer.c w3m-0.5/buffer.c --- w3m-0.5.orig/buffer.c Sat Sep 27 02:59:51 2003 +++ w3m-0.5/buffer.c Thu Mar 25 14:22:09 2004 @@ -558,7 +558,7 @@ WcOption.auto_detect = WC_OPT_DETECT_OFF; UseContentCharset = FALSE; #endif - if (!strcasecmp(buf->type, "text/html")) + if (IS_HTML(buf->type)) loadHTMLBuffer(&f, buf); else loadBuffer(&f, buf); @@ -590,7 +590,7 @@ gotoLine(buf, cur->linenumber); } buf->pos -= buf->currentLine->bpos; - if (FoldLine && strcasecmp(buf->type, "text/html")) + if (FoldLine && !IS_HTML(buf->type)) buf->currentColumn = 0; else buf->currentColumn = sbuf.currentColumn; diff -burN w3m-0.5.orig/display.c w3m-0.5/display.c --- w3m-0.5.orig/display.c Sat Sep 27 02:59:51 2003 +++ w3m-0.5/display.c Thu Mar 25 14:15:47 2004 @@ -383,7 +383,7 @@ if (buf->height == 0) buf->height = LASTLINE + 1; if ((buf->width != INIT_BUFFER_WIDTH && - ((buf->type && !strcmp(buf->type, "text/html")) || FoldLine)) + ((buf->type && IS_HTML(buf->type)) || FoldLine)) || buf->need_reshape) { buf->need_reshape = TRUE; reshapeBuffer(buf); diff -burN w3m-0.5.orig/file.c w3m-0.5/file.c --- w3m-0.5.orig/file.c Tue Dec 9 01:08:01 2003 +++ w3m-0.5/file.c Thu Mar 25 14:08:16 2004 @@ -268,7 +268,7 @@ static int is_plain_text_type(char *type) { - return ((type && strcasecmp(type, "text/plain") == 0) || + return ((type && IS_PLAINTEXT(type)) || (is_text_type(type) && !is_dump_text_type(type))); } @@ -373,7 +373,7 @@ uf->guess_type = guessContentType(path); if (uf->guess_type == NULL) uf->guess_type = "text/plain"; - if (strcasecmp(uf->guess_type, "text/html") == 0) + if (IS_HTML(uf->guess_type)) return; if ((fp = lessopen_stream(path))) { UFclose(uf); @@ -2009,7 +2009,7 @@ } #endif - if (!strcasecmp(t, "text/html")) + if (IS_HTML(t)) proc = loadHTMLBuffer; else if (is_plain_text_type(t)) proc = loadBuffer; @@ -2073,7 +2073,7 @@ b->real_type = real_type; if (b->currentURL.host == NULL && b->currentURL.file == NULL) copyParsedURL(&b->currentURL, &pu); - if (!strcasecmp(t, "text/html")) + if (IS_HTML(t)) b->type = "text/html"; else if (w3m_backend) { Str s = Strnew_charp(t); @@ -7000,7 +7000,7 @@ wc_ces charset = DisplayCharset ? DisplayCharset : WC_CES_US_ASCII; #endif - if (buf->type && !strcasecmp(buf->type, "text/html")) + if (buf->type && IS_HTML(buf->type)) is_html = TRUE; pager_next: @@ -7158,7 +7158,7 @@ t = DefaultType; DefaultType = NULL; } - if (!strcasecmp(t, "text/html")) { + if (IS_HTML(t)) { buf = loadHTMLBuffer(&uf, t_buf); buf->type = "text/html"; } @@ -7951,7 +7951,7 @@ buf->hmarklist->nmark = 0; if (buf->imarklist) buf->imarklist->nmark = 0; - if (!strcasecmp(buf->type, "text/html")) + if (IS_HTML(buf->type)) loadHTMLBuffer(&uf, buf); else loadBuffer(&uf, buf); diff -burN w3m-0.5.orig/frame.c w3m-0.5/frame.c --- w3m-0.5.orig/frame.c Sat Sep 27 02:59:51 2003 +++ w3m-0.5/frame.c Thu Mar 25 14:08:16 2004 @@ -527,8 +527,7 @@ doc_charset = DocumentCharset; #endif t_stack = 0; - if (frame.body->type && - !strcasecmp(frame.body->type, "text/plain")) { + if (frame.body->type && IS_PLAINTEXT(frame.body->type)) { Str tmp; fprintf(f1, "
\n");
 		    while ((tmp = StrmyUFgets(&f2))->length) {
diff -burN w3m-0.5.orig/main.c w3m-0.5/main.c
--- w3m-0.5.orig/main.c	Mon Mar 22 01:37:08 2004
+++ w3m-0.5/main.c	Thu Mar 25 14:19:25 2004
@@ -4558,7 +4558,7 @@
     }
     if (Currentbuf->sourcefile == NULL) {
 	if (Currentbuf->pagerSource &&
-	    !strcasecmp(Currentbuf->type, "text/plain")) {
+	    IS_PLAINTEXT(Currentbuf->type)) {
 #ifdef USE_M17N
 	    wc_ces old_charset;
 	    wc_bool old_fix_width_conv;
@@ -4590,10 +4590,9 @@
 
     buf = newBuffer(INIT_BUFFER_WIDTH);
 
-    if (!strcasecmp(Currentbuf->type, "text/html")) {
+    if (IS_HTML(Currentbuf->type)) {
 	buf->type = "text/plain";
-	if (Currentbuf->real_type &&
-	    !strcasecmp(Currentbuf->real_type, "text/html"))
+	if (Currentbuf->real_type && IS_HTML(Currentbuf->real_type))
 	    buf->real_type = "text/plain";
 	else
 	    buf->real_type = Currentbuf->real_type;
@@ -4601,10 +4600,10 @@
 	buf->linkBuffer[LB_N_SOURCE] = Currentbuf;
 	Currentbuf->linkBuffer[LB_SOURCE] = buf;
     }
-    else if (!strcasecmp(Currentbuf->type, "text/plain")) {
+    else if (IS_PLAINTEXT(Currentbuf->type)) {
 	buf->type = "text/html";
 	if (Currentbuf->real_type &&
-	    !strcasecmp(Currentbuf->real_type, "text/plain"))
+	    IS_PLAINTEXT(Currentbuf->real_type))
 	    buf->real_type = "text/html";
 	else
 	    buf->real_type = Currentbuf->real_type;
@@ -4740,10 +4739,10 @@
 	Firstbuf = deleteBuffer(Firstbuf, fbuf);
     repBuffer(Currentbuf, buf);
     if ((buf->type != NULL) && (sbuf.type != NULL) &&
-	((!strcasecmp(buf->type, "text/plain") &&
-	  !strcasecmp(sbuf.type, "text/html")) ||
-	 (!strcasecmp(buf->type, "text/html") &&
-	  !strcasecmp(sbuf.type, "text/plain")))) {
+	((IS_PLAINTEXT(buf->type) &&
+	  IS_HTML(sbuf.type)) ||
+	 (IS_HTML(buf->type) &&
+	  IS_PLAINTEXT(sbuf.type)))) {
 	vwSrc();
 	if (Currentbuf != buf)
 	    Firstbuf = deleteBuffer(Firstbuf, buf);
@@ -5062,7 +5061,7 @@
 	return;
     displayImage = TRUE;
     /*
-     * if (!(Currentbuf->type && !strcmp(Currentbuf->type, "text/html")))
+     * if (!(Currentbuf->type && IS_HTML(Currentbuf->type)))
      * return;
      */
     Currentbuf->image_flag = IMG_FLAG_AUTO;
@@ -5075,7 +5074,7 @@
     if (!activeImage)
 	return;
     /*
-     * if (!(Currentbuf->type && !strcmp(Currentbuf->type, "text/html")))
+     * if (!(Currentbuf->type && IS_HTML(Currentbuf->type)))
      * return;
      */
     Currentbuf->image_flag = IMG_FLAG_SKIP;
diff -burN w3m-0.5.orig/myctype.h w3m-0.5/myctype.h
--- w3m-0.5.orig/myctype.h	Tue Sep 23 06:02:20 2003
+++ w3m-0.5/myctype.h	Thu Mar 25 14:08:16 2004
@@ -32,4 +32,9 @@
 #define	TOLOWER(x)	(IS_ALPHA(x) ? ((x)|0x20) : (x))
 #define	TOUPPER(x)	(IS_ALPHA(x) ? ((x)&~0x20) : (x))
 
+#include 
+#define IS_HTML(x)	(!strcasecmp(x, "text/html") || \
+			 !strcasecmp(x, "application/xhtml+xml"))
+#define IS_PLAINTEXT(x)	(!strcasecmp(x, "text/plain"))
+
 #endif
diff -burN w3m-0.5.orig/url.c w3m-0.5/url.c
--- w3m-0.5.orig/url.c	Tue Dec  9 01:17:21 2003
+++ w3m-0.5/url.c	Thu Mar 25 14:21:24 2004
@@ -11,6 +11,7 @@
 #include 
 
 #include 
+#include 
 #ifdef __EMX__
 #include 			/* ?? */
 #endif				/* __EMX__ */
@@ -92,6 +93,10 @@
     {"html", "text/html"},
     {"htm", "text/html"},
     {"shtml", "text/html"},
+    {"xhtml", "application/xhtml+xml"},
+    {"XHTML", "application/xhtml+xml"},
+    {"xht", "application/xhtml+xml"},
+    {"XHT", "application/xhtml+xml"},
     {"gif", "image/gif"},
     {"jpeg", "image/jpeg"},
     {"jpg", "image/jpeg"},
@@ -1269,12 +1274,49 @@
 otherinfo(ParsedURL *target, ParsedURL *current, char *referer)
 {
     Str s = Strnew();
+    char buf[2];
+    char* p = NULL;
+    struct utsname hostinfo;
+    buf[0] = buf[1] = '\0';
 
     Strcat_charp(s, "User-Agent: ");
     if (UserAgent == NULL || *UserAgent == '\0')
 	Strcat_charp(s, w3m_version);
-    else
-	Strcat_charp(s, UserAgent);
+    else {
+	p = UserAgent;
+	while (*p != '\0') {
+	    if (*p == '%') {
+		switch (*(p + 1)) {
+		case 'v': /* w3m version */
+		    Strcat_charp(s, w3m_version);
+		    p++;
+		    break;
+		case 'V': /* OS version */
+		    if (uname(&hostinfo) == 0) {
+			Strcat_charp(s, hostinfo.sysname);
+			buf[0] = ' ';
+			Strcat_charp(s, buf);
+			Strcat_charp(s, hostinfo.release);
+			Strcat_charp(s, buf);
+			Strcat_charp(s, hostinfo.machine);
+			p++;
+		    } else {
+			buf[0] = *p;
+			Strcat_charp(s, buf);
+		    }
+		    break;
+		default: /* thru */
+		    buf[0] = *p;
+		    Strcat_charp(s, buf);
+		    break;
+		}
+	    } else {
+		buf[0] = *p;
+		Strcat_charp(s, buf);
+	    }
+	    p++;
+	}
+    }
     Strcat_charp(s, "\r\n");
 
     Strcat_m_charp(s, "Accept: ", AcceptMedia, "\r\n", NULL);