FilenameToURI should percent-encode the result
Original Reporter info from Mantis: Michalis @michaliskambi
-
Reporter name: Michalis Kamburelis
Original Reporter info from Mantis: Michalis @michaliskambi
- Reporter name: Michalis Kamburelis
Description:
FilenameToURI should percent-encode the result, for example % in a filename should be changed into %Version 2.2.5 in the URI. This is how URIs should behave, and also this is consistent with URIToFilename (that already, correctly, percent-decodes the result). URIToFilename and FilenameToURI should reverse each other.
Attaching a simple patch to packages/fcl-base/src/uriparser.pp that fixes FilenameToURI by using Escape on the FileName parameter before adding it to Result. The "if PathDelim <> '/' then" logic has to be moved before the Escape call to make things smooth (to avoid percent-escaping backslash under Windows, that should instead be converted to a slash).
The attached patch also changes a comment inside ResolveRelativeURI. Currently, there is a comment saying
// TODO: this probably must NOT percent-encode the result...
but this wrong. That is, ResolveRelativeURI should percent-encode the result at the end, because it starts with ParseUri that percent-decodes the parameters. The attached testcase demonstrates that current ResolveRelativeURI is already correct, do not change it. The "TODO..." comment should be removed IMHO, current implementation of ResolveRelativeURI does exactly what it should.
Mantis conversion info:
- Mantis ID: 24324
- OS: Debian GNU/Linux
- OS Build: (testing)
- Platform: i386
- Version: 2.6.2
- Fixed in version: 2.6.4
- Fixed in revision: 24944 (#b847b03f)
- Target version: 3.0.0