Trent
Posts: 12
Joined: Mon Oct 19, 2009 3:27 pm

Postby Trent » Fri Nov 12, 2010 8:33 pm

I've noticed for a while (yes, I know, I should have reported it a while ago... :() that when I right click on links in Awasu and select "Open in default browser", the web page it opens isn't correct. It looks like it's losing everything after the first ampersand in the URL.

If the link I want to go to is:

http://news.google.com/news/url?sa=t&fd=R&usg=AFQjCNGmpV57jpJx2T6b03IcQdMs71eLWQ&url=http://www.cnn.com/2010/WORLD/americas/11/12/haiti.cholera/?hpt%3DT2

Awasu will try and open Firefox with:

http://www.google.com/url?sa=t


Any ideas? :)

User avatar
support
Site Admin
Posts: 3021
Joined: Fri Feb 07, 2003 12:48 pm
Location: Melbourne, Australia
Contact:

Postby support » Sat Nov 13, 2010 3:10 am

Yep, I can repro this and it's because of the ampersands in the URL. Bugger, I thought I had this covered, but apparently not :|

Not sure what I can do at this stage, we're code complete for 3.0 so it's only critical bugs at this stage (or anything I can do with very low-risk). Let me have a ponder...

User avatar
support
Site Admin
Posts: 3021
Joined: Fri Feb 07, 2003 12:48 pm
Location: Melbourne, Australia
Contact:

Postby support » Sat Nov 13, 2010 5:28 am

Some more details about what's going on here; it's complicated :-(

When you choose "Open in default browser", IE sends a request to Awasu of the form

Code: Select all

http://127.0.0.1:2604/openInDefaultBrowser?url=...

The problem occurs if the URL contains ampersands, because the request ends up looking like this:

Code: Select all

http://127.0.0.1:2604/openInDefaultBrowser?url=http://test.com?foo=1&bar=2

When Awasu receives the request, it looks for the url parameter and parses everything up to the next ampersand i.e. http://test.com?foo=1. It doesn't know that the ampersand relates to the embedded URL, not the request URL it received.

Getting IE to encode the ampersands in the request it sends to Awasu i.e. so it sends this

Code: Select all

http://127.0.0.1:2604/openInDefaultBrowser?url=http://test.com?foo=1%26bar=2

doesn't work since Awasu decodes these special characters before it extracts parameters and the problem comes back.

The only way I can see this could possibly work is if Awasu decodes special characters after it extracts parameters but I'm not sure this is the right thing to do. RFC 3986 says
A percent-encoding mechanism is used to represent a data octet in a component when that octet's corresponding character is outside the allowed set or is being used as a delimiter of, or within, the component
i.e. percent-encoding is a component-level thing and it goes on to define the relevant component as everything between the ? and the # (or the end of the URI).

Regardless, changing Awasu to do percent-decoding after it extracts parameters is a high-risk change so it'll have to be deferred until after 3.0. I've been having a play with trying to double-encode stuff but it doesn't seem to want to work. If you want to have a go, the $/Resources/IE Templates/IeOpenInDefaultBrowser.template file is the one you want.


User avatar
support
Site Admin
Posts: 3021
Joined: Fri Feb 07, 2003 12:48 pm
Location: Melbourne, Australia
Contact:

Postby support » Sat Nov 13, 2010 11:05 pm


That's a new approach to spam I've never seen before :roll:

I put stuff like this in my license file :-). That way I can get quick access to it (Alt H, L). Ah, that reminds me why I gave such a low-use menu item an accelerator... :roll:

User avatar
kevotheclone
Posts: 239
Joined: Mon Sep 08, 2008 7:16 pm
Location: Elk Grove, California

Postby kevotheclone » Sun Nov 14, 2010 8:48 am

support wrote:

That's a new approach to spam I've never seen before :roll:

I put stuff like this in my license file :-). That way I can get quick access to it (Alt H, L). Ah, that reminds me why I gave such a low-use menu item an accelerator... :roll:

I wanted to get Trent's original, problematic URL into an Awasu feed item so I could test it, but later I realized that I could just hard code the URL into the "IeOpenInDefaultBrowser.template" file. I also realized that I could just call the "openInDefaultBrowser" API directly with that URL to test. :oops:

Anyway, I tried several modifications of the "IeOpenInDefaultBrowser.template" file using escape(), encodeURI(), encodeURIComponent(), string.replace() but I couldn't get it to work. I'm sure if we could figure out what a correctly escaped URL should look like we could get the JavaScript code to escape it corectly in the "IeOpenInDefaultBrowser.template" file, but maybe it's just impossible to escape on correctly for the "openInDefaultBrowser" API in this release.

I've kind of got a crazy idea for something that might work, but it's getting too late to try it today. :sleepy:

Maybe we could manually create one of those asynchronous pluggable protocols that would run Firefox (if it's not already running) and pass it the URL. So instead of calling the "openInDefaultBrowser" API in this IE template you would do something like this:

Code: Select all

win.open( "moz://"+url , "_self" )

This is a complete WAG at this point, but it might work.

User avatar
support
Site Admin
Posts: 3021
Joined: Fri Feb 07, 2003 12:48 pm
Location: Melbourne, Australia
Contact:

Postby support » Sun Nov 14, 2010 9:26 am

The best I've been able to get is something like this:

Code: Select all

    url = url.replace( new RegExp("&","g") , "%26" ) ;
    win.open( "{%APP-SERVER-URL%}/openInDefaultBrowser?token={%API-TOKEN%}&url="+encodeURIComponent(url) , "_self" )

This allows Awasu to extract the URL correctly but Google barfs when it gets it, because there are encoded ampersands in the final URL. It's definitely doing something with it, the original URL is at news.google.com, but you end up at http://www.google.com when it finally reports the error.

User avatar
support
Site Admin
Posts: 3021
Joined: Fri Feb 07, 2003 12:48 pm
Location: Melbourne, Australia
Contact:

Postby support » Sun Nov 14, 2010 10:21 pm

OK, this is a really dorky solution but it seems to work.

(*) Find the IeOpenInDefaultBrowser.template file (in the Resources/IE Templates sub-directory) and open it in an editor.

(*) Change the second-last line (the one that starts with win.open) and replace it with this:

Code: Select all

    var ws = new ActiveXObject( "WScript.Shell" ) ;
    ws.run( url ) ;

User avatar
kevotheclone
Posts: 239
Joined: Mon Sep 08, 2008 7:16 pm
Location: Elk Grove, California

Postby kevotheclone » Mon Nov 15, 2010 8:36 am

Excellent! :drevil:
Glad you figured it out so quickly! :clap:

Trent
Posts: 12
Joined: Mon Oct 19, 2009 3:27 pm

Postby Trent » Mon Nov 15, 2010 11:47 am

support wrote:OK, this is a really dorky solution but it seems to work.

(*) Find the IeOpenInDefaultBrowser.template file (in the Resources/IE Templates sub-directory) and open it in an editor.

(*) Change the second-last line (the one that starts with win.open) and replace it with this:

Code: Select all

    var ws = new ActiveXObject( "WScript.Shell" ) ;
    ws.run( url ) ;


That does indeed seem to work. Good job. :)


Return to “Awasu - Bug Reports”

Who is online

Users browsing this forum: No registered users and 2 guests