mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
smjs_load_uri: return if there is an external handler
Currently, using smjs_load_uri on javascript: URIs cause an assertion failure in run_connection because smjs_load_uri uses get_protocol_handler to find the handler and asserts that the returned handler is not NULL, but get_protocol_handler returns NULL for javascript: URIs. In smjs_load_uri, if the given URI has a protocol for which some external handler is defined, immediately return JS_FALSE because smjs_load_uri implements an asynchronous operation, and we cannot reasonably carry out the operation and callback with an external handler.
This commit is contained in:
parent
bdeace4811
commit
da209c6b6f
@ -9,6 +9,7 @@
|
|||||||
#include "ecmascript/spidermonkey-shared.h"
|
#include "ecmascript/spidermonkey-shared.h"
|
||||||
#include "network/connection.h"
|
#include "network/connection.h"
|
||||||
#include "protocol/uri.h"
|
#include "protocol/uri.h"
|
||||||
|
#include "protocol/protocol.h"
|
||||||
#include "scripting/smjs/core.h"
|
#include "scripting/smjs/core.h"
|
||||||
#include "scripting/smjs/cache_object.h"
|
#include "scripting/smjs/cache_object.h"
|
||||||
#include "scripting/smjs/elinks_object.h"
|
#include "scripting/smjs/elinks_object.h"
|
||||||
@ -70,6 +71,7 @@ smjs_load_uri(JSContext *ctx, uintN argc, jsval *rval)
|
|||||||
struct smjs_load_uri_hop *hop;
|
struct smjs_load_uri_hop *hop;
|
||||||
struct download *download;
|
struct download *download;
|
||||||
JSString *jsstr;
|
JSString *jsstr;
|
||||||
|
protocol_external_handler_T *external_handler;
|
||||||
unsigned char *uri_string;
|
unsigned char *uri_string;
|
||||||
struct uri *uri;
|
struct uri *uri;
|
||||||
|
|
||||||
@ -81,6 +83,14 @@ smjs_load_uri(JSContext *ctx, uintN argc, jsval *rval)
|
|||||||
uri = get_uri(uri_string, 0);
|
uri = get_uri(uri_string, 0);
|
||||||
if (!uri) return JS_FALSE;
|
if (!uri) return JS_FALSE;
|
||||||
|
|
||||||
|
external_handler = get_protocol_external_handler(NULL, uri);
|
||||||
|
if (external_handler) {
|
||||||
|
/* Because smjs_load_uri is carrying out an asynchronous
|
||||||
|
* operation, it is inappropriate to call an external
|
||||||
|
* handler here, so just return. */
|
||||||
|
return JS_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
download = mem_alloc(sizeof(*download));
|
download = mem_alloc(sizeof(*download));
|
||||||
if (!download) {
|
if (!download) {
|
||||||
done_uri(uri);
|
done_uri(uri);
|
||||||
|
Loading…
Reference in New Issue
Block a user