Repository: jabref/jabref
Issue: JabRef doesn't start if AutomaticKeywordGroup uses a semicolon as separator

- [x] I have tested the latest master version from http://builds.jabref.org/master/ and the problem persists

JabRef version 4.1 on Windows 10
(JabRef 4.1, Windows 10 10.0 amd64, Java 1.8.0_144)

Steps to reproduce:

1. Open a bibtex-file ([test0.txt](https://github.com/JabRef/jabref/files/1643240/test0.txt)). Create Automatic keyword group. Use proposed standard values, only change "," to ";" as separator.
2. Close JabRef. The bibtex-file looks like this: [test.txt](https://github.com/JabRef/jabref/files/1643209/test.txt)
3. Start JabRef.
4. JabRef doesn't start: It appears in the task manager, using the CPU a short time and then stays at 0% CPU with a constant amount of RAM used. No window opens.

If within the test file the `\\;` which stands for the separator (the second one after `keywords`, I guess) is changed to `,` or `-` JabRef opens again. If this `\\;` is changed to `;` JabRef doesn't start.

Regards



Changed files:
src/test/java/org/jabref/logic/importer/util/GroupsParserTest.java, src/main/java/org/jabref/logic/exporter/GroupSerializer.java

diff --git a/src/main/java/org/jabref/logic/exporter/GroupSerializer.java b/src/main/java/org/jabref/logic/exporter/GroupSerializer.java
index e8ce0925c3..eed98ed454 100644
--- a/src/main/java/org/jabref/logic/exporter/GroupSerializer.java
+++ b/src/main/java/org/jabref/logic/exporter/GroupSerializer.java
@@ -171,9 +171,9 @@ public class GroupSerializer {
         appendAutomaticGroupDetails(sb, group);
         sb.append(StringUtil.quote(group.getField(), MetadataSerializationConfiguration.GROUP_UNIT_SEPARATOR, MetadataSerializationConfiguration.GROUP_QUOTE_CHAR));
         sb.append(MetadataSerializationConfiguration.GROUP_UNIT_SEPARATOR);
-        sb.append(group.getKeywordDelimiter());
+        sb.append(StringUtil.quote(group.getKeywordDelimiter().toString(), MetadataSerializationConfiguration.GROUP_UNIT_SEPARATOR, MetadataSerializationConfiguration.GROUP_QUOTE_CHAR));
         sb.append(MetadataSerializationConfiguration.GROUP_UNIT_SEPARATOR);
-        sb.append(group.getKeywordHierarchicalDelimiter());
+        sb.append(StringUtil.quote(group.getKeywordHierarchicalDelimiter().toString(), MetadataSerializationConfiguration.GROUP_UNIT_SEPARATOR, MetadataSerializationConfiguration.GROUP_QUOTE_CHAR));
         sb.append(MetadataSerializationConfiguration.GROUP_UNIT_SEPARATOR);
         appendGroupDetails(sb, group);
         return sb.toString();
diff --git a/src/test/java/org/jabref/logic/importer/util/GroupsParserTest.java b/src/test/java/org/jabref/logic/importer/util/GroupsParserTest.java
index ef694fac9f..dd9385a736 100644
--- a/src/test/java/org/jabref/logic/importer/util/GroupsParserTest.java
+++ b/src/test/java/org/jabref/logic/importer/util/GroupsParserTest.java
@@ -42,6 +42,20 @@ public class GroupsParserTest {
         assertEquals(expected, parsed);
     }
 
+    @Test
+    public void KeywordDelimiterThatNeedsToBeEscaped() throws Exception {
+        AutomaticGroup expected = new AutomaticKeywordGroup("group1", GroupHierarchyType.INDEPENDENT, "keywords", ';', '>');
+        AbstractGroup parsed = GroupsParser.fromString("AutomaticKeywordGroup:group1;0;keywords;\\\\;;>;1;;;;;", ';', fileMonitor);
+        assertEquals(expected, parsed);
+    }
+
+    @Test
+    public void HierarchicalDelimiterThatNeedsToBeEscaped() throws Exception {
+        AutomaticGroup expected = new AutomaticKeywordGroup("group1", GroupHierarchyType.INDEPENDENT, "keywords", ',', ';');
+        AbstractGroup parsed = GroupsParser.fromString("AutomaticKeywordGroup:group1;0;keywords;,;\\\\;;1;;;;;", ';', fileMonitor);
+        assertEquals(expected, parsed);
+    }
+
     @Test(expected = ParseException.class)
     public void fromStringThrowsParseExceptionForNotEscapedGroupName() throws Exception {
         GroupsParser.fromString("ExplicitGroup:slit\\\\\\\\;0\\\\;mertsch_slit2_2007\\\\;;", ',', fileMonitor);