gnodet commented on code in PR #77:
URL: https://github.com/apache/maven-archiver/pull/77#discussion_r1860344521


##########
src/test/java/org/apache/maven/shared/archiver/PomPropertiesUtilTest.java:
##########
@@ -81,4 +82,36 @@ void testUnicodeEscape() throws IOException {
         assertEquals("version=2.1.5", contents.get(2));
         assertEquals(3, contents.size());
     }
+
+    @Test
+    void testWhitespaceEscape() throws IOException {
+        Path pomPropertiesFile = tempDirectory.resolve("bar.properties");
+        Path customPomPropertiesFile = 
tempDirectory.resolve("custom.properties");
+        try (Writer out = Files.newBufferedWriter(customPomPropertiesFile, 
StandardCharsets.ISO_8859_1)) {
+            
out.write("a\\u0020key\\u0020with\\u0009whitespace=value\\u0020with\\u0009whitespace\n");
+        }
+
+        util.createPomProperties(
+                (Session) null,
+                "org.foo",
+                "こんにちは",
+                "2.1.5",
+                new JarArchiver(),
+                customPomPropertiesFile,
+                pomPropertiesFile,
+                true);
+        assertThat(pomPropertiesFile).exists();
+
+        Properties actual = new Properties();
+        actual.load(Files.newInputStream(pomPropertiesFile));
+        assertEquals("value with\twhitespace", actual.getProperty("a key 
with\twhitespace"));
+
+        // Now read the file directly to check for alphabetical order and 
encoding
+        List<String> contents = Files.readAllLines(pomPropertiesFile, 
StandardCharsets.ISO_8859_1);
+        assertEquals(4, contents.size());
+        assertEquals("a\\ key\\ with\\\twhitespace=value\\ 
with\\\twhitespace", contents.get(0));

Review Comment:
   the test is wrong afaik. The mechanism is different for keys and values
   
   > Then every entry in this Properties table is written out, one per line. 
For each entry the key string is written, then an ASCII =, then the associated 
element string. For the key, all space characters are written with a preceding 
\ character. For the element, leading space characters, but not embedded or 
trailing space characters, are written with a preceding \ character. The key 
and element characters #, !, =, and : are written with a preceding backslash to 
ensure that they are properly loaded.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to