about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorThomas E. Dickey <dickey@invisible-island.net>2014-02-13 19:39:36 -0500
committerThomas E. Dickey <dickey@invisible-island.net>2014-02-13 19:39:36 -0500
commit0c867413a08246fd7923ef5339675e7218dbb059 (patch)
treeddabd2fd491e634c864f4906e0d462a4588804f3
parent5f1307fdb4466cc4a76a6ca9f46e0399ec0459bc (diff)
downloadlynx-snapshots-0c867413a08246fd7923ef5339675e7218dbb059.tar.gz
snapshot of project "lynx", label v2-8-8pre_4e
-rw-r--r--CHANGES8
-rw-r--r--WWW/Library/Implementation/HTFile.c91
-rw-r--r--src/GridText.c20
-rw-r--r--src/LYUtils.c3
4 files changed, 89 insertions, 33 deletions
diff --git a/CHANGES b/CHANGES
index e79277a9..e0c1811b 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,10 +1,14 @@
--- $LynxId: CHANGES,v 1.734 2014/02/13 13:22:22 tom Exp $
+-- $LynxId: CHANGES,v 1.736 2014/02/13 19:39:36 tom Exp $
 ===============================================================================
 Changes since Lynx 2.8 release
 ===============================================================================
 
-2014-02-14 (2.8.8rel.1)
 2014-02-14 (2.8.8pre.5)
