summaryrefslogtreecommitdiffabout
authorMichael Krelin <hacker@klever.net>2007-09-22 21:02:48 (UTC)
committer Michael Krelin <hacker@klever.net>2007-09-22 21:02:48 (UTC)
commit17dd1771421d1098a2ba8dc16ae381912cae64ef (patch) (unidiff)
treee4a3c21ab8dad60ef746b6650e63ddb9d608742c
parent5cb71518360f865cd4448a083b5d481e6f356a3e (diff)
downloadlibopkele-17dd1771421d1098a2ba8dc16ae381912cae64ef.zip
libopkele-17dd1771421d1098a2ba8dc16ae381912cae64ef.tar.gz
libopkele-17dd1771421d1098a2ba8dc16ae381912cae64ef.tar.bz2
save a couple of ticks
Signed-off-by: Michael Krelin <hacker@klever.net>
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--lib/consumer.cc5
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/consumer.cc b/lib/consumer.cc
index df95b64..7f31d52 100644
--- a/lib/consumer.cc
+++ b/lib/consumer.cc
@@ -329,38 +329,37 @@ namespace opkele {
329 *re_hre = "\\bhref\\s*=\\s*['\"]\\s*([^'\"\\s]+)\\s*['\"]"; 329 *re_hre = "\\bhref\\s*=\\s*['\"]\\s*([^'\"\\s]+)\\s*['\"]";
330 pcre_matches_t m1(3), m2(3); 330 pcre_matches_t m1(3), m2(3);
331 pcre_t bre(re_bre,PCRE_CASELESS); 331 pcre_t bre(re_bre,PCRE_CASELESS);
332 if(bre.exec(html,m1)>0) 332 if(bre.exec(html,m1)>0)
333 html.erase(m1.begin(0)); 333 html.erase(m1.begin(0));
334 pcre_t hdre(re_hdre,PCRE_CASELESS); 334 pcre_t hdre(re_hdre,PCRE_CASELESS);
335 if(hdre.exec(html,m1)<=0) 335 if(hdre.exec(html,m1)<=0)
336 throw bad_input(OPKELE_CP_ "failed to find <head>"); 336 throw bad_input(OPKELE_CP_ "failed to find <head>");
337 html.erase(0,m1.end(0)+1); 337 html.erase(0,m1.end(0)+1);
338 pcre_t lre(re_lre,PCRE_CASELESS), rre(re_rre,PCRE_CASELESS), hre(re_hre,PCRE_CASELESS); 338 pcre_t lre(re_lre,PCRE_CASELESS), rre(re_rre,PCRE_CASELESS), hre(re_hre,PCRE_CASELESS);
339 while(lre.exec(html,m1)>=2) { 339 while(lre.exec(html,m1)>=2) {
340 string attrs(html,m1.begin(1),m1.length(1)); 340 string attrs(html,m1.begin(1),m1.length(1));
341 html.erase(0,m1.end(0)+1); 341 html.erase(0,m1.end(0)+1);
342 if(!( rre.exec(attrs,m1)>=2 && hre.exec(attrs,m2)>=2 )) 342 if(!( rre.exec(attrs,m1)>=2 && hre.exec(attrs,m2)>=2 ))
343 continue; 343 continue;
344 string rel(attrs,m1.begin(1),m1.length(1)); 344 string rel(attrs,m1.begin(1),m1.length(1));
345 string href(attrs,m2.begin(1),m2.length(1));
346 if(rel=="openid.server") { 345 if(rel=="openid.server") {
347 server = href; 346 server.assign(attrs,m2.begin(1),m2.length(1));
348 if(!delegate.empty()) break; 347 if(!delegate.empty()) break;
349 }else if(rel=="openid.delegate") { 348 }else if(rel=="openid.delegate") {
350 delegate = href; 349 delegate.assign(attrs,m2.begin(1),m2.length(1));
351 if(!server.empty()) break; 350 if(!server.empty()) break;
352 } 351 }
353 } 352 }
354 if(server.empty()) 353 if(server.empty())
355 throw failed_assertion(OPKELE_CP_ "The location has no openid.server declaration"); 354 throw failed_assertion(OPKELE_CP_ "The location has no openid.server declaration");
356 } 355 }
357 356
358 assoc_t consumer_t::find_assoc(const string& server) { 357 assoc_t consumer_t::find_assoc(const string& server) {
359 throw failed_lookup(OPKELE_CP_ "no find_assoc() provided"); 358 throw failed_lookup(OPKELE_CP_ "no find_assoc() provided");
360 } 359 }
361 360
362 string consumer_t::normalize(const string& url) { 361 string consumer_t::normalize(const string& url) {
363 string rv = url; 362 string rv = url;
364 // strip leading and trailing spaces 363 // strip leading and trailing spaces
365 string::size_type i = rv.find_first_not_of(" \t\r\n"); 364 string::size_type i = rv.find_first_not_of(" \t\r\n");
366 if(i==string::npos) 365 if(i==string::npos)