Allow Zotero.Server requests with Host: localhost

Previously only Host: 127.0.0.1 was allowed. (The check prevents a DNS
rebinding attack.)

This allows requests to translation-server using localhost
(zotero/translation-server#48).

Fixes #125
This commit is contained in:
Dan Stillman 2017-06-26 07:52:23 -04:00
parent df2216960b
commit 9372979fb5

View file

@ -237,7 +237,7 @@ Zotero.Server.DataListener.prototype._headerFinished = function() {
Zotero.debug(this.header, 5);
const methodRe = /^([A-Z]+) ([^ \r\n?]+)(\?[^ \r\n]+)?/;
const hostRe = /[\r\n]Host: *127\.0\.0\.1(:[0-9]+)?[\r\n]/i;
const hostRe = /[\r\n]Host: *(localhost|127\.0\.0\.1)(:[0-9]+)?[\r\n]/i;
const contentTypeRe = /[\r\n]Content-Type: *([^ \r\n]+)/i;
if(!Zotero.isServer) {