From: serassio <> Date: Sun, 6 Mar 2005 21:46:24 +0000 (+0000) Subject: Forward port of all the header parsing cleanup of 2.5.STABLE8: X-Git-Tag: SQUID_3_0_PRE4~863 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=52d3f1986d5dd7a7a89d039f20c359f593d24658;p=thirdparty%2Fsquid.git Forward port of all the header parsing cleanup of 2.5.STABLE8: - squid-2.5.STABLE7-header_parsing.patch - Bug #1228 - Bug #1242 - Relaxed_header_parser squid.conf option. - New ERR_INVALID_RESP error message. --- diff --git a/errors/Bulgarian/ERR_INVALID_RESP b/errors/Bulgarian/ERR_INVALID_RESP new file mode 100755 index 0000000000..960968c405 --- /dev/null +++ b/errors/Bulgarian/ERR_INVALID_RESP @@ -0,0 +1,29 @@ + + +ERROR: The requested URL could not be retrieved + + +

ERROR

+

The requested URL could not be retrieved

+
+

+While trying to process the request: +

+%R
+
+

+The following error was encountered: +

+ +

+The HTTP Response message received from the contacted server +could not be understood or was otherwise malformed. Please contact +the site operator. Your cache administrator may be able to provide +you with more details about the exact nature of the problem if needed. + +

Your cache administrator is %w. diff --git a/errors/Catalan/ERR_INVALID_RESP b/errors/Catalan/ERR_INVALID_RESP new file mode 100755 index 0000000000..960968c405 --- /dev/null +++ b/errors/Catalan/ERR_INVALID_RESP @@ -0,0 +1,29 @@ + + +ERROR: The requested URL could not be retrieved + + +

ERROR

+

The requested URL could not be retrieved

+
+

+While trying to process the request: +

+%R
+
+

+The following error was encountered: +

+ +

+The HTTP Response message received from the contacted server +could not be understood or was otherwise malformed. Please contact +the site operator. Your cache administrator may be able to provide +you with more details about the exact nature of the problem if needed. + +

Your cache administrator is %w. diff --git a/errors/Czech/ERR_INVALID_RESP b/errors/Czech/ERR_INVALID_RESP new file mode 100755 index 0000000000..d3a130711b --- /dev/null +++ b/errors/Czech/ERR_INVALID_RESP @@ -0,0 +1,27 @@ + + + +CHYBA: Pozadovany dokument je nedostupny + + +

ERROR

+

Po¾adovaný dokument je nedostupný

+
+

+Pøi provádìní po¾adavku: +

+%R
+
+

+se objevila následující chyba: +

+ +

+HTTP odpovìï obdr¾ená od vzdáleného serveru je nesrozumitelná èi po¹kozená. +Kontaktujte prosím správce vzdáleného serveru. Dal¹í informace Vám poskytne +správce tohoto proxy serveru %w diff --git a/errors/Danish/ERR_INVALID_RESP b/errors/Danish/ERR_INVALID_RESP new file mode 100755 index 0000000000..960968c405 --- /dev/null +++ b/errors/Danish/ERR_INVALID_RESP @@ -0,0 +1,29 @@ + + +ERROR: The requested URL could not be retrieved + + +

ERROR

+

The requested URL could not be retrieved

+
+

+While trying to process the request: +

+%R
+
+

+The following error was encountered: +

+ +

+The HTTP Response message received from the contacted server +could not be understood or was otherwise malformed. Please contact +the site operator. Your cache administrator may be able to provide +you with more details about the exact nature of the problem if needed. + +

Your cache administrator is %w. diff --git a/errors/Dutch/ERR_INVALID_RESP b/errors/Dutch/ERR_INVALID_RESP new file mode 100755 index 0000000000..960968c405 --- /dev/null +++ b/errors/Dutch/ERR_INVALID_RESP @@ -0,0 +1,29 @@ + + +ERROR: The requested URL could not be retrieved + + +

ERROR

+

The requested URL could not be retrieved

+
+

+While trying to process the request: +

+%R
+
+

+The following error was encountered: +

+ +

+The HTTP Response message received from the contacted server +could not be understood or was otherwise malformed. Please contact +the site operator. Your cache administrator may be able to provide +you with more details about the exact nature of the problem if needed. + +

Your cache administrator is %w. diff --git a/errors/English/ERR_INVALID_RESP b/errors/English/ERR_INVALID_RESP new file mode 100755 index 0000000000..960968c405 --- /dev/null +++ b/errors/English/ERR_INVALID_RESP @@ -0,0 +1,29 @@ + + +ERROR: The requested URL could not be retrieved + + +

ERROR

+

The requested URL could not be retrieved

+
+

