Bug 1097364 - Support <OpenSearchDescription> as the root tag of a search plugin. r=bnicholson
authorMargaret Leibovic <margaret.leibovic@gmail.com>
Wed, 12 Nov 2014 07:38:03 -0800
changeset 215279 7db83e0a413721c08ae2917f94d78c1864b6146a
parent 215278 248de75efd24329f2d9af8e04e93ddffa70f9672
child 215280 882f3497f8aaea2ab89c6729262576bf80973c26
push id51731
push userryanvm@gmail.com
push dateWed, 12 Nov 2014 20:52:34 +0000
treeherdermozilla-inbound@90731dbaab2d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbnicholson
bugs1097364
milestone36.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1097364 - Support <OpenSearchDescription> as the root tag of a search plugin. r=bnicholson
mobile/android/search/java/org/mozilla/search/providers/SearchEngine.java
--- a/mobile/android/search/java/org/mozilla/search/providers/SearchEngine.java
+++ b/mobile/android/search/java/org/mozilla/search/providers/SearchEngine.java
@@ -69,17 +69,26 @@ public class SearchEngine {
 
         final XmlPullParser parser = Xml.newPullParser();
         parser.setInput(in, null);
         parser.nextTag();
         readSearchPlugin(parser);
     }
 
     private void readSearchPlugin(XmlPullParser parser) throws XmlPullParserException, IOException {
-        parser.require(XmlPullParser.START_TAG, null, "SearchPlugin");
+        if (XmlPullParser.START_TAG != parser.getEventType()) {
+            throw new XmlPullParserException("Expected start tag: " + parser.getPositionDescription());
+        }
+
+        final String name = parser.getName();
+        if (!"SearchPlugin".equals(name) && !"OpenSearchDescription".equals(name)) {
+            throw new XmlPullParserException("Expected <SearchPlugin> or <OpenSearchDescription> as root tag: "
+                + parser.getPositionDescription());
+        }
+
         while (parser.next() != XmlPullParser.END_TAG) {
             if (parser.getEventType() != XmlPullParser.START_TAG) {
                 continue;
             }
 
             final String tag = parser.getName();
             if (tag.equals("ShortName")) {
                 readShortName(parser);