Bug 997432 - log failures when MozParams don't include a condition attribute, r=gavin
authorMike Connor <mconnor@mozilla.com>
Wed, 16 Apr 2014 19:35:28 -0400
changeset 179514 9dfe9f74ddd25dc4879f1bb9c0fd3d2ef78ed728
parent 179513 ae057f9c301bd110c96f57dae158e80295eac810
child 179515 f2bd6f0ab7619add682680e9ad1c5e2df7897ded
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
reviewersgavin
bugs997432
milestone31.0a1
Bug 997432 - log failures when MozParams don't include a condition attribute, r=gavin
toolkit/components/search/nsSearchService.js
--- a/toolkit/components/search/nsSearchService.js
+++ b/toolkit/components/search/nsSearchService.js
@@ -1805,16 +1805,25 @@ Engine.prototype = {
           // Ignore failure
           LOG("_parseURL: Url element has an invalid param");
         }
       } else if (param.localName == "MozParam" &&
                  // We only support MozParams for default search engines
                  this._isDefault) {
         var value;
         let condition = param.getAttribute("condition");
+
+        // MozParams must have a condition to be valid
+        if (!condition) {
+          let engineLoc = this._location;
+          let paramName = param.getAttribute("name");
+          LOG("_parseURL: MozParam (" + paramName + ") without a condition attribute found parsing engine: " + engineLoc);
+          continue;
+        }
+
         switch (condition) {
           case "purpose":
             url.addParam(param.getAttribute("name"),
                          param.getAttribute("value"),
                          param.getAttribute("purpose"));
             // _addMozParam is not needed here since it can be serialized fine without. _addMozParam
             // also requires a unique "name" which is not normally the case when @purpose is used.
             break;