aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEinar Egilsson2012-05-15 10:38:10 +0200
committerEinar Egilsson2012-05-15 10:38:10 +0200
commit404372326e9d854b065175ef1f4634fd78ca8afa (patch)
tree37ba66f07898e9b60a0ae96e96993d9af2d4a328
parent134add6434541ad89f663cbdc1dcef8e9a76eab8 (diff)
Removed proxyserver.js + fixed bug with empty captures
-rw-r--r--build.py4
-rw-r--r--chrome/js/proxyserver.js58
-rw-r--r--chrome/js/redirect.js13
-rw-r--r--chrome/js/redirector.js6
-rw-r--r--install.rdf4
5 files changed, 12 insertions, 73 deletions
diff --git a/build.py b/build.py
index 4225bf0..2eff878 100644
--- a/build.py
+++ b/build.py
@@ -1,6 +1,6 @@
-import os, os.path, zipfile
+import os, os.path, zipfile, sys
-xpi = zipfile.ZipFile('redirector-2.7.1.xpi','w')
+xpi = zipfile.ZipFile('redirector-' + raw_input('Version: ') + '.xpi','w')
for (root, folders, files) in os.walk('.'):
if 'unittest' in root:
continue
diff --git a/chrome/js/proxyserver.js b/chrome/js/proxyserver.js
deleted file mode 100644
index 4881f59..0000000
--- a/chrome/js/proxyserver.js
+++ /dev/null
@@ -1,58 +0,0 @@
-Components.utils.import("chrome://redirector/content/js/xpcom.js");
-
-var EXPORTED_SYMBOLS = ['RedirectorProxy'];
-
-var RedirectorProxy = {
-
- start : function(port, getUrl) {
- dump('Opening Proxy Server Socket on port ' + port);
- this.getUrl = getUrl;
- this.serverSocket = new ServerSocket(port, true, -1);
- this.serverSocket.asyncListen(this);
- },
-
- onSocketAccepted: function(serverSocket, clientSocket) {
- dump("Accepted connection on "+clientSocket.host+":"+clientSocket.port);
- var requestStream = clientSocket.openInputStream(0, 0, 0).QueryInterface(Ci.nsIAsyncInputStream);
- var responseStream = clientSocket.openOutputStream(Ci.nsITransport.OPEN_BLOCKING, 0, 0);
- var tm = Cc["@mozilla.org/thread-manager;1"].getService();
- requestStream.asyncWait({
- onInputStreamReady : function(inputStream) {
- RedirectorProxy.processRequest(clientSocket, inputStream, responseStream);
- }
- },0,0,tm.mainThread);
- },
-
- processRequest : function(clientSocket, inputStream, responseStream) {
- var requestStream = new ScriptableInputStream(inputStream);
- requestStream.available();
- var request = '';
- while (requestStream.available()) {
- request = request + requestStream.read(2048);
- }
- var parts = request.split(' ');
- dump('\n\n\n' + request + '\n\n\n');
- dump("\n" + parts[0] + " request for " + parts[1]);
- var redirectUrl = 'http://einaregilsson.com';//Redirector.getRedirectUrl(parts[1]);
- var outp = 'HTTP/1.1 302 Moved Temporarily';
- outp += '\r\nContent-Length: <cl>';
- outp += '\r\nLocation: ' + redirectUrl;
- outp += '\r\nX-Redirected-By: Redirector Firefox Extension'
- outp += '\r\n\r\n';
- var cl = outp.length -4;
- if (cl < 100) {
- cl+=2;
- } else if (cl < 1000) {
- cl += 3;
- } else if (cl < 10000) {
- cl += 4;
- } else if (cl < 100000) {
- cl += 5;
- }
- outp = outp.replace('<cl>', cl);
- dump(outp);
- responseStream.write(outp, outp.length);
- responseStream.close();
- inputStream.close();
- }
-} \ No newline at end of file
diff --git a/chrome/js/redirect.js b/chrome/js/redirect.js
index 4a05ef8..eab14f8 100644
--- a/chrome/js/redirect.js
+++ b/chrome/js/redirect.js
@@ -202,11 +202,14 @@ Redirect.prototype = {
}
var resultUrl = this.redirectUrl;
for (var i = 1; i < matches.length; i++) {
- resultUrl = resultUrl.replace(new RegExp('\\$' + i, 'gi'),
- this.unescapeMatches ? unescape(matches[i]) :
- this.escapeMatches ? encodeURIComponent(matches[i]) :
- matches[i]
- );
+ var repl = matches[i] || '';
+ if (this.unescapeMatches) {
+ repl = unescape(repl);
+ }
+ if (this.escapeMatches) {
+ repl = encodeURIComponent(repl);
+ }
+ resultUrl = resultUrl.replace(new RegExp('\\$' + i, 'gi'), repl);
}
this._rxInclude.lastIndex = 0;
return resultUrl;
diff --git a/chrome/js/redirector.js b/chrome/js/redirector.js
index 5f4fa2a..86e07a2 100644
--- a/chrome/js/redirector.js
+++ b/chrome/js/redirector.js
@@ -1,7 +1,6 @@
Components.utils.import("chrome://redirector/content/js/xpcom.js");
Components.utils.import("chrome://redirector/content/js/redirect.js");
Components.utils.import("chrome://redirector/content/js/redirectorprefs.js");
-//Components.utils.import("chrome://redirector/content/js/proxyserver.js");
var EXPORTED_SYMBOLS = ['Redirector'];
@@ -304,11 +303,6 @@ Redirector = {
if (redirectsFile.exists()) {
this.importRedirects(redirectsFile);
}
-
- //RedirectorProxy.start(this._prefs.proxyServerPort);
- //Redirector.debug('Registering as Proxy Filter');
- //var pps = Cc["@mozilla.org/network/protocol-proxy-service;1"].getService(Ci.nsIProtocolProxyService);
- //pps.registerFilter(this, 0);
},
_loadStrings : function() {
diff --git a/install.rdf b/install.rdf
index 063de77..df68e9f 100644
--- a/install.rdf
+++ b/install.rdf
@@ -4,7 +4,7 @@
<Description about="urn:mozilla:install-manifest">
<em:id>redirector@einaregilsson.com</em:id>
<em:name>Redirector</em:name>
- <em:version>2.8</em:version>
+ <em:version>2.8.1</em:version>
<em:creator>Einar Egilsson</em:creator>
<em:contributor>Noah Luck Easterly</em:contributor>
<em:description>Automatically redirects to user-defined urls on certain pages</em:description>
@@ -18,7 +18,7 @@
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id> <!-- firefox -->
<em:minVersion>5.0</em:minVersion>
- <em:maxVersion>10.*</em:maxVersion>
+ <em:maxVersion>12.*</em:maxVersion>
</Description>
</em:targetApplication>
</Description>