зеркало из https://github.com/mozilla/pjs.git
Bug 342010: allow FTP for search-engine URIs and icons. r+a181=mconnor
This commit is contained in:
Родитель
83bff06fa8
Коммит
36b780bc28
|
@ -2957,7 +2957,7 @@ const BrowserSearch = {
|
||||||
var etitle = target.title;
|
var etitle = target.title;
|
||||||
var ehref = target.href;
|
var ehref = target.href;
|
||||||
const searchRelRegex = /(^|\s)search($|\s)/i;
|
const searchRelRegex = /(^|\s)search($|\s)/i;
|
||||||
const searchHrefRegex = /^https?:\/\//i;
|
const searchHrefRegex = /^(https?|ftp):\/\//i;
|
||||||
|
|
||||||
if (!etype)
|
if (!etype)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -99,7 +99,7 @@ const OPENSEARCH_NS_11 = "http://a9.com/-/spec/opensearch/1.1/";
|
||||||
|
|
||||||
// Although the specification at http://opensearch.a9.com/spec/1.1/description/
|
// Although the specification at http://opensearch.a9.com/spec/1.1/description/
|
||||||
// gives the namespace names defined above, many existing OpenSearch engines
|
// gives the namespace names defined above, many existing OpenSearch engines
|
||||||
// are using the former versions. We therefore allow either.
|
// are using the following versions. We therefore allow either.
|
||||||
const OPENSEARCH_NAMESPACES = [ OPENSEARCH_NS_11, OPENSEARCH_NS_10,
|
const OPENSEARCH_NAMESPACES = [ OPENSEARCH_NS_11, OPENSEARCH_NS_10,
|
||||||
"http://a9.com/-/spec/opensearchdescription/1.1/",
|
"http://a9.com/-/spec/opensearchdescription/1.1/",
|
||||||
"http://a9.com/-/spec/opensearchdescription/1.0/"];
|
"http://a9.com/-/spec/opensearchdescription/1.0/"];
|
||||||
|
@ -845,6 +845,7 @@ function Engine(aLocation, aSourceDataType, aIsReadOnly) {
|
||||||
switch (aLocation.scheme) {
|
switch (aLocation.scheme) {
|
||||||
case "https":
|
case "https":
|
||||||
case "http":
|
case "http":
|
||||||
|
case "ftp":
|
||||||
case "data":
|
case "data":
|
||||||
case "file":
|
case "file":
|
||||||
case "resource":
|
case "resource":
|
||||||
|
@ -1046,10 +1047,10 @@ Engine.prototype = {
|
||||||
* Sets the .iconURI property of the engine.
|
* Sets the .iconURI property of the engine.
|
||||||
*
|
*
|
||||||
* @param aIconURL
|
* @param aIconURL
|
||||||
* A URI string pointing to the engine's icon. Must have a http[s] or
|
* A URI string pointing to the engine's icon. Must have a http[s],
|
||||||
* data scheme. Icons with HTTP[S] schemes will be downloaded and
|
* ftp, or data scheme. Icons with HTTP[S] or FTP schemes will be
|
||||||
* converted to data URIs for storage in the engine XML files, if
|
* downloaded and converted to data URIs for storage in the engine
|
||||||
* the engine is not readonly.
|
* XML files, if the engine is not readonly.
|
||||||
* @param aIsPreferred
|
* @param aIsPreferred
|
||||||
* Whether or not this icon is to be preferred. Preferred icons can
|
* Whether or not this icon is to be preferred. Preferred icons can
|
||||||
* override non-preferred icons.
|
* override non-preferred icons.
|
||||||
|
@ -1068,7 +1069,7 @@ Engine.prototype = {
|
||||||
|
|
||||||
LOG("_setIcon: Setting icon url \"" + uri.spec + "\" for engine \""
|
LOG("_setIcon: Setting icon url \"" + uri.spec + "\" for engine \""
|
||||||
+ this.name + "\".");
|
+ this.name + "\".");
|
||||||
// Only accept remote icons from http[s]
|
// Only accept remote icons from http[s] or ftp
|
||||||
switch (uri.scheme) {
|
switch (uri.scheme) {
|
||||||
case "data":
|
case "data":
|
||||||
this._iconURI = uri;
|
this._iconURI = uri;
|
||||||
|
@ -1077,6 +1078,7 @@ Engine.prototype = {
|
||||||
break;
|
break;
|
||||||
case "http":
|
case "http":
|
||||||
case "https":
|
case "https":
|
||||||
|
case "ftp":
|
||||||
// No use downloading the icon if the engine file is read-only
|
// No use downloading the icon if the engine file is read-only
|
||||||
// XXX could store the data: URI in a pref... ew?
|
// XXX could store the data: URI in a pref... ew?
|
||||||
if (!this._readOnly) {
|
if (!this._readOnly) {
|
||||||
|
|
|
@ -191,16 +191,16 @@ function (engineURL, expectedSuffix, iconURL)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// make sure using HTTP or HTTPS and refering to the expected kind of file
|
// make sure using HTTP, HTTPS, or FTP and refering to the expected kind of file
|
||||||
// for the engine.
|
// for the engine.
|
||||||
const engineRegexp = new RegExp("^https?:\/\/.+\." + expectedSuffix + "$", "i");
|
const engineRegexp = new RegExp("^(https?|ftp):\/\/.+\." + expectedSuffix + "$", "i");
|
||||||
if (! engineRegexp.test(engineURL))
|
if (! engineRegexp.test(engineURL))
|
||||||
throw "Unsupported search engine URL";
|
throw "Unsupported search engine URL";
|
||||||
|
|
||||||
// make sure using HTTP or HTTPS and refering to a
|
// make sure using HTTP, HTTPS, or FTP and refering to a
|
||||||
// .gif/.jpg/.jpeg/.png/.ico file for the icon.
|
// .gif/.jpg/.jpeg/.png/.ico file for the icon.
|
||||||
if (iconURL &&
|
if (iconURL &&
|
||||||
! /^https?:\/\/.+\.(gif|jpg|jpeg|png|ico)$/i.test(iconURL))
|
! /^(https?|ftp):\/\/.+\.(gif|jpg|jpeg|png|ico)$/i.test(iconURL))
|
||||||
throw "Unsupported search icon URL.";
|
throw "Unsupported search icon URL.";
|
||||||
}
|
}
|
||||||
catch(ex)
|
catch(ex)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче