-rw-r--r-- | .gitignore | 33 | ||||
-rw-r--r-- | COPYING | 2 | ||||
-rw-r--r-- | Makefile.am | 3 | ||||
-rw-r--r-- | NEWS.xml | 6 | ||||
-rwxr-xr-x | autogen.sh | 2 | ||||
-rw-r--r-- | autoregen.sh | 2 | ||||
-rw-r--r-- | configure.ac | 4 | ||||
-rw-r--r-- | include/opkele/expat.h | 3 | ||||
-rw-r--r-- | lib/basic_rp.cc | 3 | ||||
-rw-r--r-- | lib/discovery.cc | 53 | ||||
-rw-r--r-- | lib/expat.cc | 9 | ||||
-rw-r--r-- | test/RP.cc | 1 |
12 files changed, 82 insertions, 39 deletions
@@ -1,21 +1,16 @@ | |||
1 | configure | 1 | /configure |
2 | Makefile.in | 2 | Makefile.in |
3 | Doxyfile | 3 | /Doxyfile |
4 | config.log | 4 | /config.log |
5 | depcomp | 5 | /config.h |
6 | config.guess | 6 | /INSTALL |
7 | config.h | 7 | /NEWS |
8 | config.sub | ||
9 | ltmain.sh | ||
10 | INSTALL | ||
11 | NEWS | ||
12 | Makefile | 8 | Makefile |
13 | config.status | 9 | /config.status |
14 | stamp-h1 | 10 | /stamp-h1 |
15 | config.h.in | 11 | /config.h.in |
16 | libtool | 12 | /autom4te.cache |
17 | autom4te.cache | 13 | /libopkele.pc |
18 | libopkele.pc | 14 | /aclocal.m4 |
19 | missing | 15 | /aclocal.d |
20 | aclocal.m4 | 16 | /aux.d |
21 | install-sh | ||
@@ -1,17 +1,17 @@ | |||
1 | Copyright (c) 2005-2008 Klever Group (http://www.klever.net/) | 1 | Copyright (c) 2005-2009 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 |
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
diff --git a/Makefile.am b/Makefile.am index 3227bdb..7726dad 100644 --- a/Makefile.am +++ b/Makefile.am | |||
@@ -1,20 +1,21 @@ | |||
1 | |||
2 | SUBDIRS=include lib test | 1 | SUBDIRS=include lib test |
3 | EXTRA_DIST= NEWS NEWS.xml NEWS.xsl | 2 | EXTRA_DIST= NEWS NEWS.xml NEWS.xsl |
4 | 3 | ||
4 | ACLOCAL_AMFLAGS=-I aclocal.d | ||
5 | |||
5 | pkgconfigdir=${libdir}/pkgconfig | 6 | pkgconfigdir=${libdir}/pkgconfig |
6 | pkgconfig_DATA=libopkele.pc | 7 | pkgconfig_DATA=libopkele.pc |
7 | 8 | ||
8 | all-local: NEWS | 9 | all-local: NEWS |
9 | if HAVE_DOXYGEN | 10 | if HAVE_DOXYGEN |
10 | clean-local: | 11 | clean-local: |
11 | rm -rf doxydox | 12 | rm -rf doxydox |
12 | endif | 13 | endif |
13 | 14 | ||
14 | NEWS: NEWS.xsl NEWS.xml | 15 | NEWS: NEWS.xsl NEWS.xml |
15 | ${XSLTPROC} -o $@ NEWS.xsl NEWS.xml | 16 | ${XSLTPROC} -o $@ NEWS.xsl NEWS.xml |
16 | 17 | ||
17 | if HAVE_DOXYGEN | 18 | if HAVE_DOXYGEN |
18 | dox: Doxyfile | 19 | dox: Doxyfile |
19 | ${DOXYGEN} | 20 | ${DOXYGEN} |
20 | endif | 21 | endif |
@@ -1,18 +1,24 @@ | |||
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.2" date="April 11th, 2009"> | ||
4 | <ni>Handling of unknown encodings during discovery</ni> | ||
5 | <ni>Discovery robustness improvements</ni> | ||
6 | <ni>Workaround for OPs (e.g. livejournal.com) breaking specs</ni> | ||
7 | <ni>Build fixes and improvements</ni> | ||
8 | </version> | ||
3 | <version version="2.0.1" date="November 22nd, 2008"> | 9 | <version version="2.0.1" date="November 22nd, 2008"> |
4 | <ni>Compile-time fixes and improvements</ni> | 10 | <ni>Compile-time fixes and improvements</ni> |
5 | <ni>Portability improvements for FreeBSD</ni> | 11 | <ni>Portability improvements for FreeBSD</ni> |
6 | <ni>Really suppress debugging message from htmltidy when --disable-debug is in | 12 | <ni>Really suppress debugging message from htmltidy when --disable-debug is in |
7 | effect</ni> | 13 | effect</ni> |
8 | <ni>minor bugfixes</ni> | 14 | <ni>minor bugfixes</ni> |
9 | <ni>thread-safety improvements</ni> | 15 | <ni>thread-safety improvements</ni> |
10 | </version> | 16 | </version> |
11 | <version version="2.0" date="June 26th, 2008"> | 17 | <version version="2.0" date="June 26th, 2008"> |
12 | <ni>OpenID 2.0 support</ni> | 18 | <ni>OpenID 2.0 support</ni> |
13 | <ni>Major rewrite of the whole thing</ni> | 19 | <ni>Major rewrite of the whole thing</ni> |
14 | <ni>Support for XRDS (YADIS and XRI/inames) discovery</ni> | 20 | <ni>Support for XRDS (YADIS and XRI/inames) discovery</ni> |
15 | <ni>Sheerly improved html-based discovery (only code using new, 2.0-enabled | 21 | <ni>Sheerly improved html-based discovery (only code using new, 2.0-enabled |
16 | classes benefits from it)</ni> | 22 | classes benefits from it)</ni> |
17 | <ni>Deprecation of the old api</ni> | 23 | <ni>Deprecation of the old api</ni> |
18 | <ni>Added sample RP and OP implementations</ni> | 24 | <ni>Added sample RP and OP implementations</ni> |
@@ -1,11 +1,11 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | tool_libtoolize="$(type -P glibtoolize || type -P libtoolize)" | 2 | tool_libtoolize="$(type -P glibtoolize || type -P libtoolize)" |
3 | if test -z "$tool_libtoolize" ; then | 3 | if test -z "$tool_libtoolize" ; then |
4 | echo "Failed to find libtoolize." ; exit 1; | 4 | echo "Failed to find libtoolize." ; exit 1; |
5 | fi | 5 | fi |
6 | "$tool_libtoolize" -f \ | 6 | "$tool_libtoolize" -f \ |
7 | && aclocal \ | 7 | && aclocal -I aclocal.d \ |
8 | && autoheader \ | 8 | && autoheader \ |
9 | && automake -a \ | 9 | && automake -a \ |
10 | && autoconf \ | 10 | && autoconf \ |
11 | && ./configure "$@" | 11 | && ./configure "$@" |
diff --git a/autoregen.sh b/autoregen.sh new file mode 100644 index 0000000..ce75a08 --- a/dev/null +++ b/autoregen.sh | |||
@@ -0,0 +1,2 @@ | |||
1 | #!/bin/bash | ||
2 | eval sh autogen.sh $(./config.status --version | grep '^ with options "'|sed -e 's/^[^"]\+"//' -e 's/"$//') "$@" | ||
diff --git a/configure.ac b/configure.ac index a7b56ff..2ded490 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -1,19 +1,21 @@ | |||
1 | AC_INIT([libopkele], [2.0.1], [libopkele-bugs@klever.net]) | 1 | AC_INIT([libopkele], [2.0.2], [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 | AC_CONFIG_MACRO_DIR([aclocal.d]) | ||
5 | AC_CONFIG_AUX_DIR([aux.d]) | ||
4 | AM_INIT_AUTOMAKE([dist-bzip2]) | 6 | AM_INIT_AUTOMAKE([dist-bzip2]) |
5 | 7 | ||
6 | AC_PROG_INSTALL | 8 | AC_PROG_INSTALL |
7 | AC_PROG_CXX | 9 | AC_PROG_CXX |
8 | AC_PROG_CC | 10 | AC_PROG_CC |
9 | AC_PROG_LIBTOOL | 11 | AC_PROG_LIBTOOL |
10 | PKG_PROG_PKG_CONFIG | 12 | PKG_PROG_PKG_CONFIG |
11 | 13 | ||
12 | AC_HEADER_STDC | 14 | AC_HEADER_STDC |
13 | AC_CHECK_FUNCS([timegm]) | 15 | AC_CHECK_FUNCS([timegm]) |
14 | 16 | ||
15 | AC_PATH_PROG([XSLTPROC],[xsltproc],[true]) | 17 | AC_PATH_PROG([XSLTPROC],[xsltproc],[true]) |
16 | 18 | ||
17 | AC_MSG_CHECKING([for source tree version]) | 19 | AC_MSG_CHECKING([for source tree version]) |
18 | if headrev=$(cd $srcdir && git rev-parse --verify HEAD 2>/dev/null) ; then | 20 | if headrev=$(cd $srcdir && git rev-parse --verify HEAD 2>/dev/null) ; then |
19 | PACKAGE_SRC_VERSION="$(cd $srcdir && git describe --tags $headrev)" | 21 | PACKAGE_SRC_VERSION="$(cd $srcdir && git describe --tags $headrev)" |
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 | |||
@@ -13,32 +13,35 @@ namespace opkele { | |||
13 | XML_Parser _x; | 13 | XML_Parser _x; |
14 | 14 | ||
15 | expat_t() : _x(0) { } | 15 | expat_t() : _x(0) { } |
16 | expat_t(XML_Parser x) : _x(x) { } | 16 | expat_t(XML_Parser x) : _x(x) { } |
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(); |
41 | 44 | ||
42 | virtual void start_cdata_section() { } | 45 | virtual void start_cdata_section() { } |
43 | virtual void end_cdata_section() { } | 46 | virtual void end_cdata_section() { } |
44 | void set_cdata_section_handler(); | 47 | void set_cdata_section_handler(); |
diff --git a/lib/basic_rp.cc b/lib/basic_rp.cc index 3cad71c..9c7113b 100644 --- a/lib/basic_rp.cc +++ b/lib/basic_rp.cc | |||
@@ -205,33 +205,34 @@ namespace opkele { | |||
205 | } | 205 | } |
206 | break; | 206 | break; |
207 | }else{ | 207 | }else{ |
208 | if(eq==string::npos || eq>am) { | 208 | if(eq==string::npos || eq>am) { |
209 | p[""] = u.substr(q,eq-q); | 209 | p[""] = u.substr(q,eq-q); |
210 | }else{ | 210 | }else{ |
211 | p[u.substr(q,eq-q)] = u.substr(eq+1,am-eq-1); | 211 | p[u.substr(q,eq-q)] = u.substr(eq+1,am-eq-1); |
212 | } | 212 | } |
213 | q = ++am; | 213 | q = ++am; |
214 | } | 214 | } |
215 | } | 215 | } |
216 | } | 216 | } |
217 | 217 | ||
218 | void basic_RP::id_res(const basic_openid_message& om,extension_t *ext) { | 218 | void basic_RP::id_res(const basic_openid_message& om,extension_t *ext) { |
219 | reset_vars(); | 219 | reset_vars(); |
220 | bool o2 = om.has_field("ns") | 220 | bool o2 = om.has_field("ns") |
221 | && om.get_field("ns")==OIURI_OPENID20; | 221 | && om.get_field("ns")==OIURI_OPENID20 |
222 | && om.has_field("op_endpoint") && !om.get_field("op_endpoint").empty(); | ||
222 | if( (!o2) && om.has_field("user_setup_url")) | 223 | if( (!o2) && om.has_field("user_setup_url")) |
223 | throw id_res_setup(OPKELE_CP_ "assertion failed, setup url provided", | 224 | throw id_res_setup(OPKELE_CP_ "assertion failed, setup url provided", |
224 | om.get_field("user_setup_url")); | 225 | om.get_field("user_setup_url")); |
225 | string m = om.get_field("mode"); | 226 | string m = om.get_field("mode"); |
226 | if(o2 && m=="setup_needed") | 227 | if(o2 && m=="setup_needed") |
227 | throw id_res_setup(OPKELE_CP_ "setup needed, no setup url provided"); | 228 | throw id_res_setup(OPKELE_CP_ "setup needed, no setup url provided"); |
228 | if(m=="cancel") | 229 | if(m=="cancel") |
229 | throw id_res_cancel(OPKELE_CP_ "authentication cancelled"); | 230 | throw id_res_cancel(OPKELE_CP_ "authentication cancelled"); |
230 | bool go_dumb=false; | 231 | bool go_dumb=false; |
231 | try { | 232 | try { |
232 | string OP = o2 | 233 | string OP = o2 |
233 | ?om.get_field("op_endpoint") | 234 | ?om.get_field("op_endpoint") |
234 | :get_endpoint().uri; | 235 | :get_endpoint().uri; |
235 | assoc_t assoc = retrieve_assoc( | 236 | assoc_t assoc = retrieve_assoc( |
236 | OP,om.get_field("assoc_handle")); | 237 | OP,om.get_field("assoc_handle")); |
237 | if(om.get_field("sig")!=util::base64_signature(assoc,om)) | 238 | if(om.get_field("sig")!=util::base64_signature(assoc,om)) |
diff --git a/lib/discovery.cc b/lib/discovery.cc index bd1f917..b4ed3b6 100644 --- a/lib/discovery.cc +++ b/lib/discovery.cc | |||
@@ -270,32 +270,33 @@ namespace opkele { | |||
270 | if(td.clean_and_repair()<=0) | 270 | if(td.clean_and_repair()<=0) |
271 | throw exception_tidy(OPKELE_CP_ "tidy failed to clean and repair"); | 271 | throw exception_tidy(OPKELE_CP_ "tidy failed to clean and repair"); |
272 | util::tidy_buf_t tide; | 272 | util::tidy_buf_t tide; |
273 | if(td.save_buffer(tide)<=0) | 273 | if(td.save_buffer(tide)<=0) |
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) { |
298 | XRD_t& x = id.xrd; | 299 | XRD_t& x = id.xrd; |
299 | if(!html_openid2.uris.empty()) { | 300 | if(!html_openid2.uris.empty()) { |
300 | html_openid2.types.insert(STURI_OPENID20); | 301 | html_openid2.types.insert(STURI_OPENID20); |
301 | x.services.add(-1,html_openid2); | 302 | x.services.add(-1,html_openid2); |
@@ -440,51 +441,66 @@ namespace opkele { | |||
440 | } | 441 | } |
441 | }else | 442 | }else |
442 | skipping = 1; | 443 | skipping = 1; |
443 | }else if(xmode&xmode_html) { | 444 | }else if(xmode&xmode_html) { |
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")) { |
487 | bool heq = false; | 503 | bool heq = false; |
488 | string l; | 504 | string l; |
489 | for(;*a;a+=2) { | 505 | for(;*a;a+=2) { |
490 | if(!( strcasecmp(a[0],"http-equiv") | 506 | if(!( strcasecmp(a[0],"http-equiv") |
@@ -556,32 +572,39 @@ namespace opkele { | |||
556 | }else{ | 572 | }else{ |
557 | if(svc.local_ids.empty()) { | 573 | if(svc.local_ids.empty()) { |
558 | ep.local_id = ep.claimed_id; | 574 | ep.local_id = ep.claimed_id; |
559 | *(oi++) = ep; | 575 | *(oi++) = ep; |
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(unsigned 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) |
584 | throw; | 607 | throw; |
585 | } | 608 | } |
586 | 609 | ||
587 | } | 610 | } |
diff --git a/lib/expat.cc b/lib/expat.cc index c4dab7e..fb58a9a 100644 --- a/lib/expat.cc +++ b/lib/expat.cc | |||
@@ -79,19 +79,28 @@ namespace opkele { | |||
79 | assert(_x); | 79 | assert(_x); |
80 | XML_SetDefaultHandlerExpand(_x,_default_handler); | 80 | XML_SetDefaultHandlerExpand(_x,_default_handler); |
81 | } | 81 | } |
82 | 82 | ||
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 | } |
@@ -1,19 +1,20 @@ | |||
1 | #include <uuid/uuid.h> | 1 | #include <uuid/uuid.h> |
2 | #include <iostream> | 2 | #include <iostream> |
3 | #include <cassert> | 3 | #include <cassert> |
4 | #include <cstdlib> | ||
4 | #include <stdexcept> | 5 | #include <stdexcept> |
5 | #include <string> | 6 | #include <string> |
6 | #include <set> | 7 | #include <set> |
7 | #include <iterator> | 8 | #include <iterator> |
8 | using namespace std; | 9 | using namespace std; |
9 | #include <kingate/exception.h> | 10 | #include <kingate/exception.h> |
10 | #include <kingate/plaincgi.h> | 11 | #include <kingate/plaincgi.h> |
11 | #include <kingate/cgi_gateway.h> | 12 | #include <kingate/cgi_gateway.h> |
12 | #include <opkele/exception.h> | 13 | #include <opkele/exception.h> |
13 | #include <opkele/types.h> | 14 | #include <opkele/types.h> |
14 | #include <opkele/util.h> | 15 | #include <opkele/util.h> |
15 | #include <opkele/uris.h> | 16 | #include <opkele/uris.h> |
16 | #include <opkele/discovery.h> | 17 | #include <opkele/discovery.h> |
17 | #include <opkele/association.h> | 18 | #include <opkele/association.h> |
18 | #include <opkele/sreg.h> | 19 | #include <opkele/sreg.h> |
19 | using namespace opkele; | 20 | using namespace opkele; |