#674744 Wikipedia broke w3m-search-escape-query-string (+ vs. %20)

#674744#5
Date:
2012-05-27 08:46:06 UTC
From:
To:
I use wikipedia as my default search engine:

    (setq
     w3m-search-engine-alist
     '(("google" "http://encrypted.google.com/search?q=%s")
       ;; ("google" "http://google.com.au/search?q=%s")
       ("wikipedia" "https://en.wikipedia.org/wiki/Special:Search/%s")
       ;; ("wikipedia" "http://en.wikipedia.org/wiki/Special:Search/%s")
       ("duckduckgo" "https://duckduckgo.com/lite?q=%s"))
     w3m-search-default-engine "wikipedia")

Around 15 July 2011, this stopped working properly.  It turned out to
be because Wikipedia started treating these links differently:

https://en.wikipedia.org/wiki/Special:Search/foo+bar
https://en.wikipedia.org/wiki/Special:Search/foo%20bar

At that time, I deployed a workaround in my .emacs:

    ;;; Guerilla patch -- redefine this to cat using "%20" instead of "+", since
    ;;; apparently Wikipedia doesn't like the latter anymore.
    (eval-after-load "w3m-search"
      '(defun w3m-search-escape-query-string (str &optional coding)
         (mapconcat
          (lambda (s)
            (w3m-url-encode-string s (or coding w3m-default-coding-system)))
          (split-string str)
          "%20")))

...however this should probably be dealt with upstream.  I do not know
if simply changing + to %20 is the right way to address this, but I
haven't had any problems so far.

PS: sorry I didn't bother to report this sooner...

#674744#10
Date:
2013-07-19 11:03:44 UTC
From:
To:
Hi Trent,

Do you still have a problem?

Currently, foo+bar seems to work.

Thanks,
--
Tatsuya Kinoshita

#674744#15
Date:
2013-07-20 04:19:35 UTC
From:
To:
Tatsuya Kinoshita wrote:

I've been using this patch:

    ;;; Guerilla patch -- http://bugs.debian.org/674744
    (eval-after-load "w3m-search"
      '(defun w3m-search-escape-query-string (str &optional coding)
         (mapconcat
          (lambda (s)
            (w3m-url-encode-string s (or coding w3m-default-coding-system)))
          (split-string str)
          "%20")))

Although now I look at it, this is simpler:

    (eval-after-load "w3m-search"
      '(defun w3m-search-escape-query-string (str &optional coding)
         (w3m-url-encode-string str (or coding w3m-default-coding-system))))

Wikipedia *does* give diffrent results for .../foo+bar and .../foo bar
(encoded as %20 or not).  The former has no exact match, so it goes to
a results page, the latter goes to a specific article.

Do any search engines need "+" instead of " "?
If not, maybe this function should not bother to split and rejoin.

#674744#20
Date:
2013-07-20 05:53:44 UTC
From:
To:
Hi emacs-w3m developers,

Forwarded from Debian bug#674744 <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=674744>:

Thanks,

#674744#25
Date:
2013-07-28 12:36:25 UTC
From:
To:
tags 674744 + upstream
forwarded 674744 http://emacs-w3m.namazu.org/ml/msg11987.html
thanks