diff --git a/IllegalTokenText/Example3/config.xml b/IllegalTokenText/Example3/config.xml
index 1d81b2a6..6cb71c37 100644
--- a/IllegalTokenText/Example3/config.xml
+++ b/IllegalTokenText/Example3/config.xml
@@ -23,7 +23,7 @@
-
+
diff --git a/IllegalTokenText/all-examples-in-one/config.xml b/IllegalTokenText/all-examples-in-one/config.xml
index d750aea2..0bfbb6c0 100644
--- a/IllegalTokenText/all-examples-in-one/config.xml
+++ b/IllegalTokenText/all-examples-in-one/config.xml
@@ -36,7 +36,7 @@
-
+
diff --git a/MultipleStringLiterals/Example3/config.xml b/MultipleStringLiterals/Example3/config.xml
index 620ce087..b90a3ea3 100644
--- a/MultipleStringLiterals/Example3/config.xml
+++ b/MultipleStringLiterals/Example3/config.xml
@@ -23,7 +23,7 @@
-
+
diff --git a/MultipleStringLiterals/all-examples-in-one/config.xml b/MultipleStringLiterals/all-examples-in-one/config.xml
index 741a0b70..27fe1a3b 100644
--- a/MultipleStringLiterals/all-examples-in-one/config.xml
+++ b/MultipleStringLiterals/all-examples-in-one/config.xml
@@ -33,7 +33,7 @@
-
+
diff --git a/Regexp/Example12/config.xml b/Regexp/Example12/config.xml
index 0a0e0121..1d6823de 100644
--- a/Regexp/Example12/config.xml
+++ b/Regexp/Example12/config.xml
@@ -23,7 +23,7 @@
-
+
diff --git a/Regexp/Example13/config.xml b/Regexp/Example13/config.xml
index b1d1c1f7..ead2954c 100644
--- a/Regexp/Example13/config.xml
+++ b/Regexp/Example13/config.xml
@@ -24,7 +24,7 @@
- \)\. You shall not\n \* disclose such Confidential Information and shall use it only in\n \* accordance with the terms of the license agreement you entered into\n \* with ACME\.\n \*
\n \*\n \* © copyright \d\d\d\d ACME\n \*\n \* @author .*)(\n\s\*.*)*/\n[\w|\s]*( class | interface )"/>
+
diff --git a/Regexp/all-examples-in-one/config.xml b/Regexp/all-examples-in-one/config.xml
index 1affd6c4..551ba570 100644
--- a/Regexp/all-examples-in-one/config.xml
+++ b/Regexp/all-examples-in-one/config.xml
@@ -88,14 +88,14 @@
-
+
- \)\. You shall not\n \* disclose such Confidential Information and shall use it only in\n \* accordance with the terms of the license agreement you entered into\n \* with ACME\.\n \* \n \*\n \* © copyright \d\d\d\d ACME\n \*\n \* @author .*)(\n\s\*.*)*/\n[\w|\s]*( class | interface )"/>
+
diff --git a/extractor/src/main/java/com/example/extractor/ConfigSerializer.java b/extractor/src/main/java/com/example/extractor/ConfigSerializer.java
index e8e8c68c..770fd98b 100644
--- a/extractor/src/main/java/com/example/extractor/ConfigSerializer.java
+++ b/extractor/src/main/java/com/example/extractor/ConfigSerializer.java
@@ -476,8 +476,73 @@ private static void appendProperty(final StringBuilder builder, final String ind
if (builder.length() > 0) {
builder.append('\n');
}
- builder.append(indent).append("");
+
+ // Check for quotes in the original, unescaped value
+ final boolean containsDoubleQuote = value.contains("\"");
+ final boolean containsSingleQuote = value.contains("'");
+
+ // Determine the appropriate quote character
+ final char quote;
+ if (containsDoubleQuote && !containsSingleQuote) {
+ // Use single quotes as delimiters
+ quote = '\'';
+ }
+ else {
+ // Use double quotes as delimiters in all other cases
+ quote = '"';
+ }
+
+ // Escape the value based on the selected quote character
+ final String escapedValue = escapeXmlAttributeValue(value, quote);
+
+ // Append the property to the builder
+ builder.append(indent)
+ .append("");
+ }
+
+ /**
+ * Escapes special XML characters in the input string.
+ * Replaces &, <, >, ", and ' with their corresponding XML entities.
+ * Returns the original input if null or empty.
+ *
+ * @param input the string to escape
+ * @return the escaped string or the original if null/empty
+ */
+ private static String escapeXml(final String input) {
+ String result = input;
+ if (input != null && !input.isEmpty()) {
+ result = input.replace("\"", """)
+ .replace("'", "'");
+ }
+ return result;
+ }
+
+ /**
+ * Escapes special characters in an XML attribute value.
+ * Replaces &, <, > with their corresponding XML entities.
+ * Depending on the delimiter, either ' or " is also escaped.
+ *
+ * @param input the string to escape
+ * @param delimiter the delimiter used for the attribute (' or ")
+ * @return the escaped string or the original if null/empty
+ */
+ private static String escapeXmlAttributeValue(final String input, final char delimiter) {
+ String result = input;
+ if (input != null && !input.isEmpty()) {
+ if (delimiter == '\'') {
+ result = result.replace("'", "'");
+ }
+ else {
+ result = result.replace("\"", """);
+ }
+ }
+ return result;
}
/**