new Uri(string) Changing ^ in string to %5E

J

Jeroen Mostert

Dad said:
How do I keep "Uri(string)" from changing a ^ in the string to %5E?
For example,


"http://quote.yahoo.com/d/quotes.csv?s=^DJI&f=sl1d1t1c1ohgvj1pp2owern&e=.csv"


gets changed to


"http://quote.yahoo.com/d/quotes.csv?s=^DJI&f=sl1d1t1c1ohgvj1pp2owern&e=.csv"


which doesn't work. If I type the latter string directly into Internet
Explorer it does work so
the '^' is not a problem for Yahoo and needed be changed.
"^" must be escaped according to RFC 2396; the URI class is doing nothing
wrong. Unfortunately, Yahoo's server is. Even assuming that it doesn't
*require* "^" to be escaped, it should correctly decode "%5E" to "^", but it
doesn't. This is because the server is redirecting the response and mucking
up the escaping in the process.

Try using the URL it redirects to directly instead:
http://finance.yahoo.com/... This should work. Failing that, you can use the
deprecated overload of Uri that allows you to specify whether the string is
already escaped (new Uri(..., true)). This is dangerous if the string is
constructed from untrusted user input, but it still works.
 
D

Dad

Try using the URL it redirects to directly instead:
http://finance.yahoo.com/... This should work. Failing that, you can
use the deprecated overload of Uri that allows you to specify
whether the string is already escaped (new Uri(..., true)). This is
dangerous if the string is constructed from untrusted user input,
but it still works.

The deprecated Uri constructor worked. I had seen it but forgot
about it.

Thanks much,
Gary
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top