[pmwiki-users] Custom markup with search data in URL
Patrick R. Michaud
pmichaud at pobox.com
Tue Jun 21 12:51:48 CDT 2005
On Tue, Jun 21, 2005 at 11:20:17AM -0500, Chris Cox wrote:
> http://www.wikipedia.com/wiki/Special:Search?search="impress me"&go=Go
>
> Now that would work just fine in a URL to a browser... though not
> ideal... should read:
>
> http://www.wikipedia.com/wiki/Special:Search?search=%22impress+me%22&go=Go
>
> HOWEVER, pmwiki is changing the item area to...
> %22impress%20me%22
>
> and it's shows up in my url line when I go to wikipedia as:
> http://en.wikipedia.org/wiki/Special:Search?search=%252522impress%252520me%252522&go=Go
Short answer: The problem is almost certainly at Wikipedia -- I've set up
a test page at http://www.pmichaud.com/sandbox/quotelinks.php, and
you'll see that all of the formulations of this URL result in the
problem you're seeing, even when PmWiki isn't present.
Medium answer: www.wikipedia.com appears to forward the browser to
en.wikipedia.com for the search results. I suspect that in doing so
www.wikipedia.com isn't properly encoding the url used in the
forward link.
Long answer: PmWiki is actually encoding things according to the
standards. Although HTML recommends converting spaces into '+' characters,
the URL standards (RFC 3986 and formerly 2396) allow spaces to be
encoded as %20. Technically, url generating software (PmWiki) is
allowed to %-encode any of the characters of the url, although
encoding characters from the set [A-Za-z0-9._~-] is discouraged.
PmWiki chooses to encode " and ' characters because they will
appear in the href= attribute of an <a> tag, which itself will
have quotes of some sort. PmWiki encodes the space character as
%20, because although space can be encoded as '+' in the query
portion of a url, it cannot be a '+' in the path portion of a url
and must be encoded as %20.
So, with
http://www.wikipedia.com/wiki/Special:Search?search="impress me"&go=Go
PmWiki simply converts this into a valid href:
http://www.wikipedia.com/wiki/Special:Search?search=%22impress%20me%22&go=Go
and all tends to work.
Although I am indeed surprised that Wikipedia isn't handling
the url correctly. :-)
Pm
More information about the pmwiki-users
mailing list