summaryrefslogtreecommitdiffabout
authorMichael Krelin <hacker@klever.net>2009-01-21 19:48:17 (UTC)
committer Michael Krelin <hacker@klever.net>2009-01-21 19:48:17 (UTC)
commit485a0816b78fcf53a717e8e7cbeabee0b83091e7 (patch) (unidiff)
tree1100501fe3590a63ac615ac23747d6d30ed8a2ae
parenta2a524f744849e81ec91a7afbaf641d1b57e14b1 (diff)
downloadlibopkele-485a0816b78fcf53a717e8e7cbeabee0b83091e7.zip
libopkele-485a0816b78fcf53a717e8e7cbeabee0b83091e7.tar.gz
libopkele-485a0816b78fcf53a717e8e7cbeabee0b83091e7.tar.bz2
Do not bomb out on unusual xml
In particular, properly handle directy Type child of XRD element. As usually, thanks to Joseph Smarr of Plaxo for spotting it ;-) Signed-off-by: Michael Krelin <hacker@klever.net>
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--lib/discovery.cc41
1 files changed, 26 insertions, 15 deletions
diff --git a/lib/discovery.cc b/lib/discovery.cc
index cbdceb3..f8a3988 100644
--- a/lib/discovery.cc
+++ b/lib/discovery.cc
@@ -455,23 +455,34 @@ namespace opkele {
455 } 455 }
456 if(is_qelement(n,NSURI_XRD "\tType")) { 456 if(is_qelement(n,NSURI_XRD "\tType")) {
457 assert(xrd); assert(xrd_service); assert(cdata==&cdata_buf); 457 if(xrd && xrd_service) {
458 xrd_service->types.insert(cdata_buf); 458 assert(cdata==&cdata_buf);
459 xrd_service->types.insert(cdata_buf);
460 }
459 }else if(is_qelement(n,NSURI_XRD "\tService")) { 461 }else if(is_qelement(n,NSURI_XRD "\tService")) {
460 assert(xrd); assert(xrd_service); 462 if(!(xrd && xrd_service)) {
461 assert(!pt_stack.empty()); 463 skipping = -1;
462 assert(pt_stack.back()==(NSURI_XRD "\tService")); 464 }else{
463 pt_stack.pop_back(); 465 assert(!pt_stack.empty());
464 xrd_service = 0; 466 assert(pt_stack.back()==(NSURI_XRD "\tService"));
465 }else if(is_qelement(n,NSURI_XRD "\tStatus")) {
466 assert(xrd);
467 if(is_qelement(pt_stack.back().c_str(),n)) {
468 assert(cdata==&status_string);
469 pt_stack.pop_back(); 467 pt_stack.pop_back();
470 if(status_code!=100) 468 xrd_service = 0;
471 skipping = -1; 469 }
470 }else if(is_qelement(n,NSURI_XRD "\tStatus")) {
471 if(!xrd) {
472 skipping=-1;
473 }else{
474 if(is_qelement(pt_stack.back().c_str(),n)) {
475 assert(cdata==&status_string);
476 pt_stack.pop_back();
477 if(status_code!=100)
478 skipping = -1;
479 }
472 } 480 }
473 }else if(is_qelement(n,NSURI_XRD "\tExpires")) { 481 }else if(is_qelement(n,NSURI_XRD "\tExpires")) {
474 assert(xrd); 482 if(!xrd) {
475 xrd->expires = util::w3c_to_time(cdata_buf); 483 skipping=-1;
484 }else{
485 xrd->expires = util::w3c_to_time(cdata_buf);
486 }
476 }else if((xmode&xmode_html) && is_element(n,"head")) { 487 }else if((xmode&xmode_html) && is_element(n,"head")) {
477 skipping = -1; 488 skipping = -1;