From 3faf32a0ef000d852c31050a05fe7787ae9a5c65 Mon Sep 17 00:00:00 2001 From: ornse01 Date: Sat, 30 Apr 2011 14:34:55 +0000 Subject: [PATCH] fix request path condition. git-svn-id: http://svn.sourceforge.jp/svnroot/bchan/bchan/trunk@245 20a0b8eb-f62a-4a12-8fe1-b598822500fb --- src/cookiedb.c | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/src/cookiedb.c b/src/cookiedb.c index c0a1e83..edc2cb3 100644 --- a/src/cookiedb.c +++ b/src/cookiedb.c @@ -104,6 +104,24 @@ EXPORT Bool ascstr_suffixcmp(ascstr_t *astr, ascstr_t *suffix) return True; } +/* + * match example + * astr: XXXXYYYYZZZZ + * prefix: XXXXYY + * + */ +EXPORT Bool ascstr_prefixcmp(ascstr_t *astr, ascstr_t *prefix) +{ + if (astr->len < prefix->len) { + return False; + } + if (strncmp(astr->str, prefix->str, prefix->len) != 0) { + return False; + } + + return True; +} + EXPORT W ascstr_initialize(ascstr_t *astr) { astr->str = malloc(sizeof(UB)); @@ -406,13 +424,13 @@ LOCAL Bool cookiedb_writeiterator_checksendcondition_domaincheck(cookiedb_writei return True; } -LOCAL Bool cookiedb_writeitereator_pathcheck(ascstr_t *send_path, ascstr_t *origin_path) +LOCAL Bool cookiedb_writeitereator_pathcheck(cookiedb_writeiterator_t *iter, httpcookie_t *cookie) { - if (origin_path->len < send_path->len) { - return False; - } - if (strncmp(origin_path->str, send_path->str, send_path->len) != 0) { - return False; + Bool ok; + if (cookie->path.len != 0) { + ok = ascstr_prefixcmp(&iter->path, &cookie->path); + } else { + ok = ascstr_prefixcmp(&iter->path, &cookie->origin_path); } return True; } @@ -435,11 +453,7 @@ LOCAL Bool cookiedb_writeiterator_checksendcondition(cookiedb_writeiterator_t *i if (ok == False) { return False; } - if (cookie->path.len != 0) { - ok = cookiedb_writeitereator_pathcheck(&iter->path, &cookie->path); - } else { - ok = cookiedb_writeitereator_pathcheck(&iter->path, &cookie->origin_path); - } + ok = cookiedb_writeitereator_pathcheck(iter, cookie); if (ok == False) { return False; } -- 2.11.0