+While trying to process the request: +

+%R
+
+

+The following error was encountered: +

+ +

+The HTTP Response message received from the contacted server +could not be understood or was otherwise malformed. Please contact +the site operator. Your cache administrator may be able to provide +you with more details about the exact nature of the problem if needed. + +

Your cache administrator is %w. diff --git a/errors/Estonian/ERR_INVALID_RESP b/errors/Estonian/ERR_INVALID_RESP new file mode 100755 index 0000000000..6c746c396e --- /dev/null +++ b/errors/Estonian/ERR_INVALID_RESP @@ -0,0 +1,28 @@ + + +VIGA: Soovitud URLi ei õnnestu laadida + + +

VIGA

+

Soovitud URLi ei õnnestu laadida

+
+

+Üritades käsitleda järgnevat päringut: +

+%R
+
+

+Tekkis viga: +

+ +

+Vasti võetud HTTP vastus on tundmatu või muidu katki. Palun kontakteeruge +saidi operaatoriga. Teie vehemälu serveri administraator võib saada anda +täiendavat infot selle vea detailide kohta. + +

Teie vehemälu serveri administraator on %w. diff --git a/errors/Finnish/ERR_INVALID_RESP b/errors/Finnish/ERR_INVALID_RESP new file mode 100755 index 0000000000..e3c70d8da6 --- /dev/null +++ b/errors/Finnish/ERR_INVALID_RESP @@ -0,0 +1,28 @@ + + +VIRHE: Pyydettyä osoitetta ei voitu hakea + + +

VIRHE

+

Pyydettyä osoitetta ei voitu hakea

+
+

+Yritettäessä toimittaa pyyntöä: +

+%R
+
+

+Tapahtui seuraava virhe: +

+ +

+Palvelimen lähettämää HTTP-vastausta ei ymmärretty tai se oli +väärän muotoinen. Ota yhteyttä palvelimen ylläpitäjään. +Välipalvelimesi ylläpitäjältä voit saada lisätietoja +ongelman luonteesta. +

Välityspalvelintasi ylläpitää %w. diff --git a/errors/French/ERR_INVALID_RESP b/errors/French/ERR_INVALID_RESP new file mode 100755 index 0000000000..960968c405 --- /dev/null +++ b/errors/French/ERR_INVALID_RESP @@ -0,0 +1,29 @@ + + +ERROR: The requested URL could not be retrieved + + +

ERROR

+

The requested URL could not be retrieved

+
+

+While trying to process the request: +

+%R
+
+

+The following error was encountered: +

+ +

+The HTTP Response message received from the contacted server +could not be understood or was otherwise malformed. Please contact +the site operator. Your cache administrator may be able to provide +you with more details about the exact nature of the problem if needed. + +

Your cache administrator is %w. diff --git a/errors/German/ERR_INVALID_RESP b/errors/German/ERR_INVALID_RESP new file mode 100755 index 0000000000..74bd383710 --- /dev/null +++ b/errors/German/ERR_INVALID_RESP @@ -0,0 +1,29 @@ + + +FEHLER: Der angeforderte URL konnte nicht geholt werden + + +

FEHLER

+

Der angeforderte URL konnte nicht geholt werden

+
+

+Während des Versuches, die Anfrage +

+%R
+
+

+zu verarbeiten, trat der folgende Fehler auf: +

+ +

+Die HTTP Antwortmeldung des kontaktierten Servers konnte nicht verstanden werden +oder war auf andere Weise missgebildet. Bitte kontaktieren Sie den Betreiber der +betreffenden Webseite. Wenn nötig kann Ihr Cache Administrator in der Lage sein, +Sie mit mehr Details über die genaue Ursache des Problems zu versorgen. + +

Ihr Cache Administrator ist %w. diff --git a/errors/Hebrew/ERR_INVALID_RESP b/errors/Hebrew/ERR_INVALID_RESP new file mode 100755 index 0000000000..960968c405 --- /dev/null +++ b/errors/Hebrew/ERR_INVALID_RESP @@ -0,0 +1,29 @@ + + +ERROR: The requested URL could not be retrieved + + +

ERROR

+

The requested URL could not be retrieved

+
+

+While trying to process the request: +

+%R
+
+

+The following error was encountered: +

+ +

+The HTTP Response message received from the contacted server +could not be understood or was otherwise malformed. Please contact +the site operator. Your cache administrator may be able to provide +you with more details about the exact nature of the problem if needed. + +

Your cache administrator is %w. diff --git a/errors/Hungarian/ERR_INVALID_RESP b/errors/Hungarian/ERR_INVALID_RESP new file mode 100755 index 0000000000..960968c405 --- /dev/null +++ b/errors/Hungarian/ERR_INVALID_RESP @@ -0,0 +1,29 @@ + + +ERROR: The requested URL could not be retrieved + + +

