mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-22 20:16:54 +03:00
In theory, store raw filenames and pass them through for file upload. Untested due to no file-upload in GTK frontend just yet
This commit is contained in:
parent
6c63adb1c1
commit
581d877576
@ -665,6 +665,8 @@ void fetch_multipart_data_destroy(struct fetch_multipart_data *list)
|
||||
next = list->next;
|
||||
free(list->name);
|
||||
free(list->value);
|
||||
if (list->file)
|
||||
free(list->rawfile);
|
||||
free(list);
|
||||
}
|
||||
}
|
||||
|
@ -79,6 +79,7 @@ struct fetch_multipart_data {
|
||||
bool file; /**< Item is a file */
|
||||
char *name; /**< Name of item */
|
||||
char *value; /**< Item value */
|
||||
char *rawfile; /**< Raw filename if file is true */
|
||||
|
||||
struct fetch_multipart_data *next; /**< Next in linked list */
|
||||
};
|
||||
|
@ -1301,7 +1301,7 @@ fetch_curl_post_convert(const struct fetch_multipart_data *control)
|
||||
char *mimetype = fetch_mimetype(control->value);
|
||||
code = curl_formadd(&post, &last,
|
||||
CURLFORM_COPYNAME, control->name,
|
||||
CURLFORM_FILE, control->value,
|
||||
CURLFORM_FILE, control->rawfile,
|
||||
CURLFORM_FILENAME, leafname,
|
||||
CURLFORM_CONTENTTYPE,
|
||||
(mimetype != 0 ? mimetype : "text/plain"),
|
||||
|
@ -50,6 +50,7 @@
|
||||
#include "render/html.h"
|
||||
#include "render/html_internal.h"
|
||||
#include "render/layout.h"
|
||||
#include "utils/corestrings.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/messages.h"
|
||||
#include "utils/talloc.h"
|
||||
@ -346,7 +347,7 @@ bool form_successful_controls(struct form *form,
|
||||
struct fetch_multipart_data sentinel, *last_success, *success_new;
|
||||
char *value = NULL;
|
||||
bool had_submit = false;
|
||||
char *charset;
|
||||
char *charset, *rawfile_temp;
|
||||
|
||||
last_success = &sentinel;
|
||||
sentinel.next = NULL;
|
||||
@ -598,6 +599,28 @@ bool form_successful_controls(struct form *form,
|
||||
goto no_memory;
|
||||
}
|
||||
|
||||
/* Retrieve the filename from the DOM annotation */
|
||||
if (dom_node_get_user_data(
|
||||
control->node,
|
||||
corestring_dom___ns_key_file_name_node_data,
|
||||
&rawfile_temp) != DOM_NO_ERR) {
|
||||
LOG(("unable to get rawfile"));
|
||||
goto no_memory;
|
||||
}
|
||||
|
||||
if (rawfile_temp == NULL) {
|
||||
/* No annotation means the file was not
|
||||
*/
|
||||
success_new->rawfile = strdup("");
|
||||
} else {
|
||||
success_new->rawfile = strdup(rawfile_temp);
|
||||
}
|
||||
|
||||
if (success_new->rawfile == NULL) {
|
||||
LOG(("strdup failed"));
|
||||
goto no_memory;
|
||||
}
|
||||
|
||||
continue;
|
||||
break;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user