]> git.donarmstrong.com Git - dactyl.git/blobdiff - common/modules/protocol.jsm
Import 1.0 supporting Firefox up to 14.*
[dactyl.git] / common / modules / protocol.jsm
index 98d8e3bcab7d0f466869aacc4ce339b2a6d330f1..edb642ecb888aff28704bdaa6f011a0ae69d9c03 100644 (file)
@@ -142,7 +142,7 @@ ProtocolBase.prototype = {
 function LocaleChannel(pkg, locale, path, orig) {
     for each (let locale in [locale, "en-US"])
         for each (let sep in "-/") {
-            var channel = Channel(["resource:/", pkg + sep + locale, path].join("/"), orig, true);
+            var channel = Channel(["resource:/", pkg + sep + locale, path].join("/"), orig, true, true);
             if (channel)
                 return channel;
         }
@@ -182,31 +182,34 @@ function XMLChannel(uri, contentType, noErrorChannel, unprivileged) {
     this.channel.contentType = contentType || channel.contentType;
     this.channel.contentCharset = "UTF-8";
     if (!unprivileged)
-    this.channel.owner = systemPrincipal;
-
-    let stream = services.InputStream(channelStream);
-    let [, pre, doctype, url, extra, open, post] = util.regexp(<![CDATA[
-            ^ ([^]*?)
-            (?:
-                (<!DOCTYPE \s+ \S+ \s+) (?:SYSTEM \s+ "([^"]*)" | ((?:[^[>\s]|\s[^[])*))
-                (\s+ \[)?
-                ([^]*)
-            )?
-            $
-        ]]>, "x").exec(stream.read(4096));
-    this.writes.push(pre);
-    if (doctype) {
-        this.writes.push(doctype + (extra || "") + " [\n");
-        if (url)
-            this.addChannel(url);
-
-        if (!open)
-            this.writes.push("\n]");
-
-        for (let [, pre, url] in util.regexp.iterate(/([^]*?)(?:%include\s+"([^"]*)";|$)/gy, post)) {
-            this.writes.push(pre);
+        this.channel.owner = systemPrincipal;
+
+    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[
+                ^ ([^]*?)
+                (?:
+                    (<!DOCTYPE \s+ \S+ \s+) (?:SYSTEM \s+ "([^"]*)" | ((?:[^[>\s]|\s[^[])*))
+                    (\s+ \[)?
+                    ([^]*)
+                )?
+                $
+            ]]>, "x").exec(stream.read(4096));
+        this.writes.push(pre);
+        if (doctype) {
+            this.writes.push(doctype + (extra || "") + " [\n");
             if (url)
                 this.addChannel(url);
+
+            if (!open)
+                this.writes.push("\n]");
+
+            for (let [, pre, url] in util.regexp.iterate(/([^]*?)(?:%include\s+"([^"]*)";|$)/gy, post)) {
+                this.writes.push(pre);
+                if (url)
+                    this.addChannel(url);
+            }
         }
     }
     this.writes.push(channelStream);