ERROR

+

The requested URL could not be retrieved

+
+

+While trying to process the request: +

+%R
+
+

+The following error was encountered: +

+ +

+The HTTP Response message received from the contacted server +could not be understood or was otherwise malformed. Please contact +the site operator. Your cache administrator may be able to provide +you with more details about the exact nature of the problem if needed. + +

Your cache administrator is %w. diff --git a/errors/Italian/ERR_INVALID_RESP b/errors/Italian/ERR_INVALID_RESP new file mode 100755 index 0000000000..fd50ad1224 --- /dev/null +++ b/errors/Italian/ERR_INVALID_RESP @@ -0,0 +1,29 @@ + + +ERRORE: La URL richiesta non può essere recuperata + + +

ERRORE

+

La URL richiesta non può essere recuperata

+
+

+Mentre si elaborava la richiesta: +

+%R
+
+

+È avvenuto il seguente errore: +

+ +

+Il messaggio contenente la risposta HTTP ricevuto dal server che si sta +contattando non può essere interpretato od è stato in qualche modo alterato. +Si prega di contattare un operatore del sito. Se necessario, l'amministratore della vostra +cache potrà fornirvi maggiori dettagli sull'esatta natura del problema. + +

L'amministratore della vostra cache è %w. diff --git a/errors/Japanese/ERR_INVALID_RESP b/errors/Japanese/ERR_INVALID_RESP new file mode 100755 index 0000000000..960968c405 --- /dev/null +++ b/errors/Japanese/ERR_INVALID_RESP @@ -0,0 +1,29 @@ + + +ERROR: The requested URL could not be retrieved + + +

ERROR

+

The requested URL could not be retrieved

+
+

+While trying to process the request: +

+%R
+
+

+The following error was encountered: +

+ +

+The HTTP Response message received from the contacted server +could not be understood or was otherwise malformed. Please contact +the site operator. Your cache administrator may be able to provide +you with more details about the exact nature of the problem if needed. + +

Your cache administrator is %w. diff --git a/errors/Korean/ERR_INVALID_RESP b/errors/Korean/ERR_INVALID_RESP new file mode 100755 index 0000000000..960968c405 --- /dev/null +++ b/errors/Korean/ERR_INVALID_RESP @@ -0,0 +1,29 @@ + + +ERROR: The requested URL could not be retrieved + + +

ERROR

+

The requested URL could not be retrieved

+
+

+While trying to process the request: +

+%R
+
+

+The following error was encountered: +

+ +

+The HTTP Response message received from the contacted server +could not be understood or was otherwise malformed. Please contact +the site operator. Your cache administrator may be able to provide +you with more details about the exact nature of the problem if needed. + +

Your cache administrator is %w. diff --git a/errors/Lithuanian/ERR_INVALID_RESP b/errors/Lithuanian/ERR_INVALID_RESP new file mode 100755 index 0000000000..053154f244 --- /dev/null +++ b/errors/Lithuanian/ERR_INVALID_RESP @@ -0,0 +1,27 @@ + + +KLAIDA: Puslapis nurodytu adresu negali bûti atsiøstas + + +

KLAIDA

+

Puslapis nurodytu adresu negali bûti atsiøstas

+
+

+Bandant ávykdyti uþklausà: +

+%R
+
+

+Gautas klaidos praneðimas: +

+ +

+Ið serverio gautas nesuprantamas HTTP atsakymas arba jis buvo klaidingai +suformuotas. Susisiekite su serverio operatoriumi. Jûsø proxy serverio +administratorius gali suteikti jums daugiau informacijos apie ðià problemà. +

diff --git a/errors/Polish/ERR_INVALID_RESP b/errors/Polish/ERR_INVALID_RESP new file mode 100755 index 0000000000..960968c405 --- /dev/null +++ b/errors/Polish/ERR_INVALID_RESP @@ -0,0 +1,29 @@ + + +ERROR: The requested URL could not be retrieved + + +

ERROR

+

The requested URL could not be retrieved

+
+

+While trying to process the request: +

+%R
+
+

+The following error was encountered: +

+ +

+The HTTP Response message received from the contacted server +could not be understood or was otherwise malformed. Please contact +the site operator. Your cache administrator may be able to provide +you with more details about the exact nature of the problem if needed. + +

Your cache administrator is %w. diff --git a/errors/Portuguese/ERR_INVALID_RESP b/errors/Portuguese/ERR_INVALID_RESP new file mode 100755 index 0000000000..960968c405 --- /dev/null +++ b/errors/Portuguese/ERR_INVALID_RESP @@ -0,0 +1,29 @@ + + +ERROR: The requested URL could not be retrieved + + +

