restsharp/RestSharp — pull request #597 by chris-grabcad (2014-11-07 11:21:43+00:00)
Title: Rewrote UrlEncodeStrict

It didn't handle % characters in the original string (unless they were followed by a not Unreserved Character).

So '%$' would encode via '%%24' to '%25%24', but '%' would encode to '%', also both '$' and '%24' would encode to '%24' - so how is the other end supposed to know what was originally intended.

It looks as if the original author was semi aware of the problem with '%' characters, as they added two cludges to the otherwise elegant code a "&& c != '%'" into the LINQ expression and at the end for translating "%%" into "%25%".

Simply removing the cludges the weakness in the clever use of Aggregate is exposed, encode '%$%' without those and you get '%2525%24%2525'.

My change is a back to basics approach which benefits from being simpler to understand and verify.

I would have added unit tests, but couldn't find any for this module.