fix potential issue with local flashroms
This commit is contained in:
@@ -22,10 +22,10 @@ if (request_headers.query.raw || bf0app_update) {
|
|||||||
sendToClient(socket, headers, data);
|
sendToClient(socket, headers, data);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
headers = "200 OK\n"
|
|
||||||
if (request_headers.query.path) {
|
if (request_headers.query.path) {
|
||||||
headers += "Content-type: text/html\n"
|
headers = "200 OK\n"
|
||||||
headers += "wtv-visit: " + service_name + ":/initiate-lc2-download?path=" + request_headers.query.path;
|
headers += "wtv-visit: " + service_name + ":/initiate-lc2-download?path=" + request_headers.query.path + "\n";
|
||||||
|
headers += "Content-type: text/html"
|
||||||
data = '';
|
data = '';
|
||||||
} else {
|
} else {
|
||||||
var errpage = doErrorPage(404)
|
var errpage = doErrorPage(404)
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ async function processLC2DownloadPage(path, flashrom_info, numparts = null) {
|
|||||||
if (numparts != null) flashrom_info.part_count = parseInt(numparts);
|
if (numparts != null) flashrom_info.part_count = parseInt(numparts);
|
||||||
if (!flashrom_info.part_count) flashrom_info.part_count = parseInt(flashrom_info.message.substring(flashrom_info.message.length - 4).replace(/\D/g, ''));
|
if (!flashrom_info.part_count) flashrom_info.part_count = parseInt(flashrom_info.message.substring(flashrom_info.message.length - 4).replace(/\D/g, ''));
|
||||||
if (!flashrom_info.part_number || !flashrom_info.is_last_part || !flashrom_info.rompath || !flashrom_info.next_rompath || !flashrom_info.is_bootrom) {
|
if (!flashrom_info.part_number || !flashrom_info.is_last_part || !flashrom_info.rompath || !flashrom_info.next_rompath || !flashrom_info.is_bootrom) {
|
||||||
if (!flashrom_info.is_last_part) {
|
if (!flashrom_info.is_last_part || request_headers.query.last_part) {
|
||||||
flashrom_info.next_rompath = request_headers.request_url.replace(escape(request_headers.query.path), escape(flashrom_info.next_rompath.replace(service_name+":/","")));
|
flashrom_info.next_rompath = request_headers.request_url.replace(escape(request_headers.query.path), escape(flashrom_info.next_rompath.replace(service_name+":/","")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,9 +5,8 @@ var romtype = ssid_sessions[socket.ssid].get("wtv-client-rom-type");
|
|||||||
url = "client:updateflash?ipaddr=" + minisrv_config.services[service_name].host + "&port=" + minisrv_config.services[service_name].port + "&path=" + escape(service_name + ":/" +request_headers.query.path);
|
url = "client:updateflash?ipaddr=" + minisrv_config.services[service_name].host + "&port=" + minisrv_config.services[service_name].port + "&path=" + escape(service_name + ":/" +request_headers.query.path);
|
||||||
if (request_headers.query.numparts) url += escape("&numparts=" + request_headers.query.numparts);
|
if (request_headers.query.numparts) url += escape("&numparts=" + request_headers.query.numparts);
|
||||||
}
|
}
|
||||||
headers = "300 OK\n";
|
headers = "200 OK\n";
|
||||||
headers += "wtv-visit: " + url + "\n";
|
headers += "wtv-visit: " + url + "\n";
|
||||||
headers += "Location: " + url + "\n";
|
|
||||||
headers += "Content-type: text/html";
|
headers += "Content-type: text/html";
|
||||||
data = '';
|
data = '';
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class WTVFlashrom {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async doLocalFlashROM(flashrom_file_path, callback, info_only = false) {
|
async doLocalFlashROM(flashrom_file_path, request_path, callback, info_only = false) {
|
||||||
// use local flashrom files;
|
// use local flashrom files;
|
||||||
console.log(info_only);
|
console.log(info_only);
|
||||||
var self = this;
|
var self = this;
|
||||||
@@ -56,7 +56,7 @@ class WTVFlashrom {
|
|||||||
callback(data, headers);
|
callback(data, headers);
|
||||||
} else {
|
} else {
|
||||||
if (info_only) {
|
if (info_only) {
|
||||||
callback(self.getFlashromData(data, flashrom_file_path));
|
callback(self.getFlashromInfo(data, request_path));
|
||||||
} else {
|
} else {
|
||||||
self.sendToClient(data, flashrom_file_path, callback);
|
self.sendToClient(data, flashrom_file_path, callback);
|
||||||
}
|
}
|
||||||
@@ -202,7 +202,7 @@ class WTVFlashrom {
|
|||||||
});
|
});
|
||||||
req.end();
|
req.end();
|
||||||
} else {
|
} else {
|
||||||
this.doLocalFlashROM(flashrom_file_path, callback, ((length != 0) ? true : false));
|
this.doLocalFlashROM(flashrom_file_path, request_path, callback, ((length != 0) ? true : false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user