Branch: Tag:

2014-08-01

2014-08-01 04:47:22 by Pontus Rodling <frigolit@frigolit.net>

Handle X-Forwarded-By and X-Forwarded-Proto in make_absolute_url(). Partially fixes [bug 7221 (#7221)].

1375:    // Add protocol and host to local absolute URLs.    if (has_prefix (url, "/")) {    if(id) { -  url = id->url_base() + url[1..]; +  string url_base = id->url_base(); +  string xf_proto = id->request_headers["x-forwarded-proto"]; +  string xf_by = id->request_headers["x-forwarded-by"]; +  +  if (xf_proto || id->request_headers["x-forwarded-by"]) { +  Standards.URI uri = Standards.URI(id->url_base()); +  +  if (xf_proto && (< "http", "https" >)[xf_proto]) +  uri->scheme = xf_proto; +  +  if (xf_by && glob("*:*", xf_by)) +  sscanf(xf_by, "%*s:%d", uri->port); +  +  url_base = (string)uri; +  } +  +  url = url_base + url[1..];    if (!prestates) prestates = id->prestate;    }    else {