[prev in list] [next in list] [prev in thread] [next in thread] 

List:       elinks-dev
Subject:    [elinks-dev] [patch] Fix d_opt mangling for no good reason
From:       Jonas Fonseca <fonseca () diku ! dk>
Date:       2003-10-28 15:07:21
Message-ID: 20031028150721.GA28389 () diku ! dk
[Download RAW message or body]

This patch fixes a segfault when pressing login button on freshmeat.net
however I don't know if it breaks form data posting. A far as I can see
encode_multipart() and encode_controls() sets d_opt with the sole
purpose of having d_opt->plain available in convert_string(). What an
ugly way to do it. Instead I've add a new CSM_FORM convert mode so we
can test if CSM_FORM was passed in convert_string().

-- 
Jonas Fonseca

["next.patch" (text/plain)]

Index: intl/charsets.c
===================================================================
RCS file: /home/cvs/elinks/elinks/src/intl/charsets.c,v
retrieving revision 1.63
diff -u -d -r1.63 charsets.c
--- intl/charsets.c	25 Oct 2003 14:41:43 -0000	1.63
+++ intl/charsets.c	28 Oct 2003 15:02:48 -0000
@@ -623,7 +623,7 @@
 			int start = charspos + 1;
 			register int i = start;
 
-			if (d_opt->plain) PUTC;
+			if (d_opt->plain || mode == CSM_FORM) PUTC;
 			while (i < charslen
 			       && ((chars[i] >= 'A' && chars[i] <= 'Z')
 				   || (chars[i] >= 'a' && chars[i] <= 'z')
@@ -635,7 +635,7 @@
 			 * in URL query strings. */
 			/* XXX: But this disables &nbsp&nbsp usage, which
 			 * appears to be relatively common! --pasky */
-			if ((mode != CSM_QUERY || (chars[i] != '&' && chars[i] != '='))
+			if ((mode == CSM_DEFAULT || (chars[i] != '&' && chars[i] != '='))
 			    && i > start && !isalnum(chars[i])) {
 				translit = get_entity_string(&chars[start], i - start,
 						      d_opt->cp);
Index: intl/charsets.h
===================================================================
RCS file: /home/cvs/elinks/elinks/src/intl/charsets.h,v
retrieving revision 1.9
diff -u -d -r1.9 charsets.h
--- intl/charsets.h	21 Aug 2003 13:03:55 -0000	1.9
+++ intl/charsets.h	28 Oct 2003 15:02:48 -0000
@@ -22,6 +22,7 @@
 enum convert_string_mode {
 	CSM_DEFAULT, /* Convert any char. */
 	CSM_QUERY, /* Special handling of '&' and '=' chars. */
+	CSM_FORM, /* Special handling of '&' and '=' chars in forms. */
 };
 
 struct conv_table *get_translation_table(int, int);
Index: viewer/text/form.c
===================================================================
RCS file: /home/cvs/elinks/elinks/src/viewer/text/form.c,v
retrieving revision 1.48
diff -u -d -r1.48 form.c
--- viewer/text/form.c	27 Oct 2003 23:58:31 -0000	1.48
+++ viewer/text/form.c	28 Oct 2003 15:02:49 -0000
@@ -479,11 +479,6 @@
 
 	foreach (sv, *l) {
 		unsigned char *p2 = NULL;
-		struct document_options o;
-
-		memset(&o, 0, sizeof(o));
-		o.plain = 1;
-		d_opt = &o;
 
 		if (lst)
 			add_char_to_string(data, '&');
@@ -504,7 +499,7 @@
 					convert_table = get_translation_table(cp_from, cp_to);
 
 				p2 = convert_string(convert_table, p,
-						    strlen(p), CSM_QUERY);
+						    strlen(p), CSM_FORM);
 				mem_free(p);
 			}
 		} else if (sv->type == FC_TEXT ||
@@ -513,7 +508,7 @@
 				convert_table = get_translation_table(cp_from, cp_to);
 
 			p2 = convert_string(convert_table, sv->value,
-					    strlen(sv->value), CSM_QUERY);
+					    strlen(sv->value), CSM_FORM);
 		} else {
 			p2 = stracpy(sv->value);
 		}
@@ -593,14 +588,8 @@
 			}
 #undef F_BUFLEN
 		} else {
-			struct document_options o;
-
 			add_to_string(data, "\"\r\n\r\n");
 
-			memset(&o, 0, sizeof(o));
-			o.plain = 1;
-			d_opt = &o;
-
 			/* Convert back to original encoding (see
 			 * html_form_control() for the original recoding). */
 			if (sv->type == FC_TEXT || sv->type == FC_PASSWORD ||
@@ -612,7 +601,7 @@
 									      cp_to);
 
 				p = convert_string(convert_table, sv->value,
-						   strlen(sv->value), CSM_QUERY);
+						   strlen(sv->value), CSM_FORM);
 				if (p) {
 					add_to_string(data, p);
 					mem_free(p);


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic