Last Comment Bug 683422 - An Ampersand (&) on the URL line breaks Translate Page
: An Ampersand (&) on the URL line breaks Translate Page
Product: SeaMonkey
Classification: Client Software
Component: General (show other bugs)
: SeaMonkey 2.3 Branch
: x86 Windows 7
-- normal (vote)
: ---
Assigned To: Philip Chee
Depends on:
  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:
QA Whiteboard:
Iteration: ---
Points: ---

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 | Splinter Review

Description User image 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:

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 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:




Comment 2 User image 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)
  else {
    loadURI(encodeURI(service + targetURI));

The following works for me:
loadURI(encodeURI(service) + encodeURIComponent(targetURI));
Neil is this the correct fix?
Comment 3 User image Philip Chee 2011-09-01 07:45:26 PDT
Created attachment 557493 [details] [diff] [review]
Patch v1.0 use encode
Comment 4 User image Philip Chee 2011-09-05 09:24:25 PDT
Comment 5 User image 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.