我在Firefox搜索栏中添加了自定义搜索引擎。当我在那里输入时,例如"我是谁?",它会以"Who+am+it%253F"的形式传递到自定义搜索引擎,而不是预期的"Who+am+it%3F"。结果是搜索引擎返回空的结果集。
它在Chrome上运行良好。
还尝试了其他一些OpenSearch搜索引擎,例如维基百科或DuckDuckGo,它们在同一个Firefox中运行得很好。
你知道问题的根源是什么吗?
看起来searchTerms被编码了两次或类似的内容。
这是XML使用的
<?xml version="1.0"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
<ShortName>ShortName</ShortName>
<LongName>LongName</LongName>
<Description>Description</Description>
<Tags>discussions friends articles</Tags>
<Contact>admin@domain.com</Contact>
<Url type="text/html" method="get" template="URL?param=value&query={searchTerms}"/>
<Image height="16" width="16" type="image/x-icon">URL/favicon.ico</Image>
<Image height="64" width="64" type="image/png">URL/nikoscope64.png</Image>
<Query role="example" searchTerms="st" />
<AdultContent>false</AdultContent>
<Language>en-us</Language>
<InputEncoding>UTF-8</InputEncoding>
<OutputEncoding>UTF-8</OutputEncoding>
</OpenSearchDescription>
问题的来源似乎是Url.template,它使用HTTP协议指向结果页,尽管服务器运行在HTTPS上。
更改此部分:
<Url type="text/html" method="get" template="http://SOME_DOMAIN?param=value&query={searchTerms}"/>
进入
<Url type="text/html" method="get" template="https://SOME_DOMAIN?param=value&query={searchTerms}"/>
解决了问题。请注意,清空浏览器缓存不足以获得新版本的OpenSearch XML。需要删除并重新添加搜索引擎