Skip to content

Commit d8118e3

Browse files
author
Fábio Santos
committed
ensure dumb sites don't shoot themselves in the foot when reading an absolute request URI
1 parent 484cca2 commit d8118e3

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

index.js

+6
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ http.createServer(function (req, res) {
9393
/* Else, proxy the request over to the server */
9494
if (!didRespond) {
9595
var parsed = url.parse(req.url)
96+
97+
// Protect Wordpress, Wikipedia and other sites from their naiveté
98+
// in assuming that the URIs in the path field aren't absolute.
99+
// http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5.1.2
100+
req.url = req.url.replace(/.*?\/\/.*?\//, '/');
101+
96102
proxy.proxyRequest(req, res, {
97103
host: parsed.hostname,
98104
port: parsed.port || 80,

0 commit comments

Comments
 (0)