ERROR

+

The requested URL could not be retrieved

+
+

+While trying to process the request: +

+%R
+
+

+The following error was encountered: +

+ +

+The HTTP Response message received from the contacted server +could not be understood or was otherwise malformed. Please contact +the site operator. Your cache administrator may be able to provide +you with more details about the exact nature of the problem if needed. + +

Your cache administrator is %w. diff --git a/errors/Romanian/ERR_INVALID_RESP b/errors/Romanian/ERR_INVALID_RESP new file mode 100755 index 0000000000..960968c405 --- /dev/null +++ b/errors/Romanian/ERR_INVALID_RESP @@ -0,0 +1,29 @@ + + +ERROR: The requested URL could not be retrieved + + +

ERROR

+

The requested URL could not be retrieved

+
+

+While trying to process the request: +

+%R
+
+

+The following error was encountered: +

+ +

+The HTTP Response message received from the contacted server +could not be understood or was otherwise malformed. Please contact +the site operator. Your cache administrator may be able to provide +you with more details about the exact nature of the problem if needed. + +

Your cache administrator is %w. diff --git a/errors/Russian-1251/ERR_INVALID_RESP b/errors/Russian-1251/ERR_INVALID_RESP new file mode 100755 index 0000000000..960968c405 --- /dev/null +++ b/errors/Russian-1251/ERR_INVALID_RESP @@ -0,0 +1,29 @@ + + +ERROR: The requested URL could not be retrieved + + +

ERROR

+

The requested URL could not be retrieved

+
+

+While trying to process the request: +

+%R
+
+

+The following error was encountered: +

+ +

+The HTTP Response message received from the contacted server +could not be understood or was otherwise malformed. Please contact +the site operator. Your cache administrator may be able to provide +you with more details about the exact nature of the problem if needed. + +

Your cache administrator is %w. diff --git a/errors/Russian-koi8-r/ERR_INVALID_RESP b/errors/Russian-koi8-r/ERR_INVALID_RESP new file mode 100755 index 0000000000..080b7184ac --- /dev/null +++ b/errors/Russian-koi8-r/ERR_INVALID_RESP @@ -0,0 +1,31 @@ + + + +ïûéâëá: úÁÐÒÏÛÅÎÎÙÊ URL ÎÅ ÍÏÖÅÔ ÂÙÔØ ÄÏÓÔÁ×ÌÅÎ + + +

ïûéâëá

+

úÁÐÒÏÛÅÎÎÙÊ URL ÎÅ ÍÏÖÅÔ ÂÙÔØ ÄÏÓÔÁ×ÌÅÎ.

+
+

+÷Ï ×ÒÅÍÑ ÏÂÒÁÂÏÔËÉ ÚÁÐÒÏÓÁ: +

+%R
+
+

+ðÒÏÉÚÏÛÌÁ ÓÌÅÄÕÀÝÁÑ ÏÛÉÂËÁ: +

+ +

+HTTP ÏÔ×ÅÔ, ÐÏÌÕÞÅÎÎÙÊ ÏÔ ÚÁÐÒÁÛÉ×ÁÅÍÏÇÏ ÓÅÒ×ÅÒÁ ÎÅÐÏÎÑÔÅÎ ÉÌÉ +ÉÚÕÒÏÄÏ×ÁÎ. ïÂÒÁÝÁÊÔÅÓØ Ë ÁÄÍÉÎÉÓÔÒÁÔÏÒÁÍ ÚÁÐÒÁÛÉ×ÁÅÍÏÇÏ ÓÁÊÔÁ. +áÄÍÉÎÉÓÔÒÁÔÏÒ ×ÁÛÅÇÏ ÐÒÏËÓÉ-ÓÅÒ×ÅÒÁ ÍÏÖÅÔ ÐÒÉ ÎÅÏÂÈÏÄÉÍÏÓÔÉ +ÂÏÌÅÅ ÄÅÔÁÌØÎÏ ÏÐÉÓÁÔØ ÓÕÝÅÓÔ×Ï ÐÒÏÂÌÅÍÙ. + +

+áÄÒÅÓ áÄÍÉÎÉÓÔÒÁÔÏÒÁ ×ÁÛÅÇÏ ÐÒÏËÓÉ-ÓÅÒ×ÅÒÁ: %w. diff --git a/errors/Serbian/ERR_INVALID_RESP b/errors/Serbian/ERR_INVALID_RESP new file mode 100755 index 0000000000..960968c405 --- /dev/null +++ b/errors/Serbian/ERR_INVALID_RESP @@ -0,0 +1,29 @@ + + +ERROR: The requested URL could not be retrieved + + +

