From 8c2f1092f668ca15ff4dc9095f52385c39a87cae Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Tue, 27 Sep 2022 19:54:24 +0200 Subject: [PATCH] [uri] Do not return earlier. Check also POST --- src/ecmascript/spidermonkey/xhr.cpp | 11 ++++++++++ src/protocol/uri.c | 31 +++++++++++++++-------------- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/src/ecmascript/spidermonkey/xhr.cpp b/src/ecmascript/spidermonkey/xhr.cpp index f2543ef2..71849bd2 100644 --- a/src/ecmascript/spidermonkey/xhr.cpp +++ b/src/ecmascript/spidermonkey/xhr.cpp @@ -685,6 +685,17 @@ xhr_send(JSContext *ctx, unsigned int argc, JS::Value *rval) if (xhr->method == POST && argc == 1) { body = jsval_to_string(ctx, args[0]); + xhr->uri->post = body; + char *url2 = get_uri_string(xhr->uri, URI_DIR_LOCATION | URI_PATH | URI_USER | URI_PASSWORD | URI_POST); + + if (!url2) { + mem_free(body); + return false; + } + done_uri(xhr->uri); + xhr->uri = get_uri(url2, URI_DIR_LOCATION | URI_PATH | URI_USER | URI_PASSWORD | URI_POST); + mem_free(url2); + mem_free(body); } xhr->download.data = xhr; xhr->download.callback = (download_callback_T *)xhr_loading_callback; diff --git a/src/protocol/uri.c b/src/protocol/uri.c index 9d843503..2b4f5464 100644 --- a/src/protocol/uri.c +++ b/src/protocol/uri.c @@ -618,25 +618,26 @@ add_uri_to_string(struct string *string, const struct uri *uri, add_char_to_string(string, '/'); } - if (!uri->datalen) return string; + if (uri->datalen) { - if (uri->protocol == PROTOCOL_DATA) { - char *e; - add_to_string(string, "data"); - e = get_extension_from_uri((struct uri *) uri); + if (uri->protocol == PROTOCOL_DATA) { + char *e; + add_to_string(string, "data"); + e = get_extension_from_uri((struct uri *) uri); - if (e) { - add_to_string(string, e); - mem_free(e); + if (e) { + add_to_string(string, e); + mem_free(e); + } + return string; } - return string; + + for (pos = filename; *pos && !end_of_dir(*pos); pos++) + if (wants(URI_FILENAME) && is_uri_dir_sep(uri, *pos)) + filename = pos + 1; + + add_bytes_to_string(string, filename, pos - filename); } - - for (pos = filename; *pos && !end_of_dir(*pos); pos++) - if (wants(URI_FILENAME) && is_uri_dir_sep(uri, *pos)) - filename = pos + 1; - - return add_bytes_to_string(string, filename, pos - filename); } if (wants(URI_QUERY) && uri->datalen) {