Last Comment Bug 683422 - An Ampersand (&) on the URL line breaks Translate Page
: An Ampersand (&) on the URL line breaks Translate Page
Status: RESOLVED FIXED
:
Product: SeaMonkey
Classification: Client Software
Component: General (show other bugs)
: SeaMonkey 2.3 Branch
: x86 Windows 7
: -- normal (vote)
: ---
Assigned To: Philip Chee
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-08-30 20:34 PDT by therube
Modified: 2011-09-05 20:48 PDT (History)
1 user (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
wontfix
fixed
fixed
fixed


Attachments
Patch v1.0 use encode (1.09 KB, patch)
2011-09-01 07:45 PDT, Philip Chee
iann_bugzilla: review+
iann_bugzilla: approval‑comm‑aurora+
iann_bugzilla: approval‑comm‑beta+
Details | Diff | Review

Description therube 2011-08-30 20:34:24 PDT
User Agent: Mozilla/5.0 (Windows NT 6.1; rv:6.0) Gecko/20110820 Firefox/6.0 SeaMonkey/2.3.1
Build ID: 20110820145925

Steps to reproduce:

 
URL: http://forums.mozillazine.org/viewtopic.php?f=3&t=2183189
Tools | Translate Page
 


Actual results:

 
The URL sent to Google Translate is truncated.
All characters after the ampersand are lost.
Google is not able to translate the page.
 


Expected results:

 
The entire URL should be passed to Google Translate.
Google should then translate the page for you.
 
 
It is quite common, for forums in particular, to use an (&) in their URL line.
Attempting to translate them from Tools | Translate breaks - often.

The same URLs manually pasted into http://translate.google.com/ work as the URL is not modified.

URL encoding the (&) would not appear to be a solution as it seems Google does not decode it back to what would be valid for a particular forum.

Don't know if there could be any security concerns in passing the full URL in plain text?
 

Some examples that break:

http://www.pcqanda.com/dc/dcboard.php?az=show_topic&forum=2&topic_id=535822&mesg_id=535822&page=

> http://www.pcqanda.com/dc/dcboard.php?az=show_topic

http://forums.mozillazine.org/viewtopic.php?f=3&t=2183189

> http://forums.mozillazine.org/viewtopic.php?f=3

http://forums.informaction.com/viewtopic.php?f=7&t=6997

> http://forums.informaction.com/viewtopic.php?f=7

http://www.digitalvolcano.co.uk/board/viewtopic.php?f=4&t=699

> http://www.digitalvolcano.co.uk/board/viewtopic.php?f=4
Comment 2 Philip Chee 2011-08-31 10:54:22 PDT
function Translate()
{
  var service = GetLocalizedStringPref("browser.translation.service");
  var serviceDomain = GetLocalizedStringPref("browser.translation.serviceDomain");
  var targetURI = getWebNavigation().currentURI.spec;

  // if we're already viewing a translated page, then just reload
  if (targetURI.indexOf(serviceDomain) >= 0)
    BrowserReload();
  else {
    loadURI(encodeURI(service + targetURI));
  }
}

The following works for me:
loadURI(encodeURI(service) + encodeURIComponent(targetURI));
Neil is this the correct fix?
Comment 3 Philip Chee 2011-09-01 07:45:26 PDT
Created attachment 557493 [details] [diff] [review]
Patch v1.0 use encode
Comment 4 Philip Chee 2011-09-05 09:24:25 PDT
Pushed.
http://hg.mozilla.org/comm-central/rev/1a07f47df164
Comment 5 Philip Chee 2011-09-05 09:25:33 PDT
Comment on attachment 557493 [details] [diff] [review]
Patch v1.0 use encode

Simple one line fix.

Note You need to log in before you can comment on or make changes to this bug.