gitlab4j-api
gitlab4j-api copied to clipboard
RepositoryFileApi.getFileInfo() returns messed up file name and file path
When you call RepositoryFileApi.getFileInfo() for a file with special characters in the name, the values of "fileName" and "filePath" fields in the RepositoryFile object are messed up. The file name is displayed correctly in the GitLab web view.
Tested with GitLab4j version 4.16.0, 4.15.7, 4.14.30.
Those two fields are passed as HTTP headers, so this probably breaks it.
RepositoryFileApi.getFile() returns correct values.
The values are ISO_8859_1 encoded, so the workaround is:
String decodedFilePath = new String(repositoryFile.getFilePath().getBytes(StandardCharsets.ISO_8859_1));
String decodedFileName = new String(repositoryFile.getFileName().getBytes(StandardCharsets.ISO_8859_1));