Do not limit Cookie detection to PHPSESSID only (mirall#260)

This commit is contained in:
Klaas Freitag 2013-01-24 10:06:42 +01:00
parent 0d6b32ed0a
commit 4ca84c80c6

View file

@ -560,7 +560,6 @@ static int configureProxy( ne_session *session )
* if a Set-Cookie header is there for the PHPSESSID. The key is stored into
* the webdav session to be added to subsequent requests.
*/
#define PHPSESSID "PHPSESSID="
static void post_request_hook(ne_request *req, void *userdata, const ne_status *status)
{
const char *set_cookie_header = NULL;
@ -578,12 +577,11 @@ static void post_request_hook(ne_request *req, void *userdata, const ne_status *
/* try to find a ', ' sequence which is the separator of neon if multiple Set-Cookie
* headers are there.
* The following code parses a string like this:
* PHPSESSID=n8feu3dsbarpvvufqae9btn5fl7m7ikgh5ml1fg37v4i2cah7k41; path=/; HttpOnly */
* Set-Cookie: 50ace6bd8a669=p537brtt048jh8srlp2tuep7em95nh9u98mj992fbqc47d1aecp1;
*/
sc = set_cookie_header;
while(sc) {
if( strlen(sc) > strlen(PHPSESSID) &&
strncmp( sc, PHPSESSID, strlen(PHPSESSID)) == 0 ) {
const char *sc_val = sc; /* + strlen(PHPSESSID); */
const char *sc_val = sc;
const char *sc_end = sc_val;
int cnt = 0;
int len = strlen(sc_val); /* The length of the rest of the header string. */
@ -621,22 +619,6 @@ static void post_request_hook(ne_request *req, void *userdata, const ne_status *
sc = NULL;
}
}
} else {
/* It is not a PHPSESSID-Header but another one which we're not interested in.
* forward to next header entry (search ',' )
*/
int len = strlen(sc);
int cnt = 0;
while(cnt < len && *sc != ',') {
cnt++;
sc++;
}
if( cnt < len )
sc = sc+2; /* mind the space after the comma */
else
sc = NULL;
}
}
}
} else {