Closed Bug 236097 Opened 20 years ago Closed 11 years ago

RFE: Multiple parameters for custom keywords

Categories

(Firefox :: Bookmarks & History, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED WONTFIX

People

(Reporter: bugzilla, Unassigned)

References

(Blocks 1 open bug)

Details

User-Agent:       
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6) Gecko/20040206 Firefox/0.8

Currently you can only specify one parameter for custom keyword searches or
queries, using %s. This potentially limits the input you can pass to specific
websites where it may be advantageous to use custom keywords. Example below,
quoted from <a href="http://forums.mozillazine.org/viewtopic.php?t=57271">more
identifiers like %s - MozillaZine Forums</a>.

------- Quote --------
for example: the 3 strings between the '*' in the following link are editable
http://www.tvtoday.de/tv/programm/programm.php?ztag=1&sparte=*alle*&uhrzeit=Ax*01*&sender=*HS*
(if you want to visit that page you have to remove the '*')

So my question: are there more identifiers like '%s' so that i can edit all 3
variables? (I want to type something like 'tv [time] [sender] [genre]'
------- End Quote --------

It would also be useful for currency conversion websites.

I would suggest that the bookmark should be able to store %s, %s1, %s2, %s3 and
so on, and that a specific character is used to differentiate between them in
the location bar, such as ~ or something which is generally not searched for.

Reproducible: Always
Steps to Reproduce:
See also bug 124237, same bug for Seamonkey.
*** Bug 252677 has been marked as a duplicate of this bug. ***
Assignee: firefox → vladimir+bm
Component: General → Bookmarks
QA Contact: mconnor
Version: unspecified → Trunk
*** Bug 274861 has been marked as a duplicate of this bug. ***
Assignee: vladimir+bm → nobody
sorry for bugspam, long-overdue mass reassign of ancient QA contact bugs, filter on "beltznerLovesGoats" to get rid of this mass change
QA Contact: mconnor → bookmarks
I think %s and %S would still have to be the full argument list, otherwise everyone's keywords are broken. Quotes seem like the obvious choice to allow for arguments with a space (kwd "a b" c), but that can be a pain (escaped quotes, etc).

http://lxr.mozilla.org/mozilla/source/browser/base/content/browser.js#1728

1762     if (matches)
1763       [, shortcutURL, charset] = matches;
1764     else {
1765       //XXX Bug 317472 will add lastCharset support to places.
1766     }

    var params = param.split(/[ ]+/);

    for (var i = 0; i < params.length; i++) {
      var encodedParam = "";

      if (charset)
        encodedParam = escape(converFromUnicode(charset, params[i]));
      else // Default charset is UTF-8
        encodedParam = encodeURIComponent(params[i]);

      var n = i + 1;

      shortcutURL = shortcutURL.replace('%s' + n, encodedParam)
                               .replace('%S' + n, param);
    }

1768     var encodedParam = "";
1769     if (charset)
1770       encodedParam = escape(converFromUnicode(charset, param));
1771     else // Default charset is UTF-8
1772       encodedParam = encodeURIComponent(param);
1773 
1774     shortcutURL = shortcutURL.replace(/%s/g, encodedParam).replace(/%S/g, param);

There's no quote handling in the above and there would be problems with missing arguments. Since %s/%S still has to run, a bookmark with 3 argument slots (http://localhost/?a=%s1&b=%s2&c=%s3&z=%s) but only 2 arguments passed would result in %s3 being turned into [arguments]3.

If a maximum argument length was set (9), you could:

    var params = param.split(/[ ]+/);

    for (var i = 0; i < 9; i++) {
      var n = i + 1;

      if (i < params.length) {
        var encodedParam = "";

        if (charset)
          encodedParam = escape(converFromUnicode(charset, params[i]));
        else // Default charset is UTF-8
          encodedParam = encodeURIComponent(params[i]);

        shortcutURL = shortcutURL.replace('%s' + n, encodedParam)
                                 .replace('%S' + n, param);
      } else {
        shortcutURL = shortcutURL.replace('%s' + n, '').replace('%S' + n, '');
      }
    }

I don't think it'd be very common to have %s followed by a number (http://localhost/?a=%s6tx), but that could be another issue.
Oops, some of that code is broken. The %S substitutions are still using 'param' instead of 'params[i]', but you get the idea.
Having multiple parameters for keywords is really only going to be useful to a handful of highly technical users (who also have to discover the feature). It would be better implemented by an add-on.
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.