Closed RubenVerborgh closed 11 years ago
Wow, thank you for the detailled analysis and patches. I will have to check the rfc and will make a pull request of your testcase to https://github.com/uri-templates/uritemplate-test
Great! The pull request is right here: uri-templates/uritemplate-test#26
I have merged to fast. There are samples, where % is allowed, see template {+half}, data {"half": "50%"} should expand to "50%25" (from spec-examples-by-section.json)
No, it's fine :-)
A %
character is indeed allowed, but it must be escaped (as your example shows). This works and is tested.
The original issue was that % was not escaped if it was followed by a two-digit number, which this pull request fixes.
Note that the test suite has been updated to include this test.
Thank you, I have seen it. I will rebase the submodule, not a trivial task with github
Context
Suppose we have the following template:
and the following variables:
So note here that the
ref
parameter in the URI's string is equal tohttp://other.org/
(URL encoded).What we expect is that the expansion of this templates equals:
Note the double escaping for the
uri
parameter. This is logical, since decoding this parameter should result in the original variable value:Bug
However, with this library, the result is:
As you can see, percent signs are not encoded. This is incorrect, since RFC6570 reads:
Furthermore, decoding results in:
which is different from the original value and thus wrong.
Pull request
This pull request fixes this by:
%
as a reserved characterLiteralExpression
to not decode the literalencodingHelper
to not decode the literalFurthermore, the tests have been updated to incorporate this issue.