url encoding
This commit is contained in:
@@ -53,7 +53,7 @@ module.exports = {
|
|||||||
loadMacrosGcode: async function () {
|
loadMacrosGcode: async function () {
|
||||||
const file = this.selectedValues[this.tab - 1];
|
const file = this.selectedValues[this.tab - 1];
|
||||||
if (this.selectedValues[this.tab - 1] != "default") {
|
if (this.selectedValues[this.tab - 1] != "default") {
|
||||||
const response = await fetch(`/api/file/{%MACROS%}${file}`, {
|
const response = await fetch(`/api/file/%7B%MACROS%7D${file}`, {
|
||||||
cache: "no-cache",
|
cache: "no-cache",
|
||||||
});
|
});
|
||||||
const text = (await response.text()).split(" ").join("\n");
|
const text = (await response.text()).split(" ").join("\n");
|
||||||
|
|||||||
@@ -80,11 +80,13 @@ class FileHandler(bbctrl.APIHandler):
|
|||||||
'FileName: ' + filename)
|
'FileName: ' + filename)
|
||||||
if not filename:
|
if not filename:
|
||||||
raise HTTPError(400, 'Missing filename')
|
raise HTTPError(400, 'Missing filename')
|
||||||
if filename.startswith('/{%MACROS%}'):
|
if filename.startswith('/%7B%MACROS%7D'):
|
||||||
filebasename = os.path.basename(url_unescape(filename.replace("{%MACROS%}", "")))
|
filebasename = os.path.basename(url_unescape(filename.replace("%7B%MACROS%7D", "")))
|
||||||
else:
|
else:
|
||||||
filebasename = os.path.basename(url_unescape(filename))
|
filebasename = os.path.basename(url_unescape(filename))
|
||||||
|
|
||||||
|
self.get_log('FileHandler').info(
|
||||||
|
'FileBaseName: ' + filebasename)
|
||||||
try:
|
try:
|
||||||
with open(self.get_upload(filebasename).encode('utf8'), 'r') as f:
|
with open(self.get_upload(filebasename).encode('utf8'), 'r') as f:
|
||||||
self.write(f.read())
|
self.write(f.read())
|
||||||
@@ -92,5 +94,5 @@ class FileHandler(bbctrl.APIHandler):
|
|||||||
self.get_ctrl().state.select_file('')
|
self.get_ctrl().state.select_file('')
|
||||||
raise HTTPError(
|
raise HTTPError(
|
||||||
400, "Unable to read file - doesn't appear to be GCode.")
|
400, "Unable to read file - doesn't appear to be GCode.")
|
||||||
if not filename.startswith('/{%MACROS%}'):
|
if not filename.startswith('/%7B%MACROS%7D'):
|
||||||
self.get_ctrl().state.select_file(filebasename)
|
self.get_ctrl().state.select_file(filebasename)
|
||||||
|
|||||||
Reference in New Issue
Block a user