aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2010-09-10 21:42:53 +0200
committerMatěj Cepl <mcepl@redhat.com>2010-09-10 21:42:53 +0200
commitf2f034c968d00874c234c0ce20bb9a2a978a8e61 (patch)
tree785692eec8dab2eb821e5ac104d839510f629ebd
parent07a9f4248c978771e55dc9054238ff03a4d6865c (diff)
downloadbugzilla-triage-f2f034c968d00874c234c0ce20bb9a2a978a8e61.tar.gz
Make certain that this.bugNo is really numerical value of bug number.
Fixes #45 * move getLogin and getPassword to bzpage (upstream bugzilla actually has SOME XML-RPC) * don't test for correct bug number in logger, when we have the bug no. correct in the first place.
-rw-r--r--lib/bzpage.js46
-rw-r--r--lib/logger.js5
2 files changed, 15 insertions, 36 deletions
diff --git a/lib/bzpage.js b/lib/bzpage.js
index 998e64d..608e21e 100644
--- a/lib/bzpage.js
+++ b/lib/bzpage.js
@@ -12,7 +12,6 @@ var simpleStorage = require("simple-storage");
var preferences = require("preferences-service");
var selection = require("selection");
var prompts = require("prompts");
-var xrpc = require("xmlrpc");
var Request = require("request").Request;
var tabs = require("tabs");
var Color = require("color").Color;
@@ -113,7 +112,7 @@ var BZPage = function BZPage(win, config) {
}
this.bugNo = util.getBugNo(this.doc.location.toString());
-
+
// deal with aliases
if (isNaN(parseInt(this.bugNo, 10)) && this.password) {
this.bugNo = this.getRealBugNo();
@@ -151,43 +150,28 @@ BZPage.prototype.getBugId = function getBugId () {
return util.getBugNo(this.doc.location.href);
};
+/**
+ * In case URL contains alias, not the real bug number, get the real bug no
+ * from the XML representation. Sets correct value to this.bugNo.
+ */
BZPage.prototype.getRealBugNo = function () {
- console.log("we have to deal with bug aliased as " + this.bugNo);
+ console.log("We have to deal with bug aliased as " + this.bugNo);
var that = this;
-
// https://bugzilla.redhat.com/show_bug.cgi?ctype=xml&id=serialWacom
-
- var xmlrpcMsg = new xrpc.XMLRPCMessage("User.login");
- xmlrpcMsg.addParameter({
- login: this.login,
- password: this.password,
- remember: 1
- });
Request({
- url: this.constantData.XMLRPCData[this.hostname].url,
+ url: this.win.location.href+"&ctype=xml",
onComplete: function() {
if (this.response.status == 200) {
- xmlrpcMsg = new xrpc.XMLRPCMessage("Bug.get");
- xmlrpcMsg.addParameter({
- ids: util.getParamsFromURL(that.win.location.href)['id']
- });
- console.log("XML-RPC message:\n" + xmlrpcMsg.xml());
- Request({
- url: that.constantData.XMLRPCData[that.hostname].url,
- onComplete: function() {
- if (this.response.status === 200) {
- console.log("response = " + this.response.text);
- //if
- }
- },
- content: xmlrpcMsg.xml(),
- contentType: "text/xml"
- }).post();
+ var xmlRepr = this.response.xml;
+ var bugID = parseInt(xmlRepr.getElementsByTagName("bug_id")[0].textContent, 10);
+ if (isNaN(bugID)) {
+ throw new Error("Cannot get bug no. even from XML representation!");
+ }
+ that.bugNo = bugID;
+ console.log("The real bug no. is " + bugID);
}
},
- content: xmlrpcMsg.xml(),
- contentType: "text/xml"
- }).post();
+ }).get();
};
/**
diff --git a/lib/logger.js b/lib/logger.js
index 1175bf8..1936ad5 100644
--- a/lib/logger.js
+++ b/lib/logger.js
@@ -82,11 +82,6 @@ Logger.prototype.timeSheetRecordsPrinter = function(body, records) {
var host = urlMod.URL(x.url).host;
var BZName = that.getBugzillaAbbr(x.url);
var bugNo = utilMod.getBugNo(x.url);
- // protection against misbehaving URLs
- if (!bugNo) {
- console.error("wrong record:\n" + rec.toSource() + "\n");
- return false;
- }
if (dayStr != currentDay) {
currentDay = dayStr;
body.innerHTML += "<hr/><p><strong>" + currentDay