From 397be98e9cc54df28d3d7939285e121b047c230a Mon Sep 17 00:00:00 2001 From: "mozilla.mano%sent.com" Date: Mon, 17 Oct 2005 11:32:17 +0000 Subject: [PATCH] Bug 267487 - addSearchEngine should install search plugins from https sites as well as http. patch from O. Atsushi (Torisugari) , r=me, sr=neil. --- browser/components/sidebar/src/nsSidebar.js | 36 ++++++--------------- xpfe/components/sidebar/src/nsSidebar.js | 36 ++++++--------------- 2 files changed, 18 insertions(+), 54 deletions(-) diff --git a/browser/components/sidebar/src/nsSidebar.js b/browser/components/sidebar/src/nsSidebar.js index a934a4501ec..3e6601f3387 100644 --- a/browser/components/sidebar/src/nsSidebar.js +++ b/browser/components/sidebar/src/nsSidebar.js @@ -130,37 +130,19 @@ function (engineURL, iconURL, suggestedTitle, suggestedCategory) try { - // make sure using HTTP (for both engine as well as icon URLs) - - if (engineURL.search(/^http:\/\//i) == -1) - { - debug ("must use HTTP to fetch search engine file"); - throw Components.results.NS_ERROR_INVALID_ARG; - } - - if (iconURL.search(/^http:\/\//i) == -1) - { - debug ("must use HTTP to fetch search icon file"); - throw Components.results.NS_ERROR_INVALID_ARG; - } - - // make sure engineURL refers to a .src file - if (engineURL.search(/\.src$/i) == -1) - { - debug ("engineURL doesn't reference a .src file"); - throw Components.results.NS_ERROR_INVALID_ARG; - } - - // make sure iconURL refers to a .gif/.jpg/.jpeg/.png file - if (iconURL.search(/\.(gif|jpg|jpeg|png)$/i) == -1) - { - debug ("iconURL doesn't reference a supported image file"); - throw Components.results.NS_ERROR_INVALID_ARG; - } + // make sure using HTTP or HTTPS and refering to a .src file + // for the engine. + if (! /^https?:\/\/.+\.src$/i.test(engineURL)) + throw "Unsupported search engine URL"; + // make sure using HTTP or HTTPS and refering to a + // .gif/.jpg/.jpeg/.png file for the icon. + if (! /^https?:\/\/.+\.(gif|jpg|jpeg|png)$/i.test(iconURL)) + throw "Unsupported search icon URL"; } catch(ex) { + debug(ex); this.promptService.alert(null, "Failed to add the search engine."); throw Components.results.NS_ERROR_INVALID_ARG; } diff --git a/xpfe/components/sidebar/src/nsSidebar.js b/xpfe/components/sidebar/src/nsSidebar.js index 7e1a8df1921..95c06f6cc68 100644 --- a/xpfe/components/sidebar/src/nsSidebar.js +++ b/xpfe/components/sidebar/src/nsSidebar.js @@ -249,37 +249,19 @@ function (engineURL, iconURL, suggestedTitle, suggestedCategory) try { - // make sure using HTTP (for both engine as well as icon URLs) - - if (engineURL.search(/^http:\/\//i) == -1) - { - debug ("must use HTTP to fetch search engine file"); - throw Components.results.NS_ERROR_INVALID_ARG; - } - - if (iconURL.search(/^http:\/\//i) == -1) - { - debug ("must use HTTP to fetch search icon file"); - throw Components.results.NS_ERROR_INVALID_ARG; - } - - // make sure engineURL refers to a .src file - if (engineURL.search(/\.src$/i) == -1) - { - debug ("engineURL doesn't reference a .src file"); - throw Components.results.NS_ERROR_INVALID_ARG; - } - - // make sure iconURL refers to a .gif/.jpg/.jpeg/.png file - if (iconURL.search(/\.(gif|jpg|jpeg|png)$/i) == -1) - { - debug ("iconURL doesn't reference a supported image file"); - throw Components.results.NS_ERROR_INVALID_ARG; - } + // make sure using HTTP or HTTPS and refering to a .src file + // for the engine. + if (! /^https?:\/\/.+\.src$/i.test(engineURL)) + throw "Unsupported search engine URL"; + // make sure using HTTP or HTTPS and refering to a + // .gif/.jpg/.jpeg/.png file for the icon. + if (! /^https?:\/\/.+\.(gif|jpg|jpeg|png)$/i.test(iconURL)) + throw "Unsupported search icon URL"; } catch(ex) { + debug(ex); this.promptService.alert(null, "Failed to add the search engine."); throw Components.results.NS_ERROR_INVALID_ARG; }