author | Michael Krelin <hacker@klever.net> | 2008-02-02 21:10:12 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2008-02-02 21:10:12 (UTC) |
commit | 3658759966cbadb7b50457d446f3436b6f7987da (patch) (side-by-side diff) | |
tree | b215da5b5212b60aa1ec965df28070b4bff587bc /lib/basic_op.cc | |
parent | a8f733c88d87abe422ecaa405df385bad562e60f (diff) | |
download | libopkele-3658759966cbadb7b50457d446f3436b6f7987da.zip libopkele-3658759966cbadb7b50457d446f3436b6f7987da.tar.gz libopkele-3658759966cbadb7b50457d446f3436b6f7987da.tar.bz2 |
moved uri matching into separate procedure
Signed-off-by: Michael Krelin <hacker@klever.net>
-rw-r--r-- | lib/basic_op.cc | 35 |
1 files changed, 3 insertions, 32 deletions
diff --git a/lib/basic_op.cc b/lib/basic_op.cc index f7573aa..11ffb48 100644 --- a/lib/basic_op.cc +++ b/lib/basic_op.cc @@ -1,6 +1,5 @@ #include <time.h> #include <cassert> -#include <algorithm> #include <openssl/sha.h> #include <openssl/hmac.h> #include <opkele/data.h> @@ -10,8 +9,6 @@ #include <opkele/uris.h> namespace opkele { - using std::pair; - using std::mismatch; void basic_op::reset_vars() { assoc.reset(); @@ -321,36 +318,10 @@ namespace opkele { } void basic_op::verify_return_to() { - string nrealm = opkele::util::rfc_3986_normalize_uri(realm); - if(nrealm.find('#')!=string::npos) + if(realm.find('#')!=string::npos) throw opkele::bad_realm(OPKELE_CP_ "authentication realm contains URI fragment"); - string nrt = opkele::util::rfc_3986_normalize_uri(return_to); - string::size_type pr = nrealm.find("://"); - string::size_type prt = nrt.find("://"); - assert(!(pr==string::npos || prt==string::npos)); - pr += sizeof("://")-1; - prt += sizeof("://")-1; - if(!strncmp(nrealm.c_str()+pr,"*.",2)) { - pr = nrealm.find('.',pr); - prt = nrt.find('.',prt); - assert(pr!=string::npos); - if(prt==string::npos) - throw bad_return_to( - OPKELE_CP_ "return_to URL doesn't match realm"); - // TODO: check for overgeneralized realm - } - string::size_type lr = nrealm.length(); - string::size_type lrt = nrt.length(); - if( (lrt-prt) < (lr-pr) ) - throw bad_return_to( - OPKELE_CP_ "return_to URL doesn't match realm"); - pair<const char*,const char*> mp = mismatch( - nrealm.c_str()+pr,nrealm.c_str()+lr, - nrt.c_str()+prt); - if( (*(mp.first-1))!='/' - && !strchr("/?#",*mp.second) ) - throw bad_return_to( - OPKELE_CP_ "return_to URL doesn't match realm"); + if(!util::uri_matches_realm(return_to,realm)) + throw bad_return_to(OPKELE_CP_ "return_to URL doesn't match realm"); } } |