From 6b1cafb8fb1a5fb2dded4e4ef80d39d14f833fc7 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Tue, 10 May 2011 19:28:24 -0300 Subject: [PATCH] Don't serialize/deserialize invalid order values. --- mindplot/src/main/javascript/XMLMindmapSerializer_Beta.js | 7 +++++-- mindplot/src/main/javascript/XMLMindmapSerializer_Pela.js | 7 +++++-- wise-webapp/src/test/data/wisemaps/strange-char.wxml | 0 .../freemind/{ExportTest.java => FreemindExportTest.java} | 4 ++-- 4 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 wise-webapp/src/test/data/wisemaps/strange-char.wxml rename wise-webapp/src/test/java/com/wisemapping/test/freemind/{ExportTest.java => FreemindExportTest.java} (97%) diff --git a/mindplot/src/main/javascript/XMLMindmapSerializer_Beta.js b/mindplot/src/main/javascript/XMLMindmapSerializer_Beta.js index ef7605ba..646d82d4 100644 --- a/mindplot/src/main/javascript/XMLMindmapSerializer_Beta.js +++ b/mindplot/src/main/javascript/XMLMindmapSerializer_Beta.js @@ -64,7 +64,10 @@ mindplot.XMLMindmapSerializer_Beta.prototype._topicToXML = function(document, to } else { var order = topic.getOrder(); - parentTopic.setAttribute("order", order); + if(core.Utils.isDefined(order) && !isNaN(order-0)) + { + parentTopic.setAttribute("order", order); + } } } @@ -213,7 +216,7 @@ mindplot.XMLMindmapSerializer_Beta.prototype._deserializeNode = function(domElem } var order = domElem.getAttribute('order'); - if (core.Utils.isDefined(order)) { + if (core.Utils.isDefined(order) && !isNaN(order-0)) { topic.setOrder(order); } diff --git a/mindplot/src/main/javascript/XMLMindmapSerializer_Pela.js b/mindplot/src/main/javascript/XMLMindmapSerializer_Pela.js index 58300dae..1e66cc1a 100644 --- a/mindplot/src/main/javascript/XMLMindmapSerializer_Pela.js +++ b/mindplot/src/main/javascript/XMLMindmapSerializer_Pela.js @@ -83,7 +83,10 @@ mindplot.XMLMindmapSerializer_Pela.prototype._topicToXML = function(document, to // } else // { var order = topic.getOrder(); - parentTopic.setAttribute("order", order); + if(core.Utils.isDefined(order) && !isNaN(order-0)) + { + parentTopic.setAttribute("order", order); + } // } } @@ -281,7 +284,7 @@ mindplot.XMLMindmapSerializer_Pela.prototype._deserializeNode = function(domElem } var order = domElem.getAttribute('order'); - if (core.Utils.isDefined(order)) { + if (core.Utils.isDefined(order) && !isNaN(order-0)) { topic.setOrder(parseInt(order)); } diff --git a/wise-webapp/src/test/data/wisemaps/strange-char.wxml b/wise-webapp/src/test/data/wisemaps/strange-char.wxml new file mode 100644 index 00000000..e69de29b diff --git a/wise-webapp/src/test/java/com/wisemapping/test/freemind/ExportTest.java b/wise-webapp/src/test/java/com/wisemapping/test/freemind/FreemindExportTest.java similarity index 97% rename from wise-webapp/src/test/java/com/wisemapping/test/freemind/ExportTest.java rename to wise-webapp/src/test/java/com/wisemapping/test/freemind/FreemindExportTest.java index 3b9d2bb5..7ea205c3 100644 --- a/wise-webapp/src/test/java/com/wisemapping/test/freemind/ExportTest.java +++ b/wise-webapp/src/test/java/com/wisemapping/test/freemind/FreemindExportTest.java @@ -13,7 +13,7 @@ import org.testng.annotations.Test; import java.io.*; @Test -public class ExportTest { +public class FreemindExportTest { private static final String DATA_DIR_PATH = "src/test/data/wisemaps/"; @Test(dataProvider = "Data-Provider-Function") @@ -85,7 +85,7 @@ public class ExportTest { final File[] freeMindFiles = dataDir.listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { - return name.endsWith(".xml"); + return name.endsWith(".wxml"); } });