Skip to content

Commit 8f45134

Browse files
Potential fix for code scanning alert no. 1654: Incomplete string escaping or encoding
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent eb34429 commit 8f45134

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

studio/src/main/resources/static/js/studio-record-editor.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ function openRecordEditor(rid, type, properties, source) {
2323
showGraphRecordEditor();
2424
}
2525

26+
function escapeSqlStringLiteral(value) {
27+
return String(value)
28+
.replace(/\\/g, "\\\\")
29+
.replace(/'/g, "\\'");
30+
}
31+
2632
function getRecordEditorTarget() {
2733
if (globalRecordEditorState.source === "table")
2834
return "#tableRecordEditorContent";
@@ -344,10 +350,10 @@ function saveRecordEditor() {
344350
JSON.parse(current);
345351
sqlValue = current;
346352
} catch (e) {
347-
sqlValue = "'" + current.replace(/'/g, "\\'") + "'";
353+
sqlValue = "'" + escapeSqlStringLiteral(current) + "'";
348354
}
349355
} else
350-
sqlValue = "'" + current.replace(/'/g, "\\'") + "'";
356+
sqlValue = "'" + escapeSqlStringLiteral(current) + "'";
351357

352358
setParts.push("`" + prop + "` = " + sqlValue);
353359
});

0 commit comments

Comments
 (0)