+* trim unexpected query-parameters from file: URIs when checking for their
+  presentation and compression types.  Not all browsers do this, etc. -TD
+* modify forms-submit to trim query-parameters from the action URI if it
+  happens to be a file-URL.  IE and some other browsers do this. The RFCs
+  do not mention this since forms are an HTTP feature (Debian #738121) -TD
 * reviewed command-line options which were not provided in lynx.cfg; added
   others which could be useful for dumps (i.e., force_html, hiddenlinks,
   listonly, list_inline, localhost, short_url, with_backspaces) -TD:
diff --git a/WWW/Library/Implementation/HTFile.c b/WWW/Library/Implementation/HTFile.c
index 8882ba77..9eae85de 100644
--- a/WWW/Library/Implementation/HTFile.c
+++ b/WWW/Library/Implementation/HTFile.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: HTFile.c,v 1.139 2013/11/28 11:33:56 tom Exp $
+ * $LynxId: HTFile.c,v 1.142 2014/02/13 18:30:01 tom Exp $
  *
  *			File Access				HTFile.c
  *			===========
@@ -173,6 +173,16 @@ static HTSuffix unknown_suffix =
 static void free_suffixes(void);
 #endif
 
+static char *FindSearch(const char *filename)
+{
+    char *result = 0;
+
+    if ((result = strchr(filename, '?')) == 0) {
+	result = strstr(filename, "%3F");
+    }
+    return result;
+}
+
 #ifdef LONG_LIST
 static char *FormatStr(char **bufp,
 		       char *start,
@@ -886,9 +896,21 @@ HTFormat HTFileFormat(const char *filename,
     int n;
     int i;
     int lf;
+    char *search;
 
     VMS_DEL_VERSION(filename);
 
+    if ((search = FindSearch(filename)) != 0) {
+	char *newname = NULL;
+	HTFormat result;
+
+	StrAllocCopy(newname, filename);
+	*(FindSearch(newname)) = '\0';
+	result = HTFileFormat(newname, pencoding, pdesc);
+	free(newname);
+	return result;
+    }
+
     if (pencoding)
 	*pencoding = NULL;
     if (pdesc)
@@ -1240,37 +1262,50 @@ CompressFileType HTCompressFileType(const char *filename,
 				    int *rootlen)
 {
     CompressFileType result = cftNone;
-    size_t len = strlen(filename);
-    const char *ftype = filename + len;
+    char *search;
 
-    VMS_DEL_VERSION(filename);
+    if ((search = FindSearch(filename)) != 0) {
+	char *newname = NULL;
 
-    if ((len > 4)
-	&& !strcasecomp((ftype - 3), "bz2")
-	&& StrChr(dots, ftype[-4]) != 0) {
-	result = cftBzip2;
-	ftype -= 4;
-    } else if ((len > 3)
-	       && !strcasecomp((ftype - 2), "gz")
-	       && StrChr(dots, ftype[-3]) != 0) {
-	result = cftGzip;
-	ftype -= 3;
-    } else if ((len > 3)
-	       && !strcasecomp((ftype - 2), "zz")
-	       && StrChr(dots, ftype[-3]) != 0) {
-	result = cftDeflate;
-	ftype -= 3;
-    } else if ((len > 2)
-	       && !strcmp((ftype - 1), "Z")
-	       && StrChr(dots, ftype[-2]) != 0) {
-	result = cftCompress;
-	ftype -= 2;
-    }
+	StrAllocCopy(newname, filename);
+	newname[((const char *) search) - filename] = '\0';
+	result = HTCompressFileType(newname, dots, rootlen);
+	free(newname);
+    } else {
+	size_t len;
+	const char *ftype;
+
+	VMS_DEL_VERSION(filename);
+	len = strlen(filename);
+	ftype = filename + len;
+
+	if ((len > 4)
+	    && !strcasecomp((ftype - 3), "bz2")
+	    && StrChr(dots, ftype[-4]) != 0) {
+	    result = cftBzip2;
+	    ftype -= 4;
+	} else if ((len > 3)
+		   && !strcasecomp((ftype - 2), "gz")
+		   && StrChr(dots, ftype[-3]) != 0) {
+	    result = cftGzip;
+	    ftype -= 3;
+	} else if ((len > 3)
+		   && !strcasecomp((ftype - 2), "zz")
+		   && StrChr(dots, ftype[-3]) != 0) {
+	    result = cftDeflate;
+	    ftype -= 3;
+	} else if ((len > 2)
+		   && !strcmp((ftype - 1), "Z")
+		   && StrChr(dots, ftype[-2]) != 0) {
+	    result = cftCompress;
+	    ftype -= 2;
+	}
 
-    *rootlen = (int) (ftype - filename);
+	*rootlen = (int) (ftype - filename);
 
-    CTRACE((tfp, "HTCompressFileType(%s) returns %d:%s\n",
-	    filename, (int) result, filename + *rootlen));
+	CTRACE((tfp, "HTCompressFileType(%s) returns %d:%s\n",
+		filename, (int) result, filename + *rootlen));
+    }
     return result;
 }
 
diff --git a/src/GridText.c b/src/GridText.c
index 6a172ebf..f447a5dc 100644
--- a/src/GridText.c
+++ b/src/GridText.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: GridText.c,v 1.274 2013/11/28 11:16:50 tom Exp $
+ * $LynxId: GridText.c,v 1.277 2014/02/13 19:32:01 tom Exp $
  *
  *		Character grid hypertext object
  *		===============================
@@ -11114,6 +11114,7 @@ int HText_SubmitForm(FormInfo * submit_item, DocInfo *doc,
 	 */
 	StrAllocCat(temp, "?");
 	BStrCat0(my_query, temp);
+	free(temp);
     } else {
 	/*
 	 * We are submitting POST content to a server,
@@ -11797,6 +11798,20 @@ int HText_SubmitForm(FormInfo * submit_item, DocInfo *doc,
     } else {
 	_statusline(SUBMITTING_FORM);
 
+	/*
+	 * File-URLs (whether via GET or POST) cannot provide search queries. 
+	 * The relevant RFCs 1630, 1738 are silent on what to do with
+	 * unexpected query parameters in a file-URL.
+	 *
+	 * Internet Explorer trims the query string here (after all, a "?" is
+	 * not a legal part of a Windows filename), and other browsers copy the
+	 * behavior.  We do this for compatibility, in case someone cares.
+	 */
+	if (my_query != 0 &&
+	    my_query->len > 5 &&
+	    !strncmp(my_query->str, "file:", 5)) {
+	    strtok(my_query->str, "?");
+	}
 	if (submit_item->submit_method == URL_POST_METHOD || Boundary) {
 	    LYFreePostData(doc);
 	    doc->post_data = my_query;
@@ -11805,9 +11820,10 @@ int HText_SubmitForm(FormInfo * submit_item, DocInfo *doc,
 	    StrAllocCopy(doc->address, submit_item->submit_action);
 	} else {		/* GET_METHOD */
 	    HTSABCat(&my_query, "", 1);		/* append null */
-	    StrAllocCopy(doc->address, BStrData(my_query));	/* FIXME? */
+	    StrAllocCopy(doc->address, BStrData(my_query));
 	    LYFreePostData(doc);
 	    FREE(content_type_out);
+	    HTSABFree(&my_query);
 	}
 	result = 1;
     }
diff --git a/src/LYUtils.c b/src/LYUtils.c
index 07590801..b2649a7f 100644
--- a/src/LYUtils.c
+++ b/src/LYUtils.c
@@ -1,5 +1,5 @@
 /*
- * $LynxId: LYUtils.c,v 1.264 2014/02/03 00:17:39 tom Exp $
+ * $LynxId: LYUtils.c,v 1.265 2014/02/13 19:35:39 tom Exp $
  */
 #include <HTUtils.h>
 #include <HTTCP.h>
@@ -2857,6 +2857,7 @@ char *LYFindConfigFile(const char *nominal, const char *dftfile)
 	    while ((item = LYstrsep(&path, PATH_SEPARATOR)) != 0) {
 		if (isEmpty(item))
 		    continue;
+		FREE(result);
 		HTSprintf0(&result, "%s%s%s", item, FILE_SEPARATOR, nominal);
 		LYTildeExpand(&result, TRUE);
 		if (LYCanReadFile(result)) {