AFNetworking/AFNetworking — pull request #927 by olarivain (2013-04-16 01:08:05+00:00)
Title: fix for unescaped brackets in params values

Hey,

The default HTTP escaping code on the AFHTTPClient is explicitly skipping square brackets on the query string from being escaped.
I'm assuming this is to support rails' "arrays in HTTP params" feature, but is nonetheless a violation of RFC 3986 that can cause some HTTP servers to improperly parse the query string (namely our IIS servers don't seem too happy with these queries).

So far, this patch only addresses the issue in params values, mainly for backward compatibility with aforementioned rails convention.
However, reading RFC 3986 in more details, it seems that square brackets are never allowed as part of a query string, and as such should always be escaped. Cf http://www.ietf.org/rfc/rfc3986.txt that claims:

> A host identified by an Internet Protocol literal address, version 6 [RFC3513] or later, is distinguished by enclosing the IP literal within square brackets ("[" and "]"). This is the only place where square bracket characters are allowed in the URI syntax.

I'd be more than happy to patch AFNetworking to be compliant with that part, but making the patch would require a bit more work (probably moving away from C functions for URL encoding), and I'd like to be sure this behavior would be fine with upstream before starting any work on it.
As it is, this patch shouldn't break anything, just fix improperly escaped query values.