FullSearch Returns Titles When Using a Text-as-Default SearchBox and IE9 When Pressing Enter

/!\ Only occurs when IE9 'Compatibility View' is on. (Just shut it off - problems with RecentChanges, FindPage response anyway MoinMoinBugs/FullSearchIE8ScripError#Workaround)...

Users of our office wiki preferred the search box default action to be text instead of wiki page titles. After switching the theme's button positions ('Text' button is now on the left/first button), users using IE9 still get titles when they press enter (Text box is highlighted showing default). Opera and Firefox work as desired. IE9 is the 'official' browser of our IT department, so I can not ignore.

I developed a fix by adding a default key handler to define what moin should search for if a user presses enter and no default button is 'clicked' within my local fullsearch.py file. This supports a developer, if they choose to make the Text button the default button for their wiki. I think it would make sense to include a similar solution within the source code. If not, at least this page can show how to make it work.

Steps to reproduce

  1. Alter theme so the search box Text button is the left-most button.

  2. Restart server.
  3. Use IE9 (maybe IE8, IE10 perform the same way)
  4. Type in some search text and press Enter

  5. fullsearch.py will default to titles only (because neither '&fullsearch=Text' or '&titlesearch=Titles' is found)

Example

not easily shown, so skipped

Component selection

When fullsearch.py is determining titles vs. text, it will incorrectly choose a title search if it does not find '&fullsearch=Text' and the search is not an advanced search.

IE9 does not include the '&fullsearch=Text' argument whenever the user presses enter when the Text button is the default button. Nor does IE9 include the '&titlesearch=Titles' argument when the Titles button is the default. Due to this, fullsearch.py falls back to a title search.

The root problem was tracked down to differing implementations of HTML4 textbox + enter action (response not defined by the standard - so browsers are free to do anything). HTML5 is more clear and requires the response to be same as default button click. Opera and Firefox follow the HTML5 edict and therefor work because the action call is the same as if the user clicked the default button. (Chrome and Safari were not tested.)

Details

The Apache access logs show the difference in the search calls:

Browser

User Action

Access log

IE9

search text + Text button click

GET /testwiki/FrontPage?action=fullsearch&context=180&value=fun&fullsearch=Text HTTP/1.1

IE9

search text + ENTER

GET /testwiki/FrontPage?action=fullsearch&context=180&value=fun HTTP/1.1

Opera12

search text + Text button click

GET /testwiki/FrontPage?action=fullsearch&context=180&value=fun&fullsearch=Text HTTP/1.1

Opera12

search text + ENTER

GET /testwiki/FrontPage?action=fullsearch&context=180&value=fun&fullsearch=Text HTTP/1.1

Firefox19

search text + Text button click

GET /testwiki/FrontPage?action=fullsearch&context=180&value=fun&fullsearch=Text HTTP/1.1

Firefox19

search text + ENTER

GET /testwiki/FrontPage?action=fullsearch&context=180&value=fun&fullsearch=Text HTTP/1.1

Original code in fullsearch.py:

   1 def checkTitleSearch(request):
   2     """ Return 1 for title search, 0 for full text search, -1 for idiot spammer
   3         who tries to press all buttons at once.
   4 
   5     When used in FullSearch macro, we have 'titlesearch' parameter with
   6     '0' or '1'. In standard search, we have either 'titlesearch' or
   7     'fullsearch' with localized string. If both missing, default to
   8     True (might happen with Safari) if this isn't an advanced search.
   9 """
  10     form = request.values
  11     if 'titlesearch' in form and 'fullsearch' in form:
  12         ret = -1 # spammer / bot
  13     else:
  14         try:
  15             ret = int(form['titlesearch'])
  16         except ValueError:
  17             ret = 1
  18         except KeyError:
  19             ret = ('fullsearch' not in form and not isAdvancedSearch(request)) and 1 or 0
  20     return ret

MoinMoin Version

1.9.6

OS and Version

Win 7, 32 bit

Python Version

2.6.6

Server Setup

Apache 2.2.19

Server Details

Language you are using the wiki in (set in the browser/UserPreferences)

en-US

Workaround

Appears to only be an issue if IE9 'Compatibility View' is active.

hg diff showing workaround patch for fullsearch.py:

   1 diff -r 5683dd03c2c0 fullsearch.py
   2 --- a/fullsearch.py     Thu Mar 14 12:37:30 2013 -0500
   3 +++ b/fullsearch.py     Fri Mar 15 14:59:54 2013 -0500
   4 @@ -32,7 +32,10 @@
   5          except ValueError:
   6              ret = 1
   7          except KeyError:
   8 -            ret = ('fullsearch' not in form and not isAdvancedSearch(request)) and 1 or 0
   9 +            if 'default' in form:
  10 +                ret = ('fullsearch' not in form and form['default'] <> u'fullsearch' and not isAdvancedSearch(request)) and 1 or 0
  11 +            else:
  12 +                ret = ('fullsearch' not in form and not isAdvancedSearch(request)) and 1 or 0
  13      return ret
  14  
  15  def isAdvancedSearch(request):

Proposed modification to the moin codebase (/MoinMoin/theme/__init__.py):

   1 diff -r e6429dc7c53d -r eb9fdac89ec5 __init__.py
   2 --- a/__init__.py       Fri Mar 15 15:14:47 2013 -0500
   3 +++ b/__init__.py       Fri Mar 15 15:17:54 2013 -0500
   4 @@ -803,6 +803,7 @@
   5  <div>
   6  <input type="hidden" name="action" value="fullsearch">
   7  <input type="hidden" name="context" value="180">
   8 +<input type="hidden" name="default" value="titlesearch">
   9  <label for="searchinput">%(search_label)s</label>
  10  <input id="searchinput" type="text" name="value" value="%(search_value)s" size="20"
  11      onfocus="searchFocus(this)" onblur="searchBlur(this)"

Modification:

Example Text search default (text search as default response and Text button first) with the moin theme base file __init__.py :

   1 diff -r e6429dc7c53d __init__.py
   2 --- a/__init__.py       Fri Mar 15 15:14:47 2013 -0500
   3 +++ b/__init__.py       Sun Mar 17 23:25:21 2013 -0500
   4 @@ -803,13 +803,13 @@
   5  <form id="searchform" method="get" action="%(url)s">
   6  <div>
   7  <input type="hidden" name="action" value="fullsearch">
   8  <input type="hidden" name="context" value="180">
   9 +<input type="hidden" name="default" value="fullsearch">
  10  <label for="searchinput">%(search_label)s</label>
  11  <input id="searchinput" type="text" name="value" value="%(search_value)s" size="20"
  12      onfocus="searchFocus(this)" onblur="searchBlur(this)"
  13      onkeyup="searchChange(this)" onchange="searchChange(this)" alt="Search">
  14 +<input id="fullsearch" name="fullsearch" type="submit"
  15 +    value="%(search_full_label)s" alt="Search Full Text">
  16  <input id="titlesearch" name="titlesearch" type="submit"
  17      value="%(search_title_label)s" alt="Search Titles">
  18 -<input id="fullsearch" name="fullsearch" type="submit"
  19 -    value="%(search_full_label)s" alt="Search Full Text">
  20  </div>
  21  </form>
  22  <script type="text/javascript">

Now the access logs show the action calls as:

Browser

User Action

Access log

IE9

search text + Text button click

GET /testwiki/FrontPage?action=fullsearch&context=180&default=fullsearch&value=ie9cvTextButton&fullsearch=Text HTTP/1.1

IE9

search text + ENTER

GET /testwiki/FrontPage?action=fullsearch&context=180&default=fullsearch&value=ie9cvEnter HTTP/1.1

Searches are returned correctly now.

Discussion

Plan


CategoryMoinMoinNoBug

MoinMoin: MoinMoinBugs/FullSearchReturnsTitlesWithTextAsDefaultSearchBoxUsingIE9 (last edited 2014-01-04 22:33:07 by ThomasWaldmann)