Your Digital Media Has Never Looked So Good

 
renojim
** Valued Community Member **
Topic Author
Posts: 3492
Joined: Mon Feb 15, 2010 1:35 pm

Caret in URL

Fri Aug 20, 2010 2:24 am

I have to use a caret (^) in a URL, but when I try it I get back the CURLE_URL_MALFORMAT error code (-3) and GetFailureReason() returns "No URL set!". I thought I could just replace the caret with %5E, but the site I'm trying to connect to doesn't seem to support that syntax. Any ideas?

-JT
 
User avatar
RokuKevin
Roku Engineering
Posts: 796
Joined: Tue Sep 22, 2009 2:29 pm

Re: Caret in URL

Fri Aug 20, 2010 10:23 am

Try encoding your url with:

    o = CreateObject("roUrlTransfer")
    encodedUrl = o.Escape(url)


--Kevin
 
renojim
** Valued Community Member **
Topic Author
Posts: 3492
Joined: Mon Feb 15, 2010 1:35 pm

Re: Caret in URL

Fri Aug 20, 2010 1:39 pm

I tried both Escape() and UrlEncode() and they both return the CURLE_COULDNT_RESOLVE_HOST error (-6) after the call to AsyncGetToString(). GetFailureReason() returns "Could not resolve host:" followed by the modified URL followed by the message "(Misformatted domain name)". I don't think either would work for me anyway since the site I'm trying to access doesn't recognize % escapes, which is really annoying. I think I'm out of luck unless I can pass the caret through unmodified.

-JT
 
User avatar
TheEndless
** Valued Community Member **
Posts: 9231
Joined: Mon Oct 04, 2004 10:15 am
Location: US
Contact:

Re: Caret in URL

Fri Aug 20, 2010 1:54 pm

Is the ^ in a querystring value? If so, you might be able to post it as post data instead, depending on how liberal the code behind the site is...
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
 
renojim
** Valued Community Member **
Topic Author
Posts: 3492
Joined: Mon Feb 15, 2010 1:35 pm

Re: Caret in URL

Fri Aug 20, 2010 3:47 pm

TheEndless wrote:
Is the ^ in a querystring value? If so, you might be able to post it as post data instead, depending on how liberal the code behind the site is...

Yes it is. I'll give that a try. Thanks for the idea!

Edit: I couldn't get it to work. I can't be sure if it doesn't accept the post or if I just haven't figured out exactly what to post to exactly what url.

-JT
 
ntdevman
Posts: 2
Joined: Mon Aug 23, 2010 6:10 pm

Re: Caret in URL

Mon Aug 23, 2010 7:44 pm

For more than most people would ever want or need to know about URL obfuscation:
go here:
http://www.pc-help.org/obscure.htm
search for this line:
Example: http://username:password@www.whatever.c ... esonly.htm

between that trick of flipping the authentication information between the http:// and the @ symbol (example above this) and using hex or octal or some other numbering system (not %), then you should be able to come up with some alternate encoding.

Since I'm guessing what you're trying to do, (IN --> function --> OUT), I'm just taking a shot in the dark here.

--
good luck
 
renojim
** Valued Community Member **
Topic Author
Posts: 3492
Joined: Mon Feb 15, 2010 1:35 pm

Re: Caret in URL

Mon Aug 23, 2010 9:07 pm

Thanks. That was some interesting reading, but it doesn't help my situation which is a query sent to a url like this:
http://www.someplace.com/query/1.0?q=^parm

The site won't accept the caret being replaced by %5E and the Roku box won't send the caret.

-JT
 
User avatar
RokuMarkn
Roku Engineering
Posts: 1581
Joined: Mon Jun 09, 2008 9:20 am

Re: Caret in URL

Tue Aug 24, 2010 9:12 am

Well, it doesn't help you solve your problem, but it sounds like that web server is seriously nonconformant to web standards. According to RFC 1738, caret is an "unsafe character" and "All unsafe characters must always be encoded within a URL". Caret is listed as unsafe because is it in a set of characters that "gateways and other transport agents are known to sometimes modify". Again, this doesn't help you unless you can use it to apply pressure to get that server made more compliant.

--Mark
 
renojim
** Valued Community Member **
Topic Author
Posts: 3492
Joined: Mon Feb 15, 2010 1:35 pm

Re: Caret in URL

Wed Aug 25, 2010 1:24 am

You're right, it doesn't help. :mrgreen: It's not a big deal, but it would be nice if there was a way to just let anything be allowed in a URL and let the connection succeed or fail on it's own.

The really funny thing is that it's a Yahoo server. You'd think they'd get it right.

-JT
 
sikofitt
Posts: 2
Joined: Sat Aug 28, 2010 1:39 pm

Re: Caret in URL

Sun Aug 29, 2010 12:37 pm

This seems more of a standards issue. I don't think I've ever been to a website that used ^ as a character? Is there a reason that this is required?
 
renojim
** Valued Community Member **
Topic Author
Posts: 3492
Joined: Mon Feb 15, 2010 1:35 pm

Re: Caret in URL

Sun Aug 29, 2010 3:22 pm

I guess you'd have to ask Yahoo. The caret is part of a query.

-JT
 
kbenson
Posts: 889
Joined: Fri Apr 09, 2010 9:53 am
Location: Santa Rosa, Ca

Re: Caret in URL

Mon Aug 30, 2010 9:29 am

renojim wrote:
I guess you'd have to ask Yahoo. The caret is part of a query.


Yahoo may require a caret in the parameter name, but they almost definitely accept it URI encoded (it's generally the web server's responsibility to unescape, not the web-app). ^ is %5E escaped, if you want to test manually.

Make sure to encode only the parameter names and values in the string, not the full URL to post to, since it will see :, /, and = as values that need to be escaped. E.g.
$ perl -MURI::Escape -e 'print uri_escape("http://example.com?^foo=bar")."\n";'
http%3A%2F%2Fexample.com%3F%5Efoo%3Dbar


What you really want is something like:
$ perl -MURI::Escape -e 'print "http://example.com?".uri_escape("^foo")."=".uri_escape("bar")."\n";'
http://example.com?%5Efoo=bar


Needless to say, escaping the entire URL, or even just the full param string, will lead to problems.
-- GandK Labs
Check out Reversi! in the channel store!
 
renojim
** Valued Community Member **
Topic Author
Posts: 3492
Joined: Mon Feb 15, 2010 1:35 pm

Re: Caret in URL

Mon Aug 30, 2010 2:35 pm

The first thing I tried was to replace the caret, and only the caret, with %5E. It didn't work. The parameter, which is one of several, was just ignored.

-JT
 
kbenson
Posts: 889
Joined: Fri Apr 09, 2010 9:53 am
Location: Santa Rosa, Ca

Re: Caret in URL

Mon Aug 30, 2010 3:13 pm

That's odd. There doesn't happen to be a test URL with a known response provided by yahoo, does there? That would make testing for the rest of us easier without revealing anything specific to your account there, if that mattes.
-- GandK Labs
Check out Reversi! in the channel store!

Who is online

Users browsing this forum: No registered users and 2 guests