1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

Apply form history to fs->value, not fc->default_value.

I am going make fc->default_value use the charset of the document, and
recoding the string from the form history to that might lose characters.

This change also affects what ECMAScript sees in the defaultValue property.
<http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109/html.html#ID-26091157>
says it should represent the HTML "value" attribute, so changing it
based on form history is not appropriate.
This commit is contained in:
Kalle Olavi Niemitalo 2007-04-29 21:39:28 +03:00 committed by Kalle Olavi Niemitalo
parent 487a047264
commit 0df5b7fdf5

View File

@ -160,9 +160,16 @@ init_form_state(struct form_control *fc, struct form_state *fs)
switch (fc->type) {
case FC_TEXT:
case FC_PASSWORD:
#ifdef CONFIG_FORMHIST
fs->value = null_or_stracpy(
get_form_history_value(
fc->form->action, fc->name));
#endif /* CONFIG_FORMHIST */
/* fall through */
case FC_TEXTAREA:
fs->value = stracpy(fc->default_value);
fs->state = strlen(fc->default_value);
if (fs->value == NULL)
fs->value = stracpy(fc->default_value);
fs->state = fs->value ? strlen(fs->value) : 0;
#ifdef CONFIG_UTF8
if (fc->type == FC_TEXTAREA)
fs->state_cell = 0;
@ -577,18 +584,6 @@ draw_forms(struct terminal *term, struct document_view *doc_view)
struct form_control *fc = get_link_form_control(l1);
if (!fc) continue;
#ifdef CONFIG_FORMHIST
if (fc->type == FC_TEXT || fc->type == FC_PASSWORD) {
unsigned char *value;
assert(fc->form);
value = get_form_history_value(fc->form->action, fc->name);
if (value)
mem_free_set(&fc->default_value,
stracpy(value));
}
#endif /* CONFIG_FORMHIST */
draw_form_entry(term, doc_view, l1);
} while (l1++ < l2);