author | Michael Krelin <hacker@klever.net> | 2009-01-21 19:48:17 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2009-01-21 19:48:17 (UTC) |
commit | 485a0816b78fcf53a717e8e7cbeabee0b83091e7 (patch) (unidiff) | |
tree | 1100501fe3590a63ac615ac23747d6d30ed8a2ae /lib | |
parent | a2a524f744849e81ec91a7afbaf641d1b57e14b1 (diff) | |
download | libopkele-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>
-rw-r--r-- | lib/discovery.cc | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/lib/discovery.cc b/lib/discovery.cc index cbdceb3..f8a3988 100644 --- a/lib/discovery.cc +++ b/lib/discovery.cc | |||
@@ -454,25 +454,36 @@ namespace opkele { | |||
454 | --skipping; return; | 454 | --skipping; return; |
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 | assert(cdata==&cdata_buf); | ||
458 | xrd_service->types.insert(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)) { |
463 | skipping = -1; | ||
464 | }else{ | ||
461 | assert(!pt_stack.empty()); | 465 | assert(!pt_stack.empty()); |
462 | assert(pt_stack.back()==(NSURI_XRD "\tService")); | 466 | assert(pt_stack.back()==(NSURI_XRD "\tService")); |
463 | pt_stack.pop_back(); | 467 | pt_stack.pop_back(); |
464 | xrd_service = 0; | 468 | xrd_service = 0; |
469 | } | ||
465 | }else if(is_qelement(n,NSURI_XRD "\tStatus")) { | 470 | }else if(is_qelement(n,NSURI_XRD "\tStatus")) { |
466 | assert(xrd); | 471 | if(!xrd) { |
472 | skipping=-1; | ||
473 | }else{ | ||
467 | if(is_qelement(pt_stack.back().c_str(),n)) { | 474 | if(is_qelement(pt_stack.back().c_str(),n)) { |
468 | assert(cdata==&status_string); | 475 | assert(cdata==&status_string); |
469 | pt_stack.pop_back(); | 476 | pt_stack.pop_back(); |
470 | if(status_code!=100) | 477 | if(status_code!=100) |
471 | skipping = -1; | 478 | skipping = -1; |
472 | } | 479 | } |
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) { |
483 | skipping=-1; | ||
484 | }else{ | ||
475 | xrd->expires = util::w3c_to_time(cdata_buf); | 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; |
478 | } | 489 | } |