From 807a83f6fdffbb20aa54701e2545a03b92823edb Mon Sep 17 00:00:00 2001 From: "gavin%gavinsharp.com" Date: Tue, 20 Jun 2006 05:07:00 +0000 Subject: [PATCH] Bug 341908: make sure we deal with invalid templates correctly, r=mconnor --- browser/components/search/nsSearchService.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/browser/components/search/nsSearchService.js b/browser/components/search/nsSearchService.js index a93ff13ba497..6376d0fab3cd 100755 --- a/browser/components/search/nsSearchService.js +++ b/browser/components/search/nsSearchService.js @@ -707,8 +707,24 @@ function EngineURL(aType, aMethod, aTemplate) { this.type = type; this.method = method; - this.template = aTemplate; this.params = []; + + var templateURI = makeURI(aTemplate); + ENSURE(templateURI, "new EngineURL: template is not a valid URI!", + Cr.NS_ERROR_FAILURE); + + switch (templateURI.scheme) { + case "http": + case "https": + // Disable these for now, see bug 295018 + // case "file": + // case "resource": + this.template = templateURI.spec; + break; + default: + ENSURE(false, "new EngineURL: template uses invalid scheme!", + Cr.NS_ERROR_FAILURE); + } } EngineURL.prototype = {