-rw-r--r-- | lib/consumer.cc | 1 |
1 files changed, 0 insertions, 1 deletions
diff --git a/lib/consumer.cc b/lib/consumer.cc index 62bec71..66db7dd 100644 --- a/lib/consumer.cc +++ b/lib/consumer.cc | |||
@@ -315,65 +315,64 @@ namespace opkele { | |||
315 | while( (!gotit) && lre.exec(html,m1)>=2 ) { | 315 | while( (!gotit) && lre.exec(html,m1)>=2 ) { |
316 | static const char *whitespace = " \t"; | 316 | static const char *whitespace = " \t"; |
317 | string attrs(html,m1.begin(1),m1.length(1)); | 317 | string attrs(html,m1.begin(1),m1.length(1)); |
318 | html.erase(0,m1.end(0)+1); | 318 | html.erase(0,m1.end(0)+1); |
319 | if(!( rre.exec(attrs,m1)>=2 && hre.exec(attrs,m2)>=2 )) | 319 | if(!( rre.exec(attrs,m1)>=2 && hre.exec(attrs,m2)>=2 )) |
320 | continue; | 320 | continue; |
321 | string rels(attrs,m1.begin(1),m1.length(1)); | 321 | string rels(attrs,m1.begin(1),m1.length(1)); |
322 | for(string::size_type ns = rels.find_first_not_of(whitespace); | 322 | for(string::size_type ns = rels.find_first_not_of(whitespace); |
323 | ns!=string::npos; | 323 | ns!=string::npos; |
324 | ns=rels.find_first_not_of(whitespace,ns)) { | 324 | ns=rels.find_first_not_of(whitespace,ns)) { |
325 | string::size_type s = rels.find_first_of(whitespace,ns); | 325 | string::size_type s = rels.find_first_of(whitespace,ns); |
326 | string rel; | 326 | string rel; |
327 | if(s==string::npos) { | 327 | if(s==string::npos) { |
328 | rel.assign(rels,ns,string::npos); | 328 | rel.assign(rels,ns,string::npos); |
329 | ns=string::npos; | 329 | ns=string::npos; |
330 | }else{ | 330 | }else{ |
331 | rel.assign(rels,ns,s-ns); | 331 | rel.assign(rels,ns,s-ns); |
332 | ns=s; | 332 | ns=s; |
333 | } | 333 | } |
334 | if(rel=="openid.server") { | 334 | if(rel=="openid.server") { |
335 | server.assign(attrs,m2.begin(1),m2.length(1)); | 335 | server.assign(attrs,m2.begin(1),m2.length(1)); |
336 | if(!delegate.empty()) { | 336 | if(!delegate.empty()) { |
337 | gotit = true; | 337 | gotit = true; |
338 | break; | 338 | break; |
339 | } | 339 | } |
340 | }else if(rel=="openid.delegate") { | 340 | }else if(rel=="openid.delegate") { |
341 | delegate.assign(attrs,m2.begin(1),m2.length(1)); | 341 | delegate.assign(attrs,m2.begin(1),m2.length(1)); |
342 | if(!server.empty()) { | 342 | if(!server.empty()) { |
343 | gotit = true; | 343 | gotit = true; |
344 | break; | 344 | break; |
345 | } | 345 | } |
346 | } | 346 | } |
347 | if(ns==string::npos) break; | ||
348 | } | 347 | } |
349 | } | 348 | } |
350 | if(server.empty()) | 349 | if(server.empty()) |
351 | throw failed_assertion(OPKELE_CP_ "The location has no openid.server declaration"); | 350 | throw failed_assertion(OPKELE_CP_ "The location has no openid.server declaration"); |
352 | } | 351 | } |
353 | 352 | ||
354 | assoc_t consumer_t::find_assoc(const string& /* server */) { | 353 | assoc_t consumer_t::find_assoc(const string& /* server */) { |
355 | throw failed_lookup(OPKELE_CP_ "no find_assoc() provided"); | 354 | throw failed_lookup(OPKELE_CP_ "no find_assoc() provided"); |
356 | } | 355 | } |
357 | 356 | ||
358 | string consumer_t::normalize(const string& url) { | 357 | string consumer_t::normalize(const string& url) { |
359 | string rv = url; | 358 | string rv = url; |
360 | // strip leading and trailing spaces | 359 | // strip leading and trailing spaces |
361 | string::size_type i = rv.find_first_not_of(" \t\r\n"); | 360 | string::size_type i = rv.find_first_not_of(" \t\r\n"); |
362 | if(i==string::npos) | 361 | if(i==string::npos) |
363 | throw bad_input(OPKELE_CP_ "empty URL"); | 362 | throw bad_input(OPKELE_CP_ "empty URL"); |
364 | if(i) | 363 | if(i) |
365 | rv.erase(0,i); | 364 | rv.erase(0,i); |
366 | i = rv.find_last_not_of(" \t\r\n"); | 365 | i = rv.find_last_not_of(" \t\r\n"); |
367 | assert(i!=string::npos); | 366 | assert(i!=string::npos); |
368 | if(i<(rv.length()-1)) | 367 | if(i<(rv.length()-1)) |
369 | rv.erase(i+1); | 368 | rv.erase(i+1); |
370 | // add missing http:// | 369 | // add missing http:// |
371 | i = rv.find("://"); | 370 | i = rv.find("://"); |
372 | if(i==string::npos) { // primitive. but do we need more? | 371 | if(i==string::npos) { // primitive. but do we need more? |
373 | rv.insert(0,"http://"); | 372 | rv.insert(0,"http://"); |
374 | i = sizeof("http://")-1; | 373 | i = sizeof("http://")-1; |
375 | }else{ | 374 | }else{ |
376 | i += sizeof("://")-1; | 375 | i += sizeof("://")-1; |
377 | } | 376 | } |
378 | string::size_type qm = rv.find('?',i); | 377 | string::size_type qm = rv.find('?',i); |
379 | string::size_type sl = rv.find('/',i); | 378 | string::size_type sl = rv.find('/',i); |