diff options
author | Einar Egilsson | 2012-05-15 10:38:10 +0200 |
---|---|---|
committer | Einar Egilsson | 2012-05-15 10:38:10 +0200 |
commit | 404372326e9d854b065175ef1f4634fd78ca8afa (patch) | |
tree | 37ba66f07898e9b60a0ae96e96993d9af2d4a328 /chrome | |
parent | 134add6434541ad89f663cbdc1dcef8e9a76eab8 (diff) |
Removed proxyserver.js + fixed bug with empty captures
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/js/proxyserver.js | 58 | ||||
-rw-r--r-- | chrome/js/redirect.js | 13 | ||||
-rw-r--r-- | chrome/js/redirector.js | 6 |
3 files changed, 8 insertions, 69 deletions
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() { |