Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.NET 4.5 new Uri unescaping double dot when there's inverted question mark #59

Open
aamarber opened this issue Sep 13, 2013 · 4 comments
Assignees
Labels

Comments

@aamarber
Copy link

I have the next problem. I'm trying to post the an status to twitter that contains an inverted question mark and a link. For instance, "¿http.www.google.com".

I'm using twitterizer for posting to twitter but when I try to post it, twitter response is "Could not authenticate you". Debugging twitterizer I have discovered that the problem is that when the Uri for making the request to Twitter is being built with the next string:

string correctUri = "http://api.twitter.com/1.1/statuses/update.json?status=%C2%BFhttp%3A%2F%2Fwww.google.com";

That's correct, every special character is escaped and everything is fine. But when new Uri is done with that string, then it comes the problem:

Uri uri =new Uri(correctUri);

Because the AbsoluteUri value is http://api.twitter.com/1.1/statuses/update.json?status=%C2%BFhttp:%2F%2Fwww.google.es . As you can see, it shows "http:" and that's exactly the problem.

I have tried the same exact code under .NET 4.5 and .NET 4 and it's only a problem under .NET 4.5. I also tried to post the same text under the two versions of .NET and it only works under .NET 4 and the only difference at the http request made to twitter (captured with fiddler) is the double dot.

I have discovered also that the problem only happens when you put an inverted question mark (%C2%BF in UTF-8) at the status. But when you don't put it, there's no problem at all.

Is there any solution to this problem? I have tried so many things, but nothing works.

@meebey
Copy link
Member

meebey commented Sep 13, 2013

Not sure if I fully understand the issue. You say the Twitter request becomes a http:// instead of a https:// request when the Twitter message contains an inverted question mark and thus fails with "Could not authenticate you"?

@aamarber
Copy link
Author

Nope, the problem is that is sending at the querystring parameter "status" "http:". I mean, is sending a double dot without encoding it and if you send it, Twitter answers with the error message "Could not authenticate you".

@meebey
Copy link
Member

meebey commented Sep 13, 2013

Ah, so everything is encoded in the status query string except the colon after the http. I think this can easily be workaround by replacing the http: with http%3A. To me this sounds like a bug in the URI class of .NET 4.5 then, but it could also be valid and the Twitter server violates the HTTP specification. Who is wrong makes no difference though as we can't fix either of them and thus need to workaround it in Twitterizer :-)

@aamarber
Copy link
Author

Yes, it's a bug in the uri class of .net 4.5. I was asking if somebody knows any workoaround for it, because I have tried soooomany things but nothing works :(

@ghost ghost assigned jamiehowarth0 Jan 21, 2014
@DigitallyBorn DigitallyBorn removed this from the Version 2.4.3 milestone Nov 11, 2014
@aamarber aamarber removed this from the Version 2.4.3 milestone Nov 11, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants