elharo commented on code in PR #3589:
URL: https://github.com/apache/maven-surefire/pull/3589#discussion_r4573703482


##########
maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporterUtils.java:
##########
@@ -26,11 +26,29 @@
  * @author Andreas Gudian
  */
 public final class FileReporterUtils {
+    // well under the 255-byte limit most filesystems enforce per path 
component,
+    // leaving room for encodings that use more than one byte per character.
+    // Does not cover unusually restrictive encrypted-filename overlays such as
+    // eCryptfs (143 bytes with filename encryption enabled) - handling every
+    // such filesystem is out of scope here.
+    private static final int MAX_FILE_NAME_LENGTH = 200;
+
     private FileReporterUtils() {
         throw new IllegalStateException("non instantiable constructor");
     }
 
-    public static String stripIllegalFilenameChars(String original) {
+    /**
+     * Builds a safe report file name: illegal characters replaced, and 
truncated with a
+     * unique suffix if it would otherwise exceed common filesystem limits.
+     *
+     * @param fileName the file name, including its extension
+     * @return a file name safe to pass to {@link 
java.io.File#File(java.io.File, String)}
+     */
+    public static String makeFileName(String fileName) {
+        return truncateFileName(stripIllegalFilenameChars(fileName));
+    }
+
+    static String stripIllegalFilenameChars(String original) {
         StringBuilder result = new StringBuilder(original);
         String illegalChars = getOSSpecificIllegalChars();

Review Comment:
   Not new in this PR, but I really don't like OS specific code or outputs. In 
this case files might be copied from the current system to a different one. 
Keep in mind that later we might want to fix it so output is platform 
independent. Does this make tests platform dependent?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to