gitlab4j-api icon indicating copy to clipboard operation
gitlab4j-api copied to clipboard

RepositoryFileApi.getFileInfo() returns messed up file name and file path

Open danlz opened this issue 3 years ago • 1 comments

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.

danlz avatar Jun 11 '21 11:06 danlz

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));

danlz avatar Jun 11 '21 14:06 danlz