This issue was found during a Codex global code scan of the repository.
Baseline commit: e3c5b38
Problem
The custom template import path assumes a file is selected and that its contents are valid JSON. Both reader.readAsText(this.file[0]) and JSON.parse(e.target.result) are unguarded.
Code references:
|
add: function () { |
|
const name = this.name; |
|
const that = this; |
|
const reader = new FileReader(); |
|
reader.onload = function (e) { |
|
const hash = require("crypto") |
|
.createHash("sha256") |
|
.update(e.target.result) |
|
.digest("hex"); |
|
const obj = JSON.parse(e.target.result); |
|
const curr = that.$storage.getStorageSync("CustomTemplate") || {}; |
|
curr[hash] = { |
|
name: name, |
|
obj: obj, |
|
}; |
|
that.$storage.setStorageSync("CustomTemplate", curr); |
|
that.$router.push("/input"); |
|
that.$root.$app.update_navi(); |
|
}; |
|
reader.readAsText(this.file[0]); |
Relevant snippet:
const obj = JSON.parse(e.target.result);
reader.readAsText(this.file[0]);
Impact
Clicking Add without selecting a file, or selecting malformed JSON, throws an uncaught browser error instead of giving a recoverable UI error.
Suggested fix
Disable Add until a file is selected, wrap JSON parsing in try/catch, handle FileReader.onerror, and show a validation message instead of navigating away.
This issue was found during a Codex global code scan of the repository.
Baseline commit: e3c5b38
Problem
The custom template import path assumes a file is selected and that its contents are valid JSON. Both
reader.readAsText(this.file[0])andJSON.parse(e.target.result)are unguarded.Code references:
dpgui/src/views/NewConfig.vue
Lines 30 to 49 in e3c5b38
Relevant snippet:
Impact
Clicking Add without selecting a file, or selecting malformed JSON, throws an uncaught browser error instead of giving a recoverable UI error.
Suggested fix
Disable Add until a file is selected, wrap JSON parsing in
try/catch, handleFileReader.onerror, and show a validation message instead of navigating away.