From 97ff27f575bb16c9a217426e7b7993c75566100d Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Thu, 26 Jan 2012 19:22:22 -0500 Subject: [PATCH] Fix bug. --- common/modules/protocol.jsm | 47 ++++++++++++++++++++----------------- common/modules/util.jsm | 2 +- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/common/modules/protocol.jsm b/common/modules/protocol.jsm index d2ba9e9b..7acb2e97 100644 --- a/common/modules/protocol.jsm +++ b/common/modules/protocol.jsm @@ -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; + this.channel.owner = systemPrincipal; - let stream = services.InputStream(channelStream); - let [, pre, doctype, url, extra, open, post] = util.regexp(\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); + let type = this.channel.contentType; + if (type.indexOf("text/") == 0 || type.indexOf("+xml") == type.length - 4) { + let stream = services.InputStream(channelStream); + let [, pre, doctype, url, extra, open, post] = util.regexp(\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); diff --git a/common/modules/util.jsm b/common/modules/util.jsm index 9385bda0..04e60c6f 100644 --- a/common/modules/util.jsm +++ b/common/modules/util.jsm @@ -1316,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