-rw-r--r-- | COPYING | 2 | ||||
-rw-r--r-- | NEWS.xml | 8 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | include/opkele/expat.h | 3 | ||||
-rw-r--r-- | lib/basic_rp.cc | 1 | ||||
-rw-r--r-- | lib/discovery.cc | 53 | ||||
-rw-r--r-- | lib/expat.cc | 9 |
7 files changed, 61 insertions, 17 deletions
@@ -1,13 +1,13 @@ | |||
1 | Copyright (c) 2005-2007 Klever Group (http://www.klever.net/) | 1 | Copyright (c) 2005-2008 Klever Group (http://www.klever.net/) |
2 | 2 | ||
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of |
4 | this software and associated documentation files (the "Software"), to deal in | 4 | this software and associated documentation files (the "Software"), to deal in |
5 | the Software without restriction, including without limitation the rights to | 5 | the Software without restriction, including without limitation the rights to |
6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies |
7 | of the Software, and to permit persons to whom the Software is furnished to do | 7 | of the Software, and to permit persons to whom the Software is furnished to do |
8 | so, subject to the following conditions: | 8 | so, subject to the following conditions: |
9 | 9 | ||
10 | The above copyright notice and this permission notice shall be included in all | 10 | The above copyright notice and this permission notice shall be included in all |
11 | copies or substantial portions of the Software. | 11 | copies or substantial portions of the Software. |
12 | 12 | ||
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
@@ -1,14 +1,22 @@ | |||
1 | <?xml version="1.0" encoding="us-ascii"?> | 1 | <?xml version="1.0" encoding="us-ascii"?> |
2 | <news> | 2 | <news> |
3 | <version version="2.0.1" date="November 22nd, 2008"> | ||
4 | <ni>Compile-time fixes and improvements</ni> | ||
5 | <ni>Portability improvements for FreeBSD</ni> | ||
6 | <ni>Really suppress debugging message from htmltidy when --disable-debug is in | ||
7 | effect</ni> | ||
8 | <ni>minor bugfixes</ni> | ||
9 | <ni>thread-safety improvements</ni> | ||
10 | </version> | ||
3 | <version version="2.0" date="June 26th, 2008"> | 11 | <version version="2.0" date="June 26th, 2008"> |
4 | <ni>OpenID 2.0 support</ni> | 12 | <ni>OpenID 2.0 support</ni> |
5 | <ni>Major rewrite of the whole thing</ni> | 13 | <ni>Major rewrite of the whole thing</ni> |
6 | <ni>Support for XRDS (YADIS and XRI/inames) discovery</ni> | 14 | <ni>Support for XRDS (YADIS and XRI/inames) discovery</ni> |
7 | <ni>Sheerly improved html-based discovery (only code using new, 2.0-enabled | 15 | <ni>Sheerly improved html-based discovery (only code using new, 2.0-enabled |
8 | classes benefits from it)</ni> | 16 | classes benefits from it)</ni> |
9 | <ni>Deprecation of the old api</ni> | 17 | <ni>Deprecation of the old api</ni> |
10 | <ni>Added sample RP and OP implementations</ni> | 18 | <ni>Added sample RP and OP implementations</ni> |
11 | <ni>Require expat xml stream parser library</ni> | 19 | <ni>Require expat xml stream parser library</ni> |
12 | <ni>Require htmltidy library</ni> | 20 | <ni>Require htmltidy library</ni> |
13 | <ni>Require tr1/memory (shared_ptr) support - either modern gcc or boost | 21 | <ni>Require tr1/memory (shared_ptr) support - either modern gcc or boost |
14 | library</ni> | 22 | library</ni> |
diff --git a/configure.ac b/configure.ac index 3484146..a7b56ff 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -1,13 +1,13 @@ | |||
1 | AC_INIT([libopkele], [2.0], [libopkele-bugs@klever.net]) | 1 | AC_INIT([libopkele], [2.0.1], [libopkele-bugs@klever.net]) |
2 | AC_CONFIG_SRCDIR([include/opkele/opkele-config.h]) | 2 | AC_CONFIG_SRCDIR([include/opkele/opkele-config.h]) |
3 | AC_CONFIG_HEADERS([config.h include/opkele/acconfig.h]) | 3 | AC_CONFIG_HEADERS([config.h include/opkele/acconfig.h]) |
4 | AM_INIT_AUTOMAKE([dist-bzip2]) | 4 | AM_INIT_AUTOMAKE([dist-bzip2]) |
5 | 5 | ||
6 | AC_PROG_INSTALL | 6 | AC_PROG_INSTALL |
7 | AC_PROG_CXX | 7 | AC_PROG_CXX |
8 | AC_PROG_CC | 8 | AC_PROG_CC |
9 | AC_PROG_LIBTOOL | 9 | AC_PROG_LIBTOOL |
10 | PKG_PROG_PKG_CONFIG | 10 | PKG_PROG_PKG_CONFIG |
11 | 11 | ||
12 | AC_HEADER_STDC | 12 | AC_HEADER_STDC |
13 | AC_CHECK_FUNCS([timegm]) | 13 | AC_CHECK_FUNCS([timegm]) |
diff --git a/include/opkele/expat.h b/include/opkele/expat.h index 3ab1630..21be003 100644 --- a/include/opkele/expat.h +++ b/include/opkele/expat.h | |||
@@ -17,24 +17,27 @@ namespace opkele { | |||
17 | virtual ~expat_t() throw(); | 17 | virtual ~expat_t() throw(); |
18 | 18 | ||
19 | expat_t& operator=(XML_Parser x); | 19 | expat_t& operator=(XML_Parser x); |
20 | 20 | ||
21 | operator const XML_Parser(void) const { return _x; } | 21 | operator const XML_Parser(void) const { return _x; } |
22 | operator XML_Parser(void) { return _x; } | 22 | operator XML_Parser(void) { return _x; } |
23 | 23 | ||
24 | inline bool parse(const char *s,int len,bool final=false) { | 24 | inline bool parse(const char *s,int len,bool final=false) { |
25 | assert(_x); | 25 | assert(_x); |
26 | return XML_Parse(_x,s,len,final); | 26 | return XML_Parse(_x,s,len,final); |
27 | } | 27 | } |
28 | 28 | ||
29 | virtual int unknown_encoding(const XML_Char * /* n */,XML_Encoding * /* i */) { return XML_STATUS_ERROR; } | ||
30 | void set_unknown_encoding_handler(); | ||
31 | |||
29 | virtual void start_element(const XML_Char * /* n */,const XML_Char ** /* a */) { } | 32 | virtual void start_element(const XML_Char * /* n */,const XML_Char ** /* a */) { } |
30 | virtual void end_element(const XML_Char * /* n */) { } | 33 | virtual void end_element(const XML_Char * /* n */) { } |
31 | void set_element_handler(); | 34 | void set_element_handler(); |
32 | 35 | ||
33 | virtual void character_data(const XML_Char * /* s */,int /* l */) { } | 36 | virtual void character_data(const XML_Char * /* s */,int /* l */) { } |
34 | void set_character_data_handler(); | 37 | void set_character_data_handler(); |
35 | 38 | ||
36 | virtual void processing_instruction(const XML_Char * /* t */,const XML_Char * /* d */) { } | 39 | virtual void processing_instruction(const XML_Char * /* t */,const XML_Char * /* d */) { } |
37 | void set_processing_instruction_handler(); | 40 | void set_processing_instruction_handler(); |
38 | 41 | ||
39 | virtual void comment(const XML_Char * /* d */) { } | 42 | virtual void comment(const XML_Char * /* d */) { } |
40 | void set_comment_handler(); | 43 | void set_comment_handler(); |
diff --git a/lib/basic_rp.cc b/lib/basic_rp.cc index 3357d0b..3cad71c 100644 --- a/lib/basic_rp.cc +++ b/lib/basic_rp.cc | |||
@@ -1,12 +1,13 @@ | |||
1 | #include <sys/types.h> | ||
1 | #include <cassert> | 2 | #include <cassert> |
2 | #include <openssl/sha.h> | 3 | #include <openssl/sha.h> |
3 | #include <openssl/hmac.h> | 4 | #include <openssl/hmac.h> |
4 | #include <opkele/basic_rp.h> | 5 | #include <opkele/basic_rp.h> |
5 | #include <opkele/exception.h> | 6 | #include <opkele/exception.h> |
6 | #include <opkele/uris.h> | 7 | #include <opkele/uris.h> |
7 | #include <opkele/data.h> | 8 | #include <opkele/data.h> |
8 | #include <opkele/util.h> | 9 | #include <opkele/util.h> |
9 | #include <opkele/util-internal.h> | 10 | #include <opkele/util-internal.h> |
10 | #include <opkele/curl.h> | 11 | #include <opkele/curl.h> |
11 | #include <opkele/debug.h> | 12 | #include <opkele/debug.h> |
12 | 13 | ||
diff --git a/lib/discovery.cc b/lib/discovery.cc index bd1f917..26f3eed 100644 --- a/lib/discovery.cc +++ b/lib/discovery.cc | |||
@@ -274,24 +274,25 @@ namespace opkele { | |||
274 | throw exception_tidy(OPKELE_CP_ "tidy failed to save buffer"); | 274 | throw exception_tidy(OPKELE_CP_ "tidy failed to save buffer"); |
275 | prepare_to_parse(); | 275 | prepare_to_parse(); |
276 | parse(tide.c_str(),tide.size(),true); | 276 | parse(tide.c_str(),tide.size(),true); |
277 | }catch(exception_tidy& et) { } | 277 | }catch(exception_tidy& et) { } |
278 | } | 278 | } |
279 | save_html.clear(); | 279 | save_html.clear(); |
280 | } | 280 | } |
281 | 281 | ||
282 | void prepare_to_parse() { | 282 | void prepare_to_parse() { |
283 | (*(expat_t*)this) = parser_create_ns(); | 283 | (*(expat_t*)this) = parser_create_ns(); |
284 | set_user_data(); set_element_handler(); | 284 | set_user_data(); set_element_handler(); |
285 | set_character_data_handler(); | 285 | set_character_data_handler(); |
286 | set_unknown_encoding_handler(); | ||
286 | 287 | ||
287 | if(xmode&xmode_html) { | 288 | if(xmode&xmode_html) { |
288 | html_openid1.clear(); html_openid2.clear(); | 289 | html_openid1.clear(); html_openid2.clear(); |
289 | parser_choked = false; | 290 | parser_choked = false; |
290 | } | 291 | } |
291 | 292 | ||
292 | cdata = 0; xrd_service = 0; skipping = 0; | 293 | cdata = 0; xrd_service = 0; skipping = 0; |
293 | pt_stack.clear(); | 294 | pt_stack.clear(); |
294 | status_code = 100; status_string.clear(); | 295 | status_code = 100; status_string.clear(); |
295 | } | 296 | } |
296 | 297 | ||
297 | void html2xrd(endpoint_discovery_iterator& oi,idiscovery_t& id) { | 298 | void html2xrd(endpoint_discovery_iterator& oi,idiscovery_t& id) { |
@@ -444,43 +445,58 @@ namespace opkele { | |||
444 | html_start_element(n,a); | 445 | html_start_element(n,a); |
445 | }else{ | 446 | }else{ |
446 | skipping = 1; | 447 | skipping = 1; |
447 | } | 448 | } |
448 | } | 449 | } |
449 | } | 450 | } |
450 | void end_element(const XML_Char *n) { | 451 | void end_element(const XML_Char *n) { |
451 | if(skipping<0) return; | 452 | if(skipping<0) return; |
452 | if(skipping) { | 453 | if(skipping) { |
453 | --skipping; return; | 454 | --skipping; return; |
454 | } | 455 | } |
455 | if(is_qelement(n,NSURI_XRD "\tType")) { | 456 | if(is_qelement(n,NSURI_XRD "\tType")) { |
456 | assert(xrd); assert(xrd_service); assert(cdata==&cdata_buf); | 457 | if(xrd && xrd_service) { |
457 | xrd_service->types.insert(cdata_buf); | 458 | assert(cdata==&cdata_buf); |
459 | xrd_service->types.insert(cdata_buf); | ||
460 | } | ||
458 | }else if(is_qelement(n,NSURI_XRD "\tService")) { | 461 | }else if(is_qelement(n,NSURI_XRD "\tService")) { |
459 | assert(xrd); assert(xrd_service); | 462 | if(!(xrd && xrd_service)) { |
460 | assert(!pt_stack.empty()); | 463 | skipping = -1; |
461 | assert(pt_stack.back()==(NSURI_XRD "\tService")); | 464 | }else{ |
462 | pt_stack.pop_back(); | 465 | assert(!pt_stack.empty()); |
463 | xrd_service = 0; | 466 | assert(pt_stack.back()==(NSURI_XRD "\tService")); |
464 | }else if(is_qelement(n,NSURI_XRD "\tStatus")) { | ||
465 | assert(xrd); | ||
466 | if(is_qelement(pt_stack.back().c_str(),n)) { | ||
467 | assert(cdata==&status_string); | ||
468 | pt_stack.pop_back(); | 467 | pt_stack.pop_back(); |
469 | if(status_code!=100) | 468 | xrd_service = 0; |
470 | 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 | } | ||
471 | } | 480 | } |
472 | }else if(is_qelement(n,NSURI_XRD "\tExpires")) { | 481 | }else if(is_qelement(n,NSURI_XRD "\tExpires")) { |
473 | assert(xrd); | 482 | if(!xrd) { |
474 | xrd->expires = util::w3c_to_time(cdata_buf); | 483 | skipping=-1; |
484 | }else{ | ||
485 | xrd->expires = util::w3c_to_time(cdata_buf); | ||
486 | } | ||
487 | }else if(is_qelement(n,NSURI_XRD "\tXRD")) { | ||
488 | assert(!pt_stack.empty()); | ||
489 | assert(pt_stack.back()==(NSURI_XRD "\tXRD")); | ||
490 | pt_stack.pop_back(); | ||
475 | }else if((xmode&xmode_html) && is_element(n,"head")) { | 491 | }else if((xmode&xmode_html) && is_element(n,"head")) { |
476 | skipping = -1; | 492 | skipping = -1; |
477 | } | 493 | } |
478 | cdata = 0; | 494 | cdata = 0; |
479 | } | 495 | } |
480 | void character_data(const XML_Char *s,int l) { | 496 | void character_data(const XML_Char *s,int l) { |
481 | if(skipping) return; | 497 | if(skipping) return; |
482 | if(cdata) cdata->append(s,l); | 498 | if(cdata) cdata->append(s,l); |
483 | } | 499 | } |
484 | 500 | ||
485 | void html_start_element(const XML_Char *n,const XML_Char **a) { | 501 | void html_start_element(const XML_Char *n,const XML_Char **a) { |
486 | if(is_element(n,"meta")) { | 502 | if(is_element(n,"meta")) { |
@@ -560,24 +576,31 @@ namespace opkele { | |||
560 | }else{ | 576 | }else{ |
561 | for(xrd::local_ids_t::const_iterator ilid=svc.local_ids.begin(); | 577 | for(xrd::local_ids_t::const_iterator ilid=svc.local_ids.begin(); |
562 | ilid!=svc.local_ids.end(); ++ilid) { | 578 | ilid!=svc.local_ids.end(); ++ilid) { |
563 | ep.local_id = ilid->second; | 579 | ep.local_id = ilid->second; |
564 | *(oi++) = ep; | 580 | *(oi++) = ep; |
565 | } | 581 | } |
566 | } | 582 | } |
567 | } | 583 | } |
568 | } | 584 | } |
569 | } | 585 | } |
570 | } | 586 | } |
571 | 587 | ||
588 | int unknown_encoding(const XML_Char *n,XML_Encoding *i) { | ||
589 | for(int ii=0;ii < sizeof(i->map)/sizeof(i->map[0]);++ii) | ||
590 | i->map[ii] = ii; | ||
591 | i->convert = 0; i->release = 0; | ||
592 | return XML_STATUS_OK; | ||
593 | } | ||
594 | |||
572 | }; | 595 | }; |
573 | 596 | ||
574 | string idiscover(endpoint_discovery_iterator oi,const string& identity) { | 597 | string idiscover(endpoint_discovery_iterator oi,const string& identity) { |
575 | idigger_t idigger; | 598 | idigger_t idigger; |
576 | return idigger.discover(oi,identity); | 599 | return idigger.discover(oi,identity); |
577 | } | 600 | } |
578 | 601 | ||
579 | void yadiscover(endpoint_discovery_iterator oi,const string& yurl,const char **types,bool redirs) try { | 602 | void yadiscover(endpoint_discovery_iterator oi,const string& yurl,const char **types,bool redirs) try { |
580 | idigger_t idigger; | 603 | idigger_t idigger; |
581 | idigger.yadiscover(oi,yurl,types,redirs); | 604 | idigger.yadiscover(oi,yurl,types,redirs); |
582 | }catch(exception_curl& ec) { | 605 | }catch(exception_curl& ec) { |
583 | if(redirs || ec._error!=CURLE_TOO_MANY_REDIRECTS) | 606 | if(redirs || ec._error!=CURLE_TOO_MANY_REDIRECTS) |
diff --git a/lib/expat.cc b/lib/expat.cc index c4dab7e..fb58a9a 100644 --- a/lib/expat.cc +++ b/lib/expat.cc | |||
@@ -83,15 +83,24 @@ namespace opkele { | |||
83 | static void _start_namespace_decl(void *ud,const XML_Char *p,const XML_Char *u) { | 83 | static void _start_namespace_decl(void *ud,const XML_Char *p,const XML_Char *u) { |
84 | ((expat_t*)ud)->start_namespace_decl(p,u); | 84 | ((expat_t*)ud)->start_namespace_decl(p,u); |
85 | } | 85 | } |
86 | static void _end_namespace_decl(void *ud,const XML_Char *p) { | 86 | static void _end_namespace_decl(void *ud,const XML_Char *p) { |
87 | ((expat_t*)ud)->end_namespace_decl(p); | 87 | ((expat_t*)ud)->end_namespace_decl(p); |
88 | } | 88 | } |
89 | 89 | ||
90 | void expat_t::set_namespace_decl_handler() { | 90 | void expat_t::set_namespace_decl_handler() { |
91 | assert(_x); | 91 | assert(_x); |
92 | XML_SetNamespaceDeclHandler(_x,_start_namespace_decl,_end_namespace_decl); | 92 | XML_SetNamespaceDeclHandler(_x,_start_namespace_decl,_end_namespace_decl); |
93 | } | 93 | } |
94 | 94 | ||
95 | static int _unknown_encoding(void *ehd,const XML_Char *n,XML_Encoding *i) { | ||
96 | return ((expat_t*)ehd)->unknown_encoding(n,i); | ||
97 | } | ||
98 | |||
99 | void expat_t::set_unknown_encoding_handler() { | ||
100 | assert(_x); | ||
101 | XML_SetUnknownEncodingHandler(_x,_unknown_encoding,this); | ||
102 | } | ||
103 | |||
95 | } | 104 | } |
96 | 105 | ||
97 | } | 106 | } |