Last modified: 2014-11-20 22:50:02 UTC
Firefox generates smart keywords from a search bar: https://support.mozilla.org/en-US/kb/how-search-from-address-bar On Wikidata it generates the wrong bookmark https://www.wikidata.org/w/index.php?=%s&search=&title=Special%3ASearch Expected bookmark is https://www.wikidata.org/w/index.php?search=%s&title=Special%3ASearch The reason is in the JavaScript code. The original HTML from server is <form action="/w/index.php" id="searchform"> <div id="simpleSearch"> <input name="search" placeholder="Search" title="Search Wikidata [f]" accesskey="f" id="searchInput" /> <button type="submit" name="button" title="Search the pages for this text" id="searchButton"> <img src="//bits.wikimedia.org/static-1.23wmf6/skins/vector/images/search-ltr.png?303-4" alt="Search" width="12" height="13" /> </button> <input type='hidden' name="title" value="Special:Search"/> </div> </form> JavaScript converts this the following HTML code with a duplicate <input> element: <form id="searchform" action="/w/index.php"> <div id="simpleSearch"> <input id="searchInput" accesskey="f" title="Search Wikidata [alt-shift-f]" placeholder="Search" class="ui-autocomplete-input ui-suggester-input ui-entityselector-input" autocomplete="off" role="textbox" aria-autocomplete="list" aria-haspopup="true" tabindex="1"> <input type="hidden" name="search" value=""> <button id="searchButton" title="Search the pages for this text" name="button" type="submit"> <img width="12" height="13" alt="Search" src="//bits.wikimedia.org/static-1.23wmf6/skins/vector/images/search-ltr.png?303-4"> </button> <input type="hidden" value="Special:Search" name="title"> </div> </form> The JavaScript code on www.mediawiki.org works and converts the HTML to <form id="searchform" action="/w/index.php"> <div id="improvedsearch-toggle" class="vectorMenu" title="Wikimedia tech" style="width: 20px; height: 1.3em; margin-left: 14.5em; margin-right: -0.8em;"></div> <div id="simpleSearch"> <input id="searchInput" accesskey="f" title="Search MediaWiki [alt-shift-f]" placeholder="Search" name="search" tabindex="1" autocomplete="off"> <button id="searchButton" title="Search the pages for this text" name="button" type="submit"> <img width="12" height="13" alt="Search" src="//bits.wikimedia.org/static-1.23wmf7/skins/vector/images/search-ltr.png?303-4"> </button> <input type="hidden" value="Special:Search" name="title"> </div> </form>
Oh, wow. This is clearly a bug in Firefox. You know that, right? Not that we shouldn't work around it. We should. I had two ideas: 1.) Switch the order of the two <input>, the named hidden <input> first, our unnamed <input> after. Result: .../index.php?search=&=%s&title=Spezial%3ASuche 2.) Give both <input> the same name="search". Result: .../index.php?search=%s&search=&title=Spezial%3ASuche Dang, this overrides the user's input with an empty string. 3.) Do both. Works.
Change 174387 had a related patch set uploaded by Thiemo Mättig (WMDE): Fix entitysearch to support Firefox smart keyword https://gerrit.wikimedia.org/r/174387
There is not bug in Firefox. It converts the <input>s in the form to a query string like in HTML. The reason are the two <input>s. Why are there two <input>s? They seams to be redundant. The implementation on mediawiki.org works with one <input>.
Turning an unnamed input into index.php?=%s is clearly a bug in Firefox. I'm not aware of a server side language that supports unnames GET variables. In PHP that would be $_GET['']. I just tried that just to be sure and no, PHP doesn't support this. Again, this doesn't mean we should not work around this issue. See my patch.
Ok, an <input> without name is ignored in the normal transformation from a <form> to a query string. Here has the <input> for which the smart keyword is requested no name. When this <input> get omitted the query string for the smart keyword would have no %s. ?=%s is a comprehensible query string for the smart keyword on a <input> without a name. Generating two <input>s with the same name is a bad solution for this problem. The right solution is to combine the two <input>s to one <input>.