Search adds '20' to searched text

ilroby - August 9, 2007 - 04:48
Project:Javascript Tools
Version:5.x-1.x-dev
Component:Active Search
Category:bug report
Priority:critical
Assigned:Unassigned
Status:postponed (maintainer needs more info)
Description

Using the search block to look up, for example, the word 'hello' (no single quotes) the url gets composed as http://www.example.com/en/search/node#keys%20hello

Once the search page comes up, it has in the search box '20hello' (no quotes) and the url
becomes http://www.example.com/en/search/node#keys%2020hello
This makes the search fail. if from the search page I remove the preceding '20' then the search runs fine.

Other than that, great module!

#1

ilroby - August 9, 2007 - 04:51

Forgot to add, this happens with IE (7 and I think 6 as well), seems ok with Firefox.

#2

nedjo - August 9, 2007 - 05:11

Thanks for the note. It's a case of the forward slash getting escaped. More generally, it's a limited/poor implementation of 'hijax' (updating history with AJAX state changes).

The best solution likely is to use the enhanced history plugin that's now part of Javascript Tools instead of the custom approach used here.

#3

manimal - August 13, 2007 - 20:06

yes, this also happens in safari for windows and osx.

I'm not sure what you mean about using the enhanced history? is this a setting? (sorry I'm sorta new)

#4

manimal - August 13, 2007 - 20:19

nevermind.. found the dev release..(haven't slept in awhile)

#5

somatics - September 26, 2007 - 07:06

This is still happening for me. I have Drupal 5.2 on a Mac OS X 10.4 server with JS Tools and all associated modules installed. It's the latest version of JS Tools (5.0.8). I need to fix this soon, as we launch our site in 24 hours!

#6

somatics - September 26, 2007 - 07:12

I just installed the HEAD and tried it again -- still the same problem.

#7

nedjo - September 26, 2007 - 15:16

I'm not sure what you mean about using the enhanced history?

What I mean is that the Javascript needs to be rewritten. Currently it uses its own way of appending history to the URL. Evidently this fails in IE. One option would be to try to fix this in IE. But it would be better to remove the custom implementation and instead use the jQuery history plugin, which provides a much better solution.

#8

nedjo - September 26, 2007 - 15:52
Status:active» fixed

Fixed in HEAD and DRUPAL-5 (5.x dev) branch.

Replaced space character with =, which doesn't get escaped.

#9

jwilde - September 27, 2007 - 13:10

Hi nedjo,

Thank you for all of the hard work. Active search works great. jim

#10

somatics - September 28, 2007 - 02:23

Yes, I installed the HEAD version (I didn't know where else to find the dev version) and it fixed virtually ALL the Javascript problems I was having -- the very same search problem reported here, the inability to re-order items in Interface Sortable, and -- most of all -- a "fatal" problem with the checkout process in UberCart. These were all present only on Safari not on FireFox with jstools 5.x-0.8 and now with the latest HEAD version that was fixed yesterday, they're gone. Thank you!!

#11

jwilde - October 4, 2007 - 11:48

I'm still having the problem somewhat in IE. For example, if I search for, 'the long tail', this is what shows up, 'the%20long%20tail', in the search form box.

Best jim

#12

nedjo - October 4, 2007 - 14:32

k, thanks for the report. /me is beginning to regret ever coding this module. I suppose we need to substitute + for spaces in the string passed by the javascript. I'd welcome a patch.

#13

drupalina - October 10, 2007 - 06:31
Status:fixed» active

Subscribing.

I have the same problem: 20 appears before and %20 appears between the searck terms. It'd be great to have a solution for this ASAP.

#14

bobdalob - November 28, 2007 - 08:28

Subscribing. Tried in latest dev release & 5.x-0.8, same problem. Okay in FF & Opera

#15

pictogram - January 20, 2008 - 19:41

Subscribing, but I can't help here, sorry.

#16

MissyM - February 3, 2008 - 23:43

subscribing - same issue

Only an issue when Active Search is on

#17

adam-s - February 17, 2008 - 07:54

Just ran into this problem on a site. A quick hack if you're not quite ready for upgrade...

Go to modules/search/search.module

In the search_query_insert function just before lines 634-635...

  return $keys;
}

Add the following code...

if (substr($keys, 0 ,2)=='20') $keys=substr($keys, 2);

So it looks like...

function search_query_insert($keys, $option, $value = '') {
  if (search_query_extract($keys, $option)) {
    $keys = trim(preg_replace('/(^| )'. $option .':[^ ]*/i', '', $keys));
  }
  if ($value != '') {
    $keys .= ' '. $option .':'. $value;
  }
  if (substr($keys, 0 ,2)=='20') $keys=substr($keys, 2);
  return $keys;
}

Not even close to a perfect or ideal solution but if you need a quick fix maybe this will help...

#18

Lityi - February 19, 2008 - 19:22

thx, it works as a quick fix ;)

#19

adam-s - February 26, 2008 - 07:28

Looks like this may not work for Safari users.

#20

yas - March 22, 2008 - 09:49

Subscribing.

#21

westwesterson - March 23, 2008 - 19:49
Priority:normal» critical

this totally breaks search in the safari browser! v 3.1 The page keeps getting refreshed and fills the search box with 20s.

#22

somatics - March 28, 2008 - 20:59

I am having these same problems in Safari 3 or 3.1 with Javascript Tools that I used to have before I upgraded the module last Fall, but now it happens no matter how recent a version I use.

Does anyone know what the fix is? It is messing up my shopping cart functionality, and I am losing customers rapidly.

#23

westwesterson - April 1, 2008 - 07:10

I can confirm my problems with thie have ended with the latest release.

#24

bobdalob - April 1, 2008 - 14:14

It still causes problems (as described in #21) with safari (windows), in an advanced search performed with more than one word.

Note: the %20 issue occurs regardless of simple/advanced, when using more than one search term.

#25

nedjo - April 14, 2008 - 15:27
Status:active» fixed

Safari issue addressed by not applying Activesearch under Safari. See http://drupal.org/node/192910#comment-806695.

#26

Anonymous (not verified) - April 28, 2008 - 15:31
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

#27

jaysonjust - September 2, 2008 - 22:20
Status:closed» postponed (maintainer needs more info)

was this ever fixed?

#28

ekendra - October 7, 2008 - 22:27

in activesearch.js change the function starting on line 29 to:

Drupal.activesearchSubmit = function() {
  var nastyChars = eval("/%20|#/ig");
  $('#edit-keys').attr('value', location.hash.substring(6).replace(nastyChars, ' '));
  // Call the submit event.
  $('#search-form').submit();
  // Actually submit the form.
  $('#search-form')[0].submit();
};

seems to do the trick although I'm sure there's a more elegant solution

#29

quineto - October 16, 2008 - 06:35

hello ekendra

this code only replaces the first 20 in the first term, does it york for you for more than one term?

Drupal.activesearchSubmit = function() {
  var nastyChars = eval("/%20|#/ig");
  $('#edit-keys').attr('value', location.hash.substring(6).replace(nastyChars, ' '));
  // Call the submit event.
  $('#search-form').submit();
  // Actually submit the form.
  $('#search-form')[0].submit();
};

#30

quineto - October 16, 2008 - 06:39

Hello Lityi,

Did this fix worked for more than one term in the search box?

thanks

#31

goudal - January 27, 2009 - 11:05

It does not work when there is a accentued character...

 
 

Drupal is a registered trademark of Dries Buytaert.