I'm working on a project where a local file is exported via HTTP. This involves getting a file URI, relativizing it using the exported path, tacking it onto the export URI and then handling that as a URL on the receiving end.
Normally this works fine, but I run into trouble when the filename contains a semicolon. I narrowed it down to here:
new File(path).toURI()
The above method correctly encodes spaces and the like, but not semicolons (which should be encoded into a %3B).
Ultimately the above method returns the result of the URI constructor (protocol, host, path, fragment), which returns the bad URI.
I could manually replace all semicolons with %3B, but that doesn't feel like the best solution. Is there really no built-in API to correctly encode a path?
Many thanks for any assistance.