ERROR

+

The requested URL could not be retrieved

+
+

+While trying to process the request: +

+%R
+
+

+The following error was encountered: +

+ +

+The HTTP Response message received from the contacted server +could not be understood or was otherwise malformed. Please contact +the site operator. Your cache administrator may be able to provide +you with more details about the exact nature of the problem if needed. + +

Your cache administrator is %w. diff --git a/errors/Simplify_Chinese/ERR_INVALID_RESP b/errors/Simplify_Chinese/ERR_INVALID_RESP new file mode 100755 index 0000000000..960968c405 --- /dev/null +++ b/errors/Simplify_Chinese/ERR_INVALID_RESP @@ -0,0 +1,29 @@ + + +ERROR: The requested URL could not be retrieved + + +

ERROR

+

The requested URL could not be retrieved

+
+

+While trying to process the request: +

+%R
+
+

+The following error was encountered: +

+ +

+The HTTP Response message received from the contacted server +could not be understood or was otherwise malformed. Please contact +the site operator. Your cache administrator may be able to provide +you with more details about the exact nature of the problem if needed. + +

Your cache administrator is %w. diff --git a/errors/Slovak/ERR_INVALID_RESP b/errors/Slovak/ERR_INVALID_RESP new file mode 100755 index 0000000000..7dbb2b1dfa --- /dev/null +++ b/errors/Slovak/ERR_INVALID_RESP @@ -0,0 +1,31 @@ + + + +CHYBA: Pozadovany dokument je nedostupny + + +

CHYBA

+

Po¾adovaný dokument je nedostupný

+
+

+Pri pokuse o prístup k: +

+%R
+
+

+do¹lo k nasledovnej chybe: +

+ +

+HTTP odpovedi obdr¾anej z kontaktovaného servera nebolo mo¾né porozumie» +alebo bola nejako po¹kodená. Kontaktujte prosím správcu servera. V prípade +potreby Vám Vá¹ cache administrátor mô¾e poskytnú» detaily o presnej povahe +problému. +

+ +

Va¹ím cache administrátorom je %w.

diff --git a/errors/Spanish/ERR_INVALID_RESP b/errors/Spanish/ERR_INVALID_RESP new file mode 100755 index 0000000000..960968c405 --- /dev/null +++ b/errors/Spanish/ERR_INVALID_RESP @@ -0,0 +1,29 @@ + + +ERROR: The requested URL could not be retrieved + + +

ERROR

+

The requested URL could not be retrieved

+
+

+While trying to process the request: +

+%R
+
+

+The following error was encountered: +

+ +

+The HTTP Response message received from the contacted server +could not be understood or was otherwise malformed. Please contact +the site operator. Your cache administrator may be able to provide +you with more details about the exact nature of the problem if needed. + +

Your cache administrator is %w. diff --git a/errors/Swedish/ERR_INVALID_RESP b/errors/Swedish/ERR_INVALID_RESP new file mode 100755 index 0000000000..629e371cd7 --- /dev/null +++ b/errors/Swedish/ERR_INVALID_RESP @@ -0,0 +1,30 @@ + + +Fel: Begärd URL kunde inte hämtas + + +

FEL

+

Begärd URL kunde inte hämtas

+
+

+Vid försöket att hämta URL: +%U +

+Mottogs följande fel: +

+ +

+HTTP svarsmeddelandet ifrån den kontaktade servern är felaktigt och +kunde inte tolkas. Vänligen kontakta den ansvariga för webbservern ifråga. +Din cacheserver administratör man eventuellt ge dig mera information om +det specifika problemet med denna sida. +

+ +

Din cacheserver administratör är %w. +

+ diff --git a/errors/Traditional_Chinese/ERR_INVALID_RESP b/errors/Traditional_Chinese/ERR_INVALID_RESP new file mode 100755 index 0000000000..960968c405 --- /dev/null +++ b/errors/Traditional_Chinese/ERR_INVALID_RESP @@ -0,0 +1,29 @@ + + +ERROR: The requested URL could not be retrieved + + +

ERROR

+

The requested URL could not be retrieved

+
+

+While trying to process the request: +

+%R
+
+

+The following error was encountered: +

+ +

+The HTTP Response message received from the contacted server +could not be understood or was otherwise malformed. Please contact +the site operator. Your cache administrator may be able to provide +you with more details about the exact nature of the problem if needed. + +

Your cache administrator is %w. diff --git a/errors/Turkish/ERR_INVALID_RESP b/errors/Turkish/ERR_INVALID_RESP new file mode 100755 index 0000000000..960968c405 --- /dev/null +++ b/errors/Turkish/ERR_INVALID_RESP @@ -0,0 +1,29 @@ + + +ERROR: The requested URL could not be retrieved + + +

