Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions quickjs-libc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1274,7 +1274,7 @@ static JSValue js_std_file_putByte(JSContext *ctx, JSValueConst this_val,

/* urlGet */

#define URL_GET_PROGRAM "curl -s -i"
#define URL_GET_PROGRAM "curl -s -i --"
#define URL_GET_BUF_SIZE 4096

static int http_get_header_line(FILE *f, char *buf, size_t buf_size,
Expand Down Expand Up @@ -1347,16 +1347,22 @@ static JSValue js_std_urlGet(JSContext *ctx, JSValueConst this_val,
}

js_std_dbuf_init(ctx, &cmd_buf);
dbuf_printf(&cmd_buf, "%s ''", URL_GET_PROGRAM);
dbuf_printf(&cmd_buf, "%s '", URL_GET_PROGRAM);
len = strlen(url);
for(i = 0; i < len; i++) {
c = url[i];
if (c == '\'' || c == '\\')
switch (c = url[i]) {
case '\'':
dbuf_putstr(&cmd_buf, "'\\''");
break;
case '[': case ']': case '{': case '}': case '\\':
dbuf_putc(&cmd_buf, '\\');
dbuf_putc(&cmd_buf, c);
/* FALLTHROUGH */
default:
dbuf_putc(&cmd_buf, c);
}
}
JS_FreeCString(ctx, url);
dbuf_putstr(&cmd_buf, "''");
dbuf_putstr(&cmd_buf, "'");
dbuf_putc(&cmd_buf, '\0');
if (dbuf_error(&cmd_buf)) {
dbuf_free(&cmd_buf);
Expand Down