Closed GuusLieben closed 1 year ago
I can't really see how the plus from an URL would end up in the file name, because URLDecoder.decode
would replace it with space and subsequently there will be replacement with underscore. Do you have an example URL to reproduce the issue?
URL is for localhost (BIMserver is on the same machine), as this is a development environment for the time being. A sample URL would be:
http://localhost:9001/access/gl/46/Bdeqhtc7ndy+ljSh8c93f3Daw4x9kHrsr6TuoYPxwas=/1UQ+fv2%2FWKpXcR%2FGJRg0HoD+8gKS0wczuE7OQA7HNWoYnMJpnaphgxcQEQWKdBTyml8h4Xy80OtULvDrnQ0dsF8cVoZUd5bKQjkYfrkMGdAoTJ3RaOzh8ZMzBj%2FU4AnfDj5tbS5PVcMGw5L7h%2FFlamTIpcu7nmeIdWHzYVg+SEYNnkozxIisK+VwvkNEIqHCvfqxafJRwZpeu%2Frxbq3FFupYB02assmWdLcODx5ESGmJV2k1ZV1S54cr7swG2uqU2iZpouJO8ayX0BNp78IkuPN7J6uJxqXsCDRXJ1BISUQH7fIx6Q075+wahfemI5Vp
I tested it further and found that the content of the filename is indeed not the issue (even though the FileSystemException suggests that it is..), but the length of the name is. As the name I mentioned in the PR description is 319 characters, it's longer than what NTFS permits (255 characters), which actually caused the issue.
I'll update this PR with the proper fix shortly👍🏼
Updated the PR to resolve the issue as described above. NTFS doesn't allow filenames to be longer than 255 characters. Windows technically allows up to 260 characters, minus one to keep space for null terminators (so 259 characters). However to be save it's better to follow NTFS limits, and apply the same terminator rule (255-1).
See this discussion on SO for a general overview, and "Maximum Path Length Limitation" for Windows standard limits.
Also see "Comparison of filename limitations" for a full overview of filename length limits per file system. While it is technically possible other filesystems are used, which carry even shorter name limits, I'd argue that it is truly relevant to support these as well considering NTFS (common on Windows), HFS (MacOS), and "most UNIX file systems" (as described in linked overview) all follow the 255 character limit.
When checking in files from remote URLs with complex URL parts there is a risk of a FileSystemException as the filename may be invalid for the filesystem. An example of such a URL part is
Mw6G5s+9ZWTshlSdu4jWr9wAZ7DVFOlF7UMJoC4JUg8+4vDpfUN6pXXQnLQ2eW3O9J+y9fzCT2UuJ0ZzZZ77ezF8ZGMAZNfGCDC7%2FEYjMs0UWlzBjBtyemZdsvoRSMofc24NeU0l2va63jtB+yLHDRJyihD%2FLZ4Oa5zSJFCmy+jTLJWvvIIPJWWfPU725axiVt%2FFUGK3FyreYyQDao4l5VDdwb0t8bNsPfE1YPwTMI00wX2WPF2K2V63W0Q%2FT03cC4qkPLLCdCxVZPbWK3gc2MbDHdXZLlwAHr0eMWGo89syWFCBxLqyFv0wPZ%2Fu9Uo8
, which yields:The proposed changes replace all characters that are not alphanumeric or a underscore or period symbol. So e.g. the above turns into:
Mw6G5s9ZWTshlSdu4jWr9wAZ7DVFOlF7UMJoC4JUg84vDpfUN6pXXQnLQ2eW3O9Jy9fzCT2UuJ0ZzZZ77ezF8ZGMAZNfGCDC72FEYjMs0UWlzBjBtyemZdsvoRSMofc24NeU0l2va63jtByLHDRJyihD2FLZ4Oa5zSJFCmyjTLJWvvIIPJWWfPU725axiVt2FFUGK3FyreYyQDao4l5VDdwb0t8bNsPfE1YPwTMI00wX2WPF2K2V63W0Q2FT03cC4qkPLLCdCxVZPbWK3gc2MbDHdXZLlwAHr0eMWGo89syWFCBxLqyFv0wPZ2Fu9Uo8
, which is a valid filename