-// Copyright (c) 2008-2011 by Kris Maglione <maglione.k@gmail.com>
+// Copyright (c) 2008-2012 Kris Maglione <maglione.k@gmail.com>
//
// This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file.
-/* use strict */
+"use strict";
-Components.utils.import("resource://dactyl/bootstrap.jsm");
defineModule("protocol", {
exports: ["LocaleChannel", "Protocol", "RedirectChannel", "StringChannel", "XMLChannel"],
require: ["services", "util"]
-}, this);
+});
var systemPrincipal = Cc["@mozilla.org/systemprincipal;1"].getService(Ci.nsIPrincipal);
}).data.QueryInterface(Ci.nsIChannel);
}
function RedirectChannel(to, orig, time, message) {
- let html = <html><head><meta http-equiv="Refresh" content={(time || 0) + ";" + to}/></head>
- <body><h2 style="text-align: center">{message || ""}</h2></body></html>.toXMLString();
+ let html = DOM.toXML(
+ ["html", {},
+ ["head", {},
+ ["meta", { "http-equiv": "Refresh", content: (time || 0) + ";" + to }]],
+ ["body", {},
+ ["h2", { style: "text-align: center" }, message || ""]]]);
return StringChannel(html, "text/html", services.io.newURI(to, null, null));
}
let type = this.channel.contentType;
if (/^text\/|[\/+]xml$/.test(type)) {
let stream = services.InputStream(channelStream);
- let [, pre, doctype, url, extra, open, post] = util.regexp(<![CDATA[
+ let [, pre, doctype, url, extra, open, post] = util.regexp(literal(/*
^ ([^]*?)
(?:
(<!DOCTYPE \s+ \S+ \s+) (?:SYSTEM \s+ "([^"]*)" | ((?:[^[>\s]|\s[^[])*))
([^]*)
)?
$
- ]]>, "x").exec(stream.read(4096));
+ */), "x").exec(stream.read(4096));
this.writes.push(pre);
if (doctype) {
this.writes.push(doctype + (extra || "") + " [\n");
this.writes.push(services.io.newChannel(url, null, this.uri).open());
}
catch (e) {
+ util.dump("addChannel('" + url + "'):");
util.reportError(e);
}
},