docs: public static String sanitizeEntryPath(final String path, final boolean removeInitialSlash) {
          if (path.isEmpty()) {
              return "";
          }
  
          // Find all '/' and '!' character positions, which split a path into segments 
          boolean foundSegmentToSanitize = false;
          {
              int lastSepIdx = -1;
              char prevC = '\0';
              for (int i = 0; i < path.length() + 1; i++) {
                  final char c = i == path.length() ? '\0' : path.charAt(i);
                  if (c == '/' || c == '!' || c == '\0') {
                      final int segmentLength = i - (lastSepIdx + 1);
                      if (
                      // Found empty segment "//" or "!!"
                      (segmentLength == 0 && prevC == c)
                              // Found segment "."
                              || (segmentLength == 1 && path.charAt(i - 1) == '.')
                              // Found segment ".."
                              || (segmentLength == 2 && path.charAt(i - 2) == '.' && path.charAt(i - 1) == '.')) {
                          foundSegmentToSanitize = true;
                      }
                      lastSepIdx = i;
                  }
                  prevC = c;
              }
          }
  
          // Handle "..", "." and empty path segments, if any were found
          String pathSanitized = path;
          if (foundSegmentToSanitize) {
              // Sanitize between "!" section markers separately (".." should not apply past preceding "!")
              final List<List<String>> allSectionSegments = new ArrayList<>();
              List<String> currSectionSegments = new ArrayList<>();
              allSectionSegments.add(currSectionSegments);
              int lastSepIdx = -1;
              for (int i = 0; i < path.length() + 1; i++) {
                  final char c = i == path.length() ? '\0' : path.charAt(i);
                  if (c == '/' || c == '!' || c == '\0') {
                      final String segment = path.substring(lastSepIdx + 1, i);
                      if (segment.equals(".") || segment.isEmpty()) {
                          // Ignore "/./" or empty segment "//"
                      } else if (segment.equals("..")) {
                          // Remove one segment if ".." encountered, but do not allow ".." above top of hierarchy
                          if (!currSectionSegments.isEmpty()) {
                              currSectionSegments.remove(currSectionSegments.size() - 1);
                          }
                      } else {
                          // Encountered normal path segment
                          currSectionSegments.add(segment);
                      }
                      if (c == '!' && !currSectionSegments.isEmpty()) {
                          // Begin new section
                          currSectionSegments = new ArrayList<>();
                          allSectionSegments.add(currSectionSegments);
                      }
                      lastSepIdx = i;
                  }
              }
              // Turn sections and segments back into path string
              final StringBuilder buf = new StringBuilder();
              for (final List<String> sectionSegments : allSectionSegments) {
                  if (!sectionSegments.isEmpty()) {
                      // Delineate segments with "!"
                      if (buf.length() > 0) {
                          buf.append('!');
                      }
                      for (final String sectionSegment : sectionSegments) {
                          buf.append('/');
                          buf.append(sectionSegment);
                      }
                  }
              }
              pathSanitized = buf.toString();
              if (pathSanitized.isEmpty() && path.startsWith("/")) {
                  pathSanitized = "/";
              }
          }
  
          if (removeInitialSlash || !path.startsWith("/")) {
              // Strip off leading "/" if it needs to be removed, or if it wasn't present in the original path
              // (the string-building code above prepends "/" to every segment). Note that "/" is always added
              // after "!", since "jar:" URLs expect this.
              while (pathSanitized.startsWith("/")) {
                  pathSanitized = pathSanitized.substring(1);
              }
          }
          return pathSanitized;
      }