From 404372326e9d854b065175ef1f4634fd78ca8afa Mon Sep 17 00:00:00 2001 From: Einar Egilsson Date: Tue, 15 May 2012 10:38:10 +0200 Subject: Removed proxyserver.js + fixed bug with empty captures --- build.py | 4 ++-- chrome/js/proxyserver.js | 58 ------------------------------------------------ chrome/js/redirect.js | 13 ++++++----- chrome/js/redirector.js | 6 ----- install.rdf | 4 ++-- 5 files changed, 12 insertions(+), 73 deletions(-) delete mode 100644 chrome/js/proxyserver.js 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: '; - 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); - 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 @@ redirector@einaregilsson.com Redirector - 2.8 + 2.8.1 Einar Egilsson Noah Luck Easterly Automatically redirects to user-defined urls on certain pages @@ -18,7 +18,7 @@ {ec8030f7-c20a-464f-9b0e-13a3a9e97384} 5.0 - 10.* + 12.* -- cgit v1.2.3-70-g09d2