-rw-r--r-- | lib/discovery.cc | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/discovery.cc b/lib/discovery.cc index 81727c0..8729cfb 100644 --- a/lib/discovery.cc +++ b/lib/discovery.cc | |||
@@ -4,8 +4,9 @@ | |||
4 | #include <opkele/uris.h> | 4 | #include <opkele/uris.h> |
5 | #include <opkele/discovery.h> | 5 | #include <opkele/discovery.h> |
6 | #include <opkele/exception.h> | 6 | #include <opkele/exception.h> |
7 | #include <opkele/util.h> | 7 | #include <opkele/util.h> |
8 | #include <opkele/debug.h> | ||
8 | 9 | ||
9 | #include "config.h" | 10 | #include "config.h" |
10 | 11 | ||
11 | #define XRDS_HEADER "X-XRDS-Location" | 12 | #define XRDS_HEADER "X-XRDS-Location" |
@@ -174,9 +175,13 @@ namespace opkele { | |||
174 | size_t write(void *p,size_t s,size_t nm) { | 175 | size_t write(void *p,size_t s,size_t nm) { |
175 | if(skipping<0) return 0; | 176 | if(skipping<0) return 0; |
176 | /* TODO: limit total size */ | 177 | /* TODO: limit total size */ |
177 | size_t bytes = s*nm; | 178 | size_t bytes = s*nm; |
178 | parse((const char *)p,bytes,false); | 179 | bool rp = parse((const char *)p,bytes,false); |
180 | if(!rp) { | ||
181 | skipping = -1; | ||
182 | bytes = 0; | ||
183 | } | ||
179 | return bytes; | 184 | return bytes; |
180 | } | 185 | } |
181 | size_t header(void *p,size_t s,size_t nm) { | 186 | size_t header(void *p,size_t s,size_t nm) { |
182 | size_t bytes = s*nm; | 187 | size_t bytes = s*nm; |
@@ -224,9 +229,9 @@ namespace opkele { | |||
224 | pt_stack.push_back(n); | 229 | pt_stack.push_back(n); |
225 | }else if(xmode&xmode_html) { | 230 | }else if(xmode&xmode_html) { |
226 | html_start_element(n,a); | 231 | html_start_element(n,a); |
227 | }else{ | 232 | }else{ |
228 | skipping = -1; | 233 | skipping = -1; stop_parser(); |
229 | } | 234 | } |
230 | }else{ | 235 | }else{ |
231 | int pt_s = pt_stack.size(); | 236 | int pt_s = pt_stack.size(); |
232 | if(pt_s==1) { | 237 | if(pt_s==1) { |
@@ -309,16 +314,17 @@ namespace opkele { | |||
309 | assert(xrd); | 314 | assert(xrd); |
310 | if(is_qelement(pt_stack.back().c_str(),n)) { | 315 | if(is_qelement(pt_stack.back().c_str(),n)) { |
311 | assert(cdata==&status_string); | 316 | assert(cdata==&status_string); |
312 | pt_stack.pop_back(); | 317 | pt_stack.pop_back(); |
313 | if(status_code!=100) | 318 | if(status_code!=100) { |
314 | skipping = -1; | 319 | skipping = -1; stop_parser(); |
320 | } | ||
315 | } | 321 | } |
316 | }else if(is_qelement(n,NSURI_XRD "\tExpires")) { | 322 | }else if(is_qelement(n,NSURI_XRD "\tExpires")) { |
317 | assert(xrd); | 323 | assert(xrd); |
318 | xrd->expires = util::w3c_to_time(cdata_buf); | 324 | xrd->expires = util::w3c_to_time(cdata_buf); |
319 | }else if((xmode&xmode_html) && is_element(n,"head")) { | 325 | }else if((xmode&xmode_html) && is_element(n,"head")) { |
320 | skipping = -1; | 326 | skipping = -1; stop_parser(); |
321 | } | 327 | } |
322 | cdata = 0; | 328 | cdata = 0; |
323 | } | 329 | } |
324 | void character_data(const XML_Char *s,int l) { | 330 | void character_data(const XML_Char *s,int l) { |
@@ -373,9 +379,9 @@ namespace opkele { | |||
373 | else if(rel=="openid2.local_id") | 379 | else if(rel=="openid2.local_id") |
374 | html_openid2.local_ids.add(-1,href); | 380 | html_openid2.local_ids.add(-1,href); |
375 | } | 381 | } |
376 | }else if(is_element(n,"body")) { | 382 | }else if(is_element(n,"body")) { |
377 | skipping = -1; | 383 | skipping = -1; stop_parser(); |
378 | } | 384 | } |
379 | } | 385 | } |
380 | 386 | ||
381 | }; | 387 | }; |