OpenAssetIO / OpenAssetIO-Manager-BAL

A contrived "asset management system" for OpenAssetIO integration test cases.
Apache License 2.0
5 stars 4 forks source link

[Core] Don't %-decode file URLs from DB #110

Closed feltech closed 1 month ago

feltech commented 1 month ago

Closes #109. We should not be percent-decoding URLs fetched from the JSON DB before passing to the host, since other functions that consume the returned URL will most likely expect the URL to be percent-encoded.

In order to allow for upward traversals to be used in file:// URLs in the DB (in particular, useful for e.g. ${bal_library_dir_url}/../path/to/file) we needed to parse the URL to treat as a path, resolve the upward traversals (since they are invalid in URLs according to FileUrlPathConverter), then reconstruct the URL. Unfortunately in doing this we also percent-decoded the URL and didn't re-encode it.

Passing the decoded URL to FileUrlPathConverter.pathFromUrl would then do a second round of percent-decoding, possibly decoding what should have been left as a %-sign.

So re-write the file:// normalisation logic to avoid having to deal with percent decoding at all.