Closed Bug 614201 Opened 15 years ago Closed 7 years ago

Escape \ (backslash character) for copy-and-paste

Categories

(Firefox :: Address Bar, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED INACTIVE

People

(Reporter: ed, Unassigned)

References

()

Details

User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:2.0b7) Gecko/20100101 Firefox/4.0b7 Build Identifier: 4.07b7 (the Help | About box does not show a build identifier) Recent versions of Firefox unescape URIs shown in the address bar. So for example if you browse to http://www.google.co.uk/search?q=a%5Cb the escape sequence %5C will be converted to \ to display in the address bar. This is great, but it can cause problems when cutting and pasting URIs into other programs. For example, since \ is not a legal character in URIs, if you include the unescaped URI in a plain text mail message then the client program may not highlight the entire URI as a clickable link. Mail clients and other text- based systems have to use heuristics and guesses to see what is a URI and where it ends, and it's not unreasonable for them to decide that when a non-legal character is seen it cannot be part of the URI. Suggested fix: although displaying an unescaped version in the address bar is great, when copying the URI to the clipboard the canonical, escaped version should be copied. Reproducible: Always Steps to Reproduce: 1. Enter a URI containing a %5C escape or other escape of non-URI-legal character. 2. The unescaped version appears in the address bar. 3. Select the text in the address bar, copy to clipboard, paste into other app. Actual Results: An unescaped version is pasted, containing \ or other non-URI-legal character. Expected Results: The original escaped version should be pasted. "Be conservative in what you do, be liberal in what you accept from others."
Assignee: smontagu → nobody
Component: Internationalization → Location Bar
Product: Core → Firefox
QA Contact: i18n → location.bar
Version: unspecified → Trunk
I can confirm this with Seamonkey trunk (!) and FF 4b07 It more ugly with spaces and i get problems with copy+paste URLs from SUMO. Example: http://support.mozilla.com/en-US/kb/Safe%20Mode
Status: UNCONFIRMED → NEW
Ever confirmed: true
Aravind, can you check if this happens in 3.5.x or 3.6? If not could you find a regression range in Fx4?
The urlbar binding method _getSelectedValueForClipboard() calls contentAreaUtils->makeURI() which calls nsIIOService->newURI(). Spaces are url encoded. Cutting and pasting the url in Comment 1 into a text editor give me: http://www.google.co.uk/search?q=a%20b But I see the problem with the backslash.
Backslash behaviour is identical in Firefox 3.6.
The space issue with the safemode URL is now fixed
(In reply to comment #5) > The space issue with the safemode URL is now fixed It wasn't even broken... So, is \ actually illegal for URIs?
Summary: Do not unescape URIs for cut-and-paste → Escape \ (backslash character) for copy-and-paste
A backslash "\" is an unsafe char based on RFC1738. I don't know if that RFC is now obsolete or not, there is no unsafe char section in rfc3986 >Other characters are unsafe because >gateways and other transport agents are known to sometimes modify >such characters. These characters are "{", "}", "|", "\", "^", "~", >"[", "]", and "`". > >All unsafe characters must always be encoded within a URL.
My reading of RFC3986 is that \ is still just as much a disallowed character in URIs, since it does not appear in the grammar.
Following is noticed in FF 3.5,3.6 and 4.x beta versions %20:SPACE: unescaped in address bar,copy/paste shows escaped char %3c: Less Than: unescaped in address bar,copy/paste shows escaped char %3e:Greater Than: unescaped in address bar,copy/paste shows escaped char %23b:Hash: escaped sequence is present in address bar. copy/paste shows escaped sequence %5c:Backslash:unescaped sequence appears in address bar,copy/paste shows unescaped sequence Checked the behavior on: Internet Explorer 8: Unescaped chars appear in address bar,copy/paste to other app shows unescaped chars Google Chrome: Few chars are escaped and few are not in address bar.
Just to update this, since it was originally filed against a long-superseded Firefox version: I have re-tested this with Firefox 13 and the behaviour is the same. The 'unescaped' URI including non-URI characters such as \ is copied to the clipboard.
Note that this is still buggy in Firefox 45.
Per policy at https://wiki.mozilla.org/Bug_Triage/Projects/Bug_Handling/Bug_Husbandry#Inactive_Bugs. If this bug is not an enhancement request or a bug not present in a supported release of Firefox, then it may be reopened.
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → INACTIVE
You need to log in before you can comment on or make changes to this bug.