author | Michael Krelin <hacker@klever.net> | 2007-10-31 13:34:27 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-10-31 16:50:17 (UTC) |
commit | 6a228d2b1cb39007c6a7b91dae578a30e26b37fd (patch) (unidiff) | |
tree | 9cca336ffc422a2dcf81eaf43367453c767a465a /lib | |
parent | e1af6ae7242a280c486c84c9d8015911613cd159 (diff) | |
download | libopkele-6a228d2b1cb39007c6a7b91dae578a30e26b37fd.zip libopkele-6a228d2b1cb39007c6a7b91dae578a30e26b37fd.tar.gz libopkele-6a228d2b1cb39007c6a7b91dae578a30e26b37fd.tar.bz2 |
allow whitespace separated list in @rel when doing links discovery.
Thanks to Joseph Smarr and Chris Messina for bringing it to my attention!
Signed-off-by: Michael Krelin <hacker@klever.net>
-rw-r--r-- | lib/consumer.cc | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/lib/consumer.cc b/lib/consumer.cc index 7f31d52..f72ae08 100644 --- a/lib/consumer.cc +++ b/lib/consumer.cc | |||
@@ -327,3 +327,3 @@ namespace opkele { | |||
327 | *re_lre = "<\\s*link\\b([^>]+)>", | 327 | *re_lre = "<\\s*link\\b([^>]+)>", |
328 | *re_rre = "\\brel\\s*=\\s*['\"]\\s*([^'\"\\s]+)\\s*['\"]", | 328 | *re_rre = "\\brel\\s*=\\s*['\"]([^'\"]+)['\"]", |
329 | *re_hre = "\\bhref\\s*=\\s*['\"]\\s*([^'\"\\s]+)\\s*['\"]"; | 329 | *re_hre = "\\bhref\\s*=\\s*['\"]\\s*([^'\"\\s]+)\\s*['\"]"; |
@@ -338,3 +338,5 @@ namespace opkele { | |||
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 | bool gotit = false; |
340 | while( (!gotit) && lre.exec(html,m1)>=2 ) { | ||
341 | static const char *whitespace = " \t"; | ||
340 | string attrs(html,m1.begin(1),m1.length(1)); | 342 | string attrs(html,m1.begin(1),m1.length(1)); |
@@ -343,9 +345,29 @@ namespace opkele { | |||
343 | continue; | 345 | continue; |
344 | string rel(attrs,m1.begin(1),m1.length(1)); | 346 | string rels(attrs,m1.begin(1),m1.length(1)); |
345 | if(rel=="openid.server") { | 347 | for(string::size_type ns = rels.find_first_not_of(whitespace); |
346 | server.assign(attrs,m2.begin(1),m2.length(1)); | 348 | ns!=string::npos; |
347 | if(!delegate.empty()) break; | 349 | ns=rels.find_first_not_of(whitespace,ns)) { |
348 | }else if(rel=="openid.delegate") { | 350 | string::size_type s = rels.find_first_of(whitespace,ns); |
349 | delegate.assign(attrs,m2.begin(1),m2.length(1)); | 351 | string rel; |
350 | if(!server.empty()) break; | 352 | if(s==string::npos) { |
353 | rel.assign(rels,ns,string::npos); | ||
354 | ns=string::npos; | ||
355 | }else{ | ||
356 | rel.assign(rels,ns,s-ns); | ||
357 | ns=s; | ||
358 | } | ||
359 | if(rel=="openid.server") { | ||
360 | server.assign(attrs,m2.begin(1),m2.length(1)); | ||
361 | if(!delegate.empty()) { | ||
362 | gotit = true; | ||
363 | break; | ||
364 | } | ||
365 | }else if(rel=="openid.delegate") { | ||
366 | delegate.assign(attrs,m2.begin(1),m2.length(1)); | ||
367 | if(!server.empty()) { | ||
368 | gotit = true; | ||
369 | break; | ||
370 | } | ||
371 | } | ||
372 | if(ns==string::npos) break; | ||
351 | } | 373 | } |