X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=common%2Fmodules%2Futil.jsm;fp=common%2Fmodules%2Futil.jsm;h=c5cd610fbcf8ecf6fabc31dea584a43331857e59;hb=5ebd29f56d17f62011cdd596b1d351947ee534ff;hp=9cc4a49e99779bb3f33bb891c3b54ae1ec2d0a96;hpb=9044153cb63835e39b9de8ec4ade237c03e3888a;p=dactyl.git diff --git a/common/modules/util.jsm b/common/modules/util.jsm index 9cc4a49..c5cd610 100644 --- a/common/modules/util.jsm +++ b/common/modules/util.jsm @@ -627,10 +627,10 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), */ formatSeconds: function formatSeconds(seconds) { function pad(n, val) ("0000000" + val).substr(-Math.max(n, String(val).length)); - function div(num, denom) [Math.round(num / denom), Math.round(num % denom)]; + function div(num, denom) [Math.floor(num / denom), Math.round(num % denom)]; let days, hours, minutes; - [minutes, seconds] = div(seconds, 60); + [minutes, seconds] = div(Math.round(seconds), 60); [hours, minutes] = div(minutes, 60); [days, hours] = div(hours, 24); if (days) @@ -710,6 +710,8 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), * responseType: {string} Override the type of the "response" * property. * + * headers: {objects} Extra request headers. + * * user: {string} The user name to send via HTTP Authentication. * pass: {string} The password to send via HTTP Authentication. * @@ -749,12 +751,18 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), params.data = data; } - if (params.mimeType) xmlhttp.overrideMimeType(params.mimeType); - xmlhttp.open(params.method || "GET", url, async, - params.user, params.pass); + let args = [params.method || "GET", url, async]; + if (params.user != null || params.pass != null) + args.push(params.user); + if (params.pass != null) + args.push(prams.pass); + xmlhttp.open.apply(xmlhttp, args); + + for (let [header, val] in Iterator(params.headers || {})) + xmlhttp.setRequestHeader(header, val); if (params.responseType) xmlhttp.responseType = params.responseType; @@ -1308,7 +1316,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), * Escapes a string against shell meta-characters and argument * separators. */ - shellEscape: function shellEscape(str) '"' + String.replace(str, /[\\"$]/g, "\\$&") + '"', + shellEscape: function shellEscape(str) '"' + String.replace(str, /[\\"$`]/g, "\\$&") + '"', /** * Suspend execution for at least *delay* milliseconds. Functions by