I'm not sure if this is a problem in autocomplete.js itself or elsewhere, but filing it here since the front-end is where this bug is surfacing: if auto-complete is asked to search on a partial string containing a slash ('/'), the web server returns a 404 response, resulting in the ugly JavaScript error pop-up.
Easiest way to reproduce: create a node and type '/' in the 'authored by' field. Not restricted to this field or form though, same happens for example when using the taxonomy field's auto-complete widget.
In case this is web server-specific: Ubuntu, PHP 5.3, Apache/2.2.14
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | slashes.patch | 664 bytes | michaelfavia |
Comments
Comment #1
mr.baileysComplete error message:
Note that firebug shows that the request itself is correctly encoded:
... and the 404 is Apache's 404 page, not Drupal's:
Comment #2
droplet commented+1
only happen when CLEAN URL enabled
Comment #3
rfayI think this may be innate to the whole approach here with autocomplete. I wonder if there's a way to make Apache ignore extra slashes (but I don't think there will be a way to get it to search on those slashes).
Of course the reason it's not a problem without clean URLs is that then the extra slash is part of the query string, not part of the base url.
This is exactly the same in D6, is it not?
Comment #4
mr.baileysOddly enough, no (at least not at first glance). Did a quick test on the user auto-complete field, and D6 seems to take the slashes just fine, so it seems this problem is new to D7...
Ideally, the argument to the auto-complete path would always be passed as a query parameter rather than a path element (you're accessing the same resource anyway, so it would make more sense too I guess)
So
http://example.com/user/autocomplete?ac=partial_stringinstead of
http://example.com/user/autocomplete/partial_stringThat would fix this issue. This probably is considered an API change though.
Comment #5
rfayI don't think I'd consider that an API change. Seems like something we should do. I'd say roll a patch.
Comment #6
mr.baileys#1000748: Term reference autocomplete widget having problems handling terms containing forward slashes. marked as duplicate.
Comment #7
joachim commented> Ideally, the argument to the auto-complete path would always be passed as a query parameter rather than a path element (you're accessing the same resource anyway, so it would make more sense too I guess)
Do we really need to make that change? As stated above, this works fine on D6 passed in as a path. How does D6 do it?
Comment #8
anrikun commentedSubscribing.
Comment #9
stborchertDrupal 6 uses
Drupal.encodeURIComponentto encode the given string.Drupal 7 uses
encodeURIComponentwhich doesn't convert%2Fback to/.If you modify autocomplete.js line 294 (
url: db.uri + '/' + encodeURIComponent(searchString),) tourl: db.uri + '/' + Drupal.encodePath(searchString),slashes aren't a problem anymore.edit: this has been committed with #284899: Drupal url problem with clean urls
Comment #10
joachim commentedSo is this bug effectively fixed by #284899: Drupal url problem with clean urls?
Comment #11
stborchertNo, unfortunately #284899: Drupal url problem with clean urls created this bug by fixing another :/
Comment #12
vitok-dupe commentedsubscribe
Comment #13
michaelfavia commentedaffected via linkit. subscribe.
Comment #14
benanderson commentedsubscribing
Comment #15
michaelfavia commentedI just added forward slashes to the regex that removes trailing and leading whitespace. Along with some comments for those who don't like reading regex ors.
I don't know if we want to include forward slashes in the ajax searches but if we do we'll have to go another route. This scratched my itch and fixes the issue with linkit module and "http://" links.
Comment #16
pillarsdotnet commentedComment #17
joachim commented> I don't know if we want to include forward slashes in the ajax searches
Yes, I would say we do. The ajax search should work for whatever the user types, since there is no restriction on characters in term names.
Comment #18
mr.baileysApologies for closing this issue, but it looks like this is a duplicate of #93854: Allow autocompletion requests to include slashes which has more background and history, so I think it's beneficial to continue the discussion there...