Fix missing bounds checks, unsafe JSON.parse, and cleanup issues
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -525,13 +525,14 @@ const openMore = async (no) => {
|
|||||||
// Use async/await to prevent errors caused by asynchronous data not being available yet
|
// Use async/await to prevent errors caused by asynchronous data not being available yet
|
||||||
issuesNo.value = no;
|
issuesNo.value = no;
|
||||||
await conformanceStore.getConformanceIssue(no);
|
await conformanceStore.getConformanceIssue(no);
|
||||||
traceId.value = await issueTraces.value[0].id;
|
if (issueTraces.value.length === 0) return;
|
||||||
|
traceId.value = issueTraces.value[0].id;
|
||||||
firstCases.value = await conformanceStore.getConformanceTraceDetail(
|
firstCases.value = await conformanceStore.getConformanceTraceDetail(
|
||||||
no,
|
no,
|
||||||
issueTraces.value[0].id,
|
issueTraces.value[0].id,
|
||||||
0,
|
0,
|
||||||
);
|
);
|
||||||
issuesModal.value = await true;
|
issuesModal.value = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -542,13 +543,14 @@ const openLoopMore = async (no) => {
|
|||||||
// Use async/await to prevent errors caused by asynchronous data not being available yet
|
// Use async/await to prevent errors caused by asynchronous data not being available yet
|
||||||
loopNo.value = no;
|
loopNo.value = no;
|
||||||
await conformanceStore.getConformanceLoop(no);
|
await conformanceStore.getConformanceLoop(no);
|
||||||
looptraceId.value = await loopTraces.value[0].id;
|
if (loopTraces.value.length === 0) return;
|
||||||
|
looptraceId.value = loopTraces.value[0].id;
|
||||||
loopFirstCases.value = await conformanceStore.getConformanceLoopsTraceDetail(
|
loopFirstCases.value = await conformanceStore.getConformanceLoopsTraceDetail(
|
||||||
no,
|
no,
|
||||||
loopTraces.value[0].id,
|
loopTraces.value[0].id,
|
||||||
0,
|
0,
|
||||||
);
|
);
|
||||||
loopModal.value = await true;
|
loopModal.value = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -73,11 +73,17 @@ export const useCytoscapeStore = defineStore('cytoscapeStore', {
|
|||||||
* @param {string} direction - Layout direction ('TB' or 'LR').
|
* @param {string} direction - Layout direction ('TB' or 'LR').
|
||||||
*/
|
*/
|
||||||
loadPositionsFromStorage(direction: string) {
|
loadPositionsFromStorage(direction: string) {
|
||||||
if (localStorage.getItem(SAVE_KEY_NAME) &&
|
try {
|
||||||
JSON.parse(
|
const raw = localStorage.getItem(SAVE_KEY_NAME);
|
||||||
localStorage.getItem(SAVE_KEY_NAME))[this.currentGraphId]) {
|
if (raw) {
|
||||||
this.nodePositions[this.currentGraphId][direction] = JSON.parse(
|
const parsed = JSON.parse(raw);
|
||||||
localStorage.getItem(SAVE_KEY_NAME))[this.currentGraphId][direction];
|
if (parsed[this.currentGraphId]) {
|
||||||
|
this.nodePositions[this.currentGraphId][direction] =
|
||||||
|
parsed[this.currentGraphId][direction];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// Corrupted localStorage data; ignore and use defaults
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -174,8 +174,10 @@ export const useFilesStore = defineStore("filesStore", {
|
|||||||
// msg: 'not in UTF-8' | 'insufficient columns' | 'the csv file is empty' | 'the filename does not ends with .csv'
|
// msg: 'not in UTF-8' | 'insufficient columns' | 'the csv file is empty' | 'the filename does not ends with .csv'
|
||||||
// type: 'encoding' | 'insufficient_columns' | 'empty' | 'name_suffix'
|
// type: 'encoding' | 'insufficient_columns' | 'empty' | 'name_suffix'
|
||||||
const detail = error.response.data.detail;
|
const detail = error.response.data.detail;
|
||||||
|
if (Array.isArray(detail) && detail.length > 0) {
|
||||||
uploadFailedFirst(detail[0].type, detail[0].msg, detail[0].loc[2]);
|
const loc = detail[0].loc;
|
||||||
|
uploadFailedFirst(detail[0].type, detail[0].msg, Array.isArray(loc) && loc.length > 2 ? loc[2] : undefined);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Swal.close(); // Close the loading progress bar
|
Swal.close(); // Close the loading progress bar
|
||||||
apiError(error, "Failed to upload the files.");
|
apiError(error, "Failed to upload the files.");
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ export const useMapPathStore = defineStore('mapPathStore', {
|
|||||||
if (listIndex >= curButton.length) { // Bounds check to prevent out-of-range access
|
if (listIndex >= curButton.length) { // Bounds check to prevent out-of-range access
|
||||||
return; // nodeIndex is the path index in the list after selecting one of the five buttons
|
return; // nodeIndex is the path index in the list after selecting one of the five buttons
|
||||||
}
|
}
|
||||||
if (nodeIndex >= curButton[listIndex]) { // Bounds check to prevent out-of-range access
|
if (nodeIndex >= curButton[listIndex].length) { // Bounds check to prevent out-of-range access
|
||||||
return; // The node index within this path in the list
|
return; // The node index within this path in the list
|
||||||
}
|
}
|
||||||
// If `curPath` and `curButton[listIndex]` fully match
|
// If `curPath` and `curButton[listIndex]` fully match
|
||||||
|
|||||||
Reference in New Issue
Block a user