ERROR

+

The requested URL could not be retrieved

+
+

+While trying to process the request: +

+%R
+
+

+The following error was encountered: +

+ +

+The HTTP Response message received from the contacted server +could not be understood or was otherwise malformed. Please contact +the site operator. Your cache administrator may be able to provide +you with more details about the exact nature of the problem if needed. + +

Your cache administrator is %w. diff --git a/src/HttpHeader.cc b/src/HttpHeader.cc index 464d07c55e..718b18de42 100644 --- a/src/HttpHeader.cc +++ b/src/HttpHeader.cc @@ -1,6 +1,6 @@ /* - * $Id: HttpHeader.cc,v 1.101 2004/12/20 16:30:32 robertc Exp $ + * $Id: HttpHeader.cc,v 1.102 2005/03/06 14:46:29 serassio Exp $ * * DEBUG: section 55 HTTP Header * AUTHOR: Alex Rousskov @@ -467,59 +467,115 @@ httpHeaderReset(HttpHeader * hdr) int httpHeaderParse(HttpHeader * hdr, const char *header_start, const char *header_end) { - const char *field_start = header_start; - HttpHeaderEntry *e; + const char *field_ptr = header_start; + HttpHeaderEntry *e, *e2; assert(hdr); assert(header_start && header_end); debug(55, 7) ("parsing hdr: (%p)\n%s\n", hdr, getStringPrefix(header_start, header_end)); HttpHeaderStats[hdr->owner].parsedCount++; - /* commonn format headers are ":[ws]" lines delimited by */ - while (field_start < header_end) { + if (memchr(header_start, '\0', header_end - header_start)) { + debug(55, 1) ("WARNING: HTTP header contains NULL characters {%s}\n", + getStringPrefix(header_start, header_end)); + return httpHeaderReset(hdr); + } + + /* common format headers are ":[ws]" lines delimited by . + * continuation lines start with a (single) space or tab */ + while (field_ptr < header_end) { + const char *field_start = field_ptr; const char *field_end; - const char *field_ptr = field_start; do { - field_end = field_ptr = field_ptr + strcspn(field_ptr, "\r\n"); - /* skip CRLF */ - - if (*field_ptr == '\r') - field_ptr++; - - if (*field_ptr == '\n') - field_ptr++; - } while (*field_ptr == ' ' || *field_ptr == '\t'); - - if (!*field_end || field_end > header_end) - return httpHeaderReset(hdr); /* missing */ + const char *this_line = field_ptr; + field_ptr = (const char *)memchr(field_ptr, '\n', header_end - field_ptr); + + if (!field_ptr) + return httpHeaderReset(hdr); /* missing */ + + field_end = field_ptr; + + field_ptr++; /* Move to next line */ + + if (field_end > this_line && field_end[-1] == '\r') { + field_end--; /* Ignore CR LF */ + /* Ignore CR CR LF in relaxed mode */ + + if (Config.onoff.relaxed_header_parser && field_end > this_line + 1 && field_end[-1] == '\r') { + debug(55, Config.onoff.relaxed_header_parser <= 0 ? 1 : 2) + ("WARNING: Double CR characters in HTTP header {%s}\n", getStringPrefix(field_start, field_end)); + field_end--; + } + } + + /* Barf on stray CR characters */ + if (memchr(this_line, '\r', field_end - this_line)) { + debug(55, 1) ("WARNING: suspicious CR characters in HTTP header {%s}\n", + getStringPrefix(field_start, field_end)); + + if (Config.onoff.relaxed_header_parser) { + char *p = (char *) this_line; /* XXX Warning! This destroys original header content and violates specifications somewhat */ + + while ((p = (char *)memchr(p, '\r', field_end - p)) != NULL) + *p++ = ' '; + } else + return httpHeaderReset(hdr); + } + + if (this_line + 1 == field_end && this_line > field_start) { + debug(55, 1) ("WARNING: Blank continuation line in HTTP header {%s}\n", + getStringPrefix(header_start, header_end)); + return httpHeaderReset(hdr); + } + } while (field_ptr < header_end && (*field_ptr == ' ' || *field_ptr == '\t')); + + if (field_start == field_end) { + if (field_ptr < header_end) { + debug(55, 1) ("WARNING: unparseable HTTP header field near {%s}\n", + getStringPrefix(field_start, header_end)); + return httpHeaderReset(hdr); + } + + break; /* terminating blank line */ + } e = httpHeaderEntryParseCreate(field_start, field_end); if (NULL == e) { - debug(55, 1) ("WARNING: ignoring unparseable HTTP header field near '%s'\n", + debug(55, 1) ("WARNING: unparseable HTTP header field {%s}\n", getStringPrefix(field_start, field_end)); - } else if (e->id == HDR_CONTENT_LENGTH && httpHeaderHas(hdr, HDR_CONTENT_LENGTH)) { - debug(55, 1) ("WARNING: found double content-length header\n"); - httpHeaderEntryDestroy(e); - return httpHeaderReset(hdr); - } else if (e->id == HDR_OTHER && stringHasWhitespace(e->name.buf())) { - debug(55, 1) ("WARNING: found whitespace in HTTP header {%s}\n", e->name.buf()); - httpHeaderEntryDestroy(e); - return httpHeaderReset(hdr); - } else { - httpHeaderAddEntry(hdr, e); + debug(55, Config.onoff.relaxed_header_parser <= 0 ? 1 : 2) + (" in {%s}\n", getStringPrefix(header_start, header_end)); + + if (Config.onoff.relaxed_header_parser) + continue; + else + return httpHeaderReset(hdr); } - field_start = field_end; + if (e->id == HDR_CONTENT_LENGTH && (e2 = httpHeaderFindEntry(hdr, e->id)) != NULL) { + if (!Config.onoff.relaxed_header_parser || e->value.cmp(e2->value.buf()) != 0) { + debug(55, 1) ("WARNING: found two conflicting content-length headers in {%s}\n", getStringPrefix(header_start, header_end)); + httpHeaderEntryDestroy(e); + return httpHeaderReset(hdr); + } else { + debug(55, Config.onoff.relaxed_header_parser <= 0 ? 1 : 2) + ("NOTICE: found double content-length header\n"); + } + } - /* skip CRLF */ + if (e->id == HDR_OTHER && stringHasWhitespace(e->name.buf())) { + debug(55, Config.onoff.relaxed_header_parser <= 0 ? 1 : 2) + ("WARNING: found whitespace in HTTP header name {%s}\n", getStringPrefix(field_start, field_end)); - if (*field_start == '\r') - field_start++; + if (!Config.onoff.relaxed_header_parser) { + httpHeaderEntryDestroy(e); + return httpHeaderReset(hdr); + } + } - if (*field_start == '\n') - field_start++; + httpHeaderAddEntry(hdr, e); } return 1; /* even if no fields where found, it is a valid header */ @@ -1254,8 +1310,8 @@ httpHeaderEntryParseCreate(const char *field_start, const char *field_end) HttpHeaderEntry *e; http_hdr_type id; /* note: name_start == field_start */ - const char *name_end = strchr(field_start, ':'); - const int name_len = name_end ? name_end - field_start : 0; + const char *name_end = (const char *)memchr(field_start, ':', field_end - field_start); + int name_len = name_end ? name_end - field_start : 0; const char *value_start = field_start + name_len + 1; /* skip ':' */ /* note: value_end == field_end */ @@ -1272,6 +1328,17 @@ httpHeaderEntryParseCreate(const char *field_start, const char *field_end) return NULL; } + if (Config.onoff.relaxed_header_parser && xisspace(field_start[name_len - 1])) { + debug(55, Config.onoff.relaxed_header_parser <= 0 ? 1 : 2) + ("NOTICE: Whitespace after header name in '%s'\n", getStringPrefix(field_start, field_end)); + + while (name_len > 0 && xisspace(field_start[name_len - 1])) + name_len--; + + if (!name_len) + return NULL; + } + /* now we know we can parse it */ e = new HttpHeaderEntry; @@ -1297,6 +1364,9 @@ httpHeaderEntryParseCreate(const char *field_start, const char *field_end) while (value_start < field_end && xisspace(*value_start)) value_start++; + while (value_start < field_end && xisspace(field_end[-1])) + field_end--; + if (field_end - value_start > 65536) { /* String has a 64K limit */ debug(55, 1) ("WARNING: ignoring '%s' header of %d bytes\n", diff --git a/src/cache_cf.cc b/src/cache_cf.cc index 600725fbf4..61dae30dc8 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -1,6 +1,6 @@ /* - * $Id: cache_cf.cc,v 1.463 2005/02/09 13:01:40 serassio Exp $ + * $Id: cache_cf.cc,v 1.464 2005/03/06 14:46:29 serassio Exp $ * * DEBUG: section 3 Configuration File Parsing * AUTHOR: Harvest Derived @@ -2017,10 +2017,39 @@ parse_onoff(int *var) } #define free_onoff free_int -#define dump_eol dump_string -#define free_eol free_string -#define dump_debug dump_string -#define free_debug free_string + +static void +dump_tristate(StoreEntry * entry, const char *name, int var) +{ + const char *state; + + if (var > 0) + state = "on"; + else if (var < 0) + state = "warn"; + else + state = "off"; + + storeAppendPrintf(entry, "%s %s\n", name, state); +} + +static void +parse_tristate(int *var) +{ + char *token = strtok(NULL, w_space); + + if (token == NULL) + self_destruct(); + + if (!strcasecmp(token, "on") || !strcasecmp(token, "enable")) + *var = 1; + else if (!strcasecmp(token, "warn")) + *var = -1; + else + *var = 0; +} + +#define free_tristate free_int static void dump_refreshpattern(StoreEntry * entry, const char *name, refresh_t * head) @@ -2287,6 +2316,9 @@ parse_eol(char *volatile *var) *var = xstrdup((char *) token); } +#define dump_eol dump_string +#define free_eol free_string + void parse_debug(char *volatile *var) { @@ -2296,6 +2328,9 @@ parse_debug(char *volatile *var) Debug::parseOptions(Config.debugOptions); } +#define dump_debug dump_string +#define free_debug free_string + static void dump_time_t(StoreEntry * entry, const char *name, time_t var) { diff --git a/src/enums.h b/src/enums.h index b19f5532ae..e1c35b3a1f 100644 --- a/src/enums.h +++ b/src/enums.h @@ -1,6 +1,6 @@ /* - * $Id: enums.h,v 1.240 2005/02/09 13:01:40 serassio Exp $ + * $Id: enums.h,v 1.241 2005/03/06 14:46:29 serassio Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -95,6 +95,7 @@ typedef enum { ERR_TOO_BIG, TCP_RESET, ERR_ESI, /* Failure to perform ESI processing */ + ERR_INVALID_RESP, ERR_MAX } err_type; diff --git a/src/http.cc b/src/http.cc index 1d397976bc..1478fd2099 100644 --- a/src/http.cc +++ b/src/http.cc @@ -1,6 +1,6 @@ /* - * $Id: http.cc,v 1.444 2005/02/14 22:12:57 serassio Exp $ + * $Id: http.cc,v 1.445 2005/03/06 14:46:29 serassio Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -1010,7 +1010,7 @@ HttpStateData::readReply (int fd, char *readBuf, size_t len, comm_err_t flag, in processReplyHeader(buf, len); else if (entry->getReply()->sline.status == HTTP_INVALID_HEADER && HttpVersion(0,9) != entry->getReply()->sline.version) { ErrorState *err; - err = errorCon(ERR_INVALID_REQ, HTTP_BAD_GATEWAY); + err = errorCon(ERR_INVALID_RESP, HTTP_BAD_GATEWAY); err->request = requestLink((HttpRequest *) request); fwdFail(fwd, err); do_next_read = 0; @@ -1040,7 +1040,7 @@ HttpStateData::readReply (int fd, char *readBuf, size_t len, comm_err_t flag, in if (s == HTTP_INVALID_HEADER && httpver != HttpVersion(0,9)) { ErrorState *err; storeEntryReset(entry); - err = errorCon(ERR_INVALID_REQ, HTTP_BAD_GATEWAY); + err = errorCon(ERR_INVALID_RESP, HTTP_BAD_GATEWAY); err->request = requestLink((HttpRequest *) request); fwdFail(fwd, err); comm_close(fd); diff --git a/src/mime.cc b/src/mime.cc index 3a3a21da4d..41f0101514 100644 --- a/src/mime.cc +++ b/src/mime.cc @@ -1,6 +1,6 @@ /* - * $Id: mime.cc,v 1.115 2004/04/04 23:17:48 hno Exp $ + * $Id: mime.cc,v 1.116 2005/03/06 14:46:30 serassio Exp $ * * DEBUG: section 25 MIME Parsing * AUTHOR: Harvest Derived @@ -176,7 +176,7 @@ size_t headersEnd(const char *mime, size_t l) { size_t e = 0; - int state = 0; + int state = 1; while (e < l && state < 3) { switch (state) { @@ -199,9 +199,7 @@ headersEnd(const char *mime, size_t l) break; case 2: - if ('\r' == mime[e]) /* ignore repeated CR */ - (void) 0; - else if ('\n' == mime[e]) + if ('\n' == mime[e]) state = 3; else state = 0; diff --git a/src/structs.h b/src/structs.h index 8d5399a58a..082f360742 100644 --- a/src/structs.h +++ b/src/structs.h @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.510 2005/03/02 20:57:35 hno Exp $ + * $Id: structs.h,v 1.511 2005/03/06 14:46:31 serassio Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -569,6 +569,7 @@ struct _SquidConfig int request_entities; int balance_on_multiple_ip; + int relaxed_header_parser; int check_hostnames; int via; int emailErrData;