fix http security leak

fork-master
Emojigit 2021-12-06 19:58:50 +08:00
parent e4fdfa60bf
commit 4fe069abac
No known key found for this signature in database
GPG Key ID: 2443E5F619026B90
2 changed files with 6 additions and 4 deletions

View File

@ -1,3 +1,4 @@
local http = core.request_http_api()
local make_fs = i3.files.gui()
IMPORT("gmatch", "split")
@ -22,13 +23,13 @@ function i3.register_craft(def)
local width, c = 0, 0
if true_str(def.url) then
if not i3.http then
if not http then
return err(fmt([[i3.register_craft(): Unable to reach %s.
No HTTP support for this mod: add it to the `secure.http_mods` or
`secure.trusted_mods` setting.]], def.url))
end
i3.http.fetch({url = def.url}, function(result)
http.fetch({url = def.url}, function(result)
if result.succeeded then
local t = core.parse_json(result.data)
if is_table(t) then

View File

@ -1,3 +1,4 @@
local http = core.request_http_api()
local replacements = {fuel = {}}
IMPORT("maxn", "copy", "insert", "sort", "match", "sub")
@ -269,13 +270,13 @@ local function init_recipes()
resolve_aliases(_select)
sort(i3.init_items)
if i3.http and true_str(i3.export_url) then
if http and true_str(i3.export_url) then
local post_data = {
recipes = i3.recipes_cache,
usages = i3.usages_cache,
}
i3.http.fetch_async {
http.fetch_async {
url = i3.export_url,
post_data = core.write_json(post_data),
}