Quantcast
Channel: WE MOVED to github.com/microsoft/cpprestsdk. This site is not monitored!
Viewing all articles
Browse latest Browse all 4845

Edited Issue: uri_exception is thrown when uri contains square brackets [382]

$
0
0
`uri_builder` in `windows_request_context::read_headers_io_completion` throws web::uri_exception when the uri contains square brackets.

The encode_uri method handles square brackets as general delimiters and therefor will not encode them.
The encoded uri is passed to the uri_builder that throws the web::uri_exception.

The following code snippet reproduces the exception:
```cpp
auto encodedUri = uri::encode_uri(L"http://localhost/service[1]?param[]=123&param[]=456");
// assert(encodedUri == L"http://localhost/service%5B1%5D?param%5B%5D=123&param%5B%5D=456");
uri_builder builder(encodedUri);
```

In compare, the JavaScript `encodeURI` method encodes the square brackets as this exampel shows:
```javascript
console.log(encodeURI("http://localhost/service[1]?param[]=123&param[]=456"));
// -> http://localhost/service%5B1%5D?param%5B%5D=123&param%5B%5D=456
```

Is there a reason to keep the brackets unencoded and why is the behavior different to javascript?

Viewing all articles
Browse latest Browse all 4845

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>