mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 04:15:43 +00:00
Bug 566079 - Trim the textContent of data received from the AMO API [r=dtownsend]
This commit is contained in:
parent
c7c99bf983
commit
6c5c7f51f9
@ -208,17 +208,19 @@ AddonRepository.prototype = {
|
||||
getService(Ci.nsIXULAppInfo).
|
||||
QueryInterface(Ci.nsIXULRuntime);
|
||||
|
||||
var guid = element.getElementsByTagName("guid");
|
||||
if (guid.length != 1)
|
||||
var guidList = element.getElementsByTagName("guid");
|
||||
if (guidList.length != 1)
|
||||
return;
|
||||
|
||||
var guid = guidList[0].textContent.trim();
|
||||
|
||||
// Ignore add-ons already seen in the results
|
||||
for (var i = 0; i < this._addons.length; i++)
|
||||
if (this._addons[i].id == guid[0].textContent)
|
||||
if (this._addons[i].id == guid)
|
||||
return;
|
||||
|
||||
// Ignore installed add-ons
|
||||
if (known_ids.indexOf(guid[0].textContent) != -1)
|
||||
if (known_ids.indexOf(guid) != -1)
|
||||
return;
|
||||
|
||||
// Ignore sandboxed add-ons
|
||||
@ -228,14 +230,15 @@ AddonRepository.prototype = {
|
||||
return;
|
||||
|
||||
// Ignore add-ons not compatible with this OS
|
||||
var os = element.getElementsByTagName("compatible_os");
|
||||
var osList = element.getElementsByTagName("compatible_os");
|
||||
// Only the version 0 schema included compatible_os if it isn't there then
|
||||
// we will see os compatibility on the install elements.
|
||||
if (os.length > 0) {
|
||||
if (osList.length > 0) {
|
||||
var compatible = false;
|
||||
var i = 0;
|
||||
while (i < os.length && !compatible) {
|
||||
if (os[i].textContent == "ALL" || os[i].textContent == app.OS) {
|
||||
while (i < osList.length && !compatible) {
|
||||
var os = osList[i].textContent.trim();
|
||||
if (os == "ALL" || os == app.OS) {
|
||||
compatible = true;
|
||||
break;
|
||||
}
|
||||
@ -255,9 +258,10 @@ AddonRepository.prototype = {
|
||||
var apps = tags[0].getElementsByTagName("appID");
|
||||
var i = 0;
|
||||
while (i < apps.length) {
|
||||
if (apps[i].textContent == app.ID) {
|
||||
var minversion = apps[i].parentNode.getElementsByTagName("min_version")[0].textContent;
|
||||
var maxversion = apps[i].parentNode.getElementsByTagName("max_version")[0].textContent;
|
||||
if (apps[i].textContent.trim() == app.ID) {
|
||||
var parent = apps[i].parentNode;
|
||||
var minversion = parent.getElementsByTagName("min_version")[0].textContent.trim();
|
||||
var maxversion = parent.getElementsByTagName("max_version")[0].textContent.trim();
|
||||
if ((vc.compare(minversion, app.version) > 0) ||
|
||||
(vc.compare(app.version, maxversion) > 0))
|
||||
return;
|
||||
@ -270,7 +274,7 @@ AddonRepository.prototype = {
|
||||
return;
|
||||
|
||||
var addon = new AddonSearchResult();
|
||||
addon.id = guid[0].textContent;
|
||||
addon.id = guid;
|
||||
addon.rating = -1;
|
||||
var node = element.firstChild;
|
||||
while (node) {
|
||||
@ -281,7 +285,7 @@ AddonRepository.prototype = {
|
||||
case "summary":
|
||||
case "description":
|
||||
case "eula":
|
||||
addon[node.localName] = node.textContent;
|
||||
addon[node.localName] = node.textContent.trim();
|
||||
break;
|
||||
case "rating":
|
||||
if (node.textContent.length > 0) {
|
||||
@ -291,13 +295,13 @@ AddonRepository.prototype = {
|
||||
}
|
||||
break;
|
||||
case "thumbnail":
|
||||
addon.thumbnailURL = node.textContent;
|
||||
addon.thumbnailURL = node.textContent.trim();
|
||||
break;
|
||||
case "icon":
|
||||
addon.iconURL = node.textContent;
|
||||
addon.iconURL = node.textContent.trim();
|
||||
break;
|
||||
case "learnmore":
|
||||
addon.homepageURL = node.textContent;
|
||||
addon.homepageURL = node.textContent.trim();
|
||||
break;
|
||||
case "type":
|
||||
// The type element has an id attribute that is the id from AMO's
|
||||
@ -315,7 +319,7 @@ AddonRepository.prototype = {
|
||||
if (os != "all" && os != app.OS.toLowerCase())
|
||||
break;
|
||||
}
|
||||
addon.xpiURL = node.textContent;
|
||||
addon.xpiURL = node.textContent.trim();
|
||||
if (node.hasAttribute("hash"))
|
||||
addon.xpiHash = node.getAttribute("hash");
|
||||
break;
|
||||
|
@ -81,8 +81,12 @@
|
||||
<guid>test5@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<status id='4'>Public</status>
|
||||
<summary>This should work fine</summary>
|
||||
<description>Test description</description>
|
||||
<summary>
|
||||
This should work fine
|
||||
</summary>
|
||||
<description>
|
||||
Test description
|
||||
</description>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>XPCShell</name>
|
||||
@ -92,8 +96,12 @@
|
||||
<max_version>1</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<learnmore>https://addons.mozilla.org/addon/5992</learnmore>
|
||||
<install os="ALL" hash="sha1:c26f0b0d62e5dcddcda95074d3f3fedb9bbc26e3">http://localhost:4444/test.xpi</install>
|
||||
<learnmore>
|
||||
https://addons.mozilla.org/addon/5992
|
||||
</learnmore>
|
||||
<install os="ALL" hash="sha1:c26f0b0d62e5dcddcda95074d3f3fedb9bbc26e3">
|
||||
http://localhost:4444/test.xpi
|
||||
</install>
|
||||
</addon>
|
||||
<addon>
|
||||
<name>FAIL</name>
|
||||
@ -141,8 +149,12 @@
|
||||
<rating>4</rating>
|
||||
<summary>Specific OS should work fine</summary>
|
||||
<eula>EULA should be confirmed</eula>
|
||||
<thumbnail>http://localhost:4444/test_bug404024/thumbnail.png</thumbnail>
|
||||
<icon>http://localhost:4444/test_bug404024/icon.png</icon>
|
||||
<thumbnail>
|
||||
http://localhost:4444/test_bug404024/thumbnail.png
|
||||
</thumbnail>
|
||||
<icon>
|
||||
http://localhost:4444/test_bug404024/icon.png
|
||||
</icon>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>XPCShell</name>
|
||||
@ -152,9 +164,15 @@
|
||||
<max_version>1</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<install os="Windows">http://localhost:4444/test.xpi</install>
|
||||
<install os="XPCShell">http://localhost:4444/XPCShell.xpi</install>
|
||||
<install os="Darwin">http://localhost:4444/test.xpi</install>
|
||||
<install os="Windows">
|
||||
http://localhost:4444/test.xpi
|
||||
</install>
|
||||
<install os="XPCShell">
|
||||
http://localhost:4444/XPCShell.xpi
|
||||
</install>
|
||||
<install os="Darwin">
|
||||
http://localhost:4444/test.xpi
|
||||
</install>
|
||||
</addon>
|
||||
</searchresults>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user