Closed
Bug 326532
Opened 20 years ago
Closed 19 years ago
Ampersand in bookmark keyworded search string doesn't get URL encoded properly
Categories
(Camino Graveyard :: Location Bar & Autocomplete, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
Camino1.5
People
(Reporter: jimmiejams, Assigned: bugzilla-graveyard)
References
Details
(Keywords: fixed1.8.1)
Attachments
(1 file, 3 obsolete files)
|
4.34 KB,
patch
|
stuart.morgan+bugzilla
:
review+
mikepinkerton
:
superreview+
|
Details | Diff | Splinter Review |
User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8) Gecko/20051229 Camino/1.0b2
Build Identifier: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8) Gecko/20051229 Camino/1.0b2
I have a bookmark with a keyword set up for Google search (the bookmark is http://www.google.com.au/search?hl=en&q=%s&btnG=Google+Search&meta= and the keyword is 'goo'). When I type the following into the address bar
goo at&t "hobbit" cpu
it incorrectly (I think) ends up as
http://www.google.com.au/search?hl=en&q=at&t%20%22hobbit%22%20cpu&btnG=Google+Search&meta=
with the '&' between the 'at' and 't' as the value of the 'q' parameter, which also causes the other parts of the 'q' value to be incorrectly interpreted by Google.
Reproducible: Always
Steps to Reproduce:
1. set up a bookmark with the location 'http://www.google.com.au/search?hl=en&q=%s&btnG=Google+Search&meta='
2. set the bookmark keyword to 'goo'
3. type 'goo at&t "hobbit" cpu' into the address bar
Actual Results:
I got a search for the letters 'AT'
Expected Results:
I should've got search results for 'AT&T "Hobbit" CPU'
| Assignee | ||
Comment 1•20 years ago
|
||
I'm not totally sure we want to be sanitising the search string used with keywords. This works perfectly in the search field. If it's a really simple fix, I suppose it wouldn't hurt, but this isn't exactly a common problem.
cl
Comment 2•20 years ago
|
||
Simple workaround: Use a JavaScript bookmarklet with encodeURIComponent().
What does Firefox 1.5 do?
This is basically bug 181243 all over again, except the only character that's not being encoded correctly now is the ampersand; other characters (like the searches in bug 181243, or the question mark) are properly encoded.
Firefox encodes the ampersand, so we should be doing that, too.
Status: UNCONFIRMED → NEW
Component: Bookmarks → Location Bar & Autocomplete
Ever confirmed: true
Target Milestone: --- → Camino1.1
Comment 5•19 years ago
|
||
*** Bug 337039 has been marked as a duplicate of this bug. ***
| Assignee | ||
Comment 6•19 years ago
|
||
Are there any other characters besides & we should worry about? I couldn't think of any, but if there are, we might want to consider an alternative approach (although simply making a string of them is fairly easy), like stringByAddingPercentEscapesUsingEncoding: or something.
I think the set of characters that are valid URL characters AND need to be encoded in most search strings is pretty small, though.
cl
Assignee: mikepinkerton → bugzilla
Status: NEW → ASSIGNED
Attachment #221252 -
Flags: review?(stuart.morgan)
Comment 7•19 years ago
|
||
Comment on attachment 221252 [details] [diff] [review]
first shot at a patch, encodes & as %26
Why would you want to roll a custom partial solution when stringByAddingPercentEscapesUsingEncoding: should do exactly what needs to be done here?
Attachment #221252 -
Flags: review?(stuart.morgan) → review-
| Assignee | ||
Comment 8•19 years ago
|
||
(In reply to comment #7)
> (From update of attachment 221252 [details] [diff] [review] [edit])
> Why would you want to roll a custom partial solution when
> stringByAddingPercentEscapesUsingEncoding: should do exactly what needs to be
> done here?
>
Because it doesn't, that's why. The ampersand is a valid URL character, and none of the encodings supported by that method seem to encode the ampersand. (Trust me, I tried that first.)
cl
Comment 9•19 years ago
|
||
You should probably use the CoreFoundation function CFURLCreateStringByAddingPercentEscapes(), then:
return (NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)resultString, NULL, NULL, kCFStringEncodingUTF8);
Comment 10•19 years ago
|
||
Apparently Apple's docs are (gasp!) wrong. The fourth argument should be CFSTR(";/?:@&=+$,") or some such.
| Assignee | ||
Comment 11•19 years ago
|
||
This takes care of the filed bug and heads off nine more possible unfiled bugs. (I don't think any of them are a problem at Google, but all could be with other search engines.)
cl
Attachment #221252 -
Attachment is obsolete: true
Attachment #221291 -
Flags: review?(stuart.morgan)
Comment 12•19 years ago
|
||
Comment on attachment 221291 [details] [diff] [review]
uses CFURLCreateString... as suggested
Sorry, I didn't look carefully enough at stringByAddingPercentEscapesUsingEncoding:
On the other hand, you didn't test this patch, so we're even ;) You need to escape |keywords|, not the entire URL; this completely breaks keywords as is (looks good if you move the escaping to keyword though).
Attachment #221291 -
Flags: review?(stuart.morgan) → review-
| Assignee | ||
Comment 13•19 years ago
|
||
There we go. I was in a hurry to get to work this morning when I posted the other one and hadn't had a chance to test it. It was very thoroughly broken, though.
This one works and only percent-escapes the search string.
cl
Attachment #221291 -
Attachment is obsolete: true
Attachment #221387 -
Flags: review?(stuart.morgan)
Comment 14•19 years ago
|
||
Comment on attachment 221387 [details] [diff] [review]
tested ;) and working patch
The escaping should be done inside the if; no point in doing work that won't be needed.
And since you are respinning anyway and like cleanup... expandKeyword:inString: is a terrible name for this function. The "keyword" argument is *not* the bookmark keyword, the keyword isn't the part being expanded, and the string isn't just any old string (which is kind of important to the whole escaping process). It would be great if you could rename this to something sensible like expandURL:withString: (swapping the argument order, obviously). You'd only have to touch two other files, and it would make the world a better place.
Attachment #221387 -
Flags: review?(stuart.morgan) → review-
| Assignee | ||
Comment 15•19 years ago
|
||
(In reply to comment #14)
> You'd only have
> to touch two other files, and it would make the world a better place.
What two? I can only find expandKeyword: in BookmarkFolder.mm.
cl
Comment 16•19 years ago
|
||
The imaginary two--I somehow got the idea that the call was from outside BMF, so there and BMF.h. That makes it even easier to make the world a better place!
| Assignee | ||
Comment 17•19 years ago
|
||
All previous comments fixed. Oh, and turns out expandKeyword wasn't declared in the header, so this was the only file I had to touch. Cool.
Attachment #221387 -
Attachment is obsolete: true
Attachment #221540 -
Flags: review?(stuart.morgan)
Comment 18•19 years ago
|
||
Comment on attachment 221540 [details] [diff] [review]
Fixed, fixed, and fixed
r=me.
Whoever checks this in should do something about the insane spacing on the arguments to CFURLCreateStringByAddingPercentEscapes (I meant to mention it earlier, but it slipped my mind). Lining arguments up is nice and all, but not when it makes the whole file 40 or 50 characters wider.
Attachment #221540 -
Flags: superreview?
Attachment #221540 -
Flags: review?(stuart.morgan)
Attachment #221540 -
Flags: review+
Attachment #221540 -
Flags: superreview? → superreview?(mikepinkerton)
Comment 19•19 years ago
|
||
Comment on attachment 221540 [details] [diff] [review]
Fixed, fixed, and fixed
sr=pink
Attachment #221540 -
Flags: superreview?(mikepinkerton) → superreview+
QA Contact: location.bar
Whiteboard: [needs checkin]
Updated•19 years ago
|
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•