diff --git a/Ghidra/Features/GraphServices/src/main/java/ghidra/graph/export/AbstractGraphExporterFactory.java b/Ghidra/Features/GraphServices/src/main/java/ghidra/graph/export/AbstractGraphExporterFactory.java index c6608ec4e2..bd65e9db6c 100644 --- a/Ghidra/Features/GraphServices/src/main/java/ghidra/graph/export/AbstractGraphExporterFactory.java +++ b/Ghidra/Features/GraphServices/src/main/java/ghidra/graph/export/AbstractGraphExporterFactory.java @@ -125,8 +125,15 @@ public abstract class AbstractGraphExporterFactory { return exporter; } + String getQuotedId(V vertex) { + String id = vertexIdProvider.apply(vertex); + return "\"" + id + "\""; + } + private GraphExporter createDotExporter() { - DOTExporter exporter = new DOTExporter<>(vertexIdProvider); + // DOT format is picky about its identifiers, so pass in a vertex id supplier + // that wraps the vertex ids in quotes + DOTExporter exporter = new DOTExporter<>(this::getQuotedId); setupExporter(exporter); return exporter; } diff --git a/Ghidra/Features/GraphServices/src/main/java/ghidra/graph/export/GraphExporterDialog.java b/Ghidra/Features/GraphServices/src/main/java/ghidra/graph/export/GraphExporterDialog.java index 15c282c8a9..6bc87c1035 100644 --- a/Ghidra/Features/GraphServices/src/main/java/ghidra/graph/export/GraphExporterDialog.java +++ b/Ghidra/Features/GraphServices/src/main/java/ghidra/graph/export/GraphExporterDialog.java @@ -276,14 +276,14 @@ public class GraphExporterDialog extends DialogComponentProvider { GraphExportFormat exporterFormat = getSelectedExporter(); File outputFile = getSelectedOutputFile(); - try { - if (outputFile.exists() && + if (outputFile.exists() && OptionDialog.showOptionDialog(getComponent(), "Overwrite Existing File?", "The file " + outputFile + " already exists.\nDo you want to overwrite it?", "Overwrite", OptionDialog.QUESTION_MESSAGE) != OptionDialog.OPTION_ONE) { return false; - } - Writer writer = new FileWriter(outputFile); + } + + try (Writer writer = new FileWriter(outputFile)) { GraphExporter exporter = AttributedGraphExporterFactory.getExporter(exporterFormat);