summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--.gitignore33
-rw-r--r--COPYING2
-rw-r--r--Makefile.am3
-rw-r--r--NEWS.xml6
-rwxr-xr-xautogen.sh2
-rw-r--r--autoregen.sh2
-rw-r--r--configure.ac4
-rw-r--r--include/opkele/expat.h3
-rw-r--r--lib/basic_rp.cc3
-rw-r--r--lib/discovery.cc31
-rw-r--r--lib/expat.cc9
-rw-r--r--test/RP.cc1
12 files changed, 71 insertions, 28 deletions
diff --git a/.gitignore b/.gitignore
index 87771db..16be7d8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,21 +1,16 @@
1configure 1/configure
2Makefile.in 2Makefile.in
3Doxyfile 3/Doxyfile
4config.log 4/config.log
5depcomp 5/config.h
6config.guess 6/INSTALL
7config.h 7/NEWS
8config.sub
9ltmain.sh
10INSTALL
11NEWS
12Makefile 8Makefile
13config.status 9/config.status
14stamp-h1 10/stamp-h1
15config.h.in 11/config.h.in
16libtool 12/autom4te.cache
17autom4te.cache 13/libopkele.pc
18libopkele.pc 14/aclocal.m4
19missing 15/aclocal.d
20aclocal.m4 16/aux.d
21install-sh
diff --git a/COPYING b/COPYING
index 46d3f30..b9cc74c 100644
--- a/COPYING
+++ b/COPYING
@@ -1,19 +1,19 @@
1Copyright (c) 2005-2008 Klever Group (http://www.klever.net/) 1Copyright (c) 2005-2009 Klever Group (http://www.klever.net/)
2 2
3Permission is hereby granted, free of charge, to any person obtaining a copy of 3Permission is hereby granted, free of charge, to any person obtaining a copy of
4this software and associated documentation files (the "Software"), to deal in 4this software and associated documentation files (the "Software"), to deal in
5the Software without restriction, including without limitation the rights to 5the Software without restriction, including without limitation the rights to
6use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 6use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7of the Software, and to permit persons to whom the Software is furnished to do 7of the Software, and to permit persons to whom the Software is furnished to do
8so, subject to the following conditions: 8so, subject to the following conditions:
9 9
10The above copyright notice and this permission notice shall be included in all 10The above copyright notice and this permission notice shall be included in all
11copies or substantial portions of the Software. 11copies or substantial portions of the Software.
12 12
13THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 13THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 15FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 17LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 18OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19SOFTWARE. 19SOFTWARE.
diff --git a/Makefile.am b/Makefile.am
index 3227bdb..7726dad 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,28 +1,29 @@
1
2SUBDIRS=include lib test 1SUBDIRS=include lib test
3EXTRA_DIST= NEWS NEWS.xml NEWS.xsl 2EXTRA_DIST= NEWS NEWS.xml NEWS.xsl
4 3
4ACLOCAL_AMFLAGS=-I aclocal.d
5
5pkgconfigdir=${libdir}/pkgconfig 6pkgconfigdir=${libdir}/pkgconfig
6pkgconfig_DATA=libopkele.pc 7pkgconfig_DATA=libopkele.pc
7 8
8all-local: NEWS 9all-local: NEWS
9if HAVE_DOXYGEN 10if HAVE_DOXYGEN
10clean-local: 11clean-local:
11 rm -rf doxydox 12 rm -rf doxydox
12endif 13endif
13 14
14NEWS: NEWS.xsl NEWS.xml 15NEWS: NEWS.xsl NEWS.xml
15 ${XSLTPROC} -o $@ NEWS.xsl NEWS.xml 16 ${XSLTPROC} -o $@ NEWS.xsl NEWS.xml
16 17
17if HAVE_DOXYGEN 18if HAVE_DOXYGEN
18dox: Doxyfile 19dox: Doxyfile
19 ${DOXYGEN} 20 ${DOXYGEN}
20endif 21endif
21 22
22ISSUEFILES = $$(find ${top_srcdir} -type f '(' \ 23ISSUEFILES = $$(find ${top_srcdir} -type f '(' \
23 -name '*.cc' -or -name '*.h' \ 24 -name '*.cc' -or -name '*.h' \
24 ')' ) \ 25 ')' ) \
25 ${top_srcdir}/configure.ac 26 ${top_srcdir}/configure.ac
26issues: todo fixme xxx 27issues: todo fixme xxx
27todo fixme xxx: 28todo fixme xxx:
28 @grep --color=auto -in '$@:' ${ISSUEFILES} || true 29 @grep --color=auto -in '$@:' ${ISSUEFILES} || true
diff --git a/NEWS.xml b/NEWS.xml
index 160b197..0206018 100644
--- a/NEWS.xml
+++ b/NEWS.xml
@@ -1,26 +1,32 @@
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>
19 <ni>Require expat xml stream parser library</ni> 25 <ni>Require expat xml stream parser library</ni>
20 <ni>Require htmltidy library</ni> 26 <ni>Require htmltidy library</ni>
21 <ni>Require tr1/memory (shared_ptr) support - either modern gcc or boost 27 <ni>Require tr1/memory (shared_ptr) support - either modern gcc or boost
22 library</ni> 28 library</ni>
23 </version> 29 </version>
24 <version version="0.3.2" date="November 22nd, 2007"> 30 <version version="0.3.2" date="November 22nd, 2007">
25 <ni>code cleanup for stricter compiler</ni> 31 <ni>code cleanup for stricter compiler</ni>
26 </version> 32 </version>
diff --git a/autogen.sh b/autogen.sh
index bf32a35..578206d 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -1,11 +1,11 @@
1#!/bin/sh 1#!/bin/sh
2tool_libtoolize="$(type -P glibtoolize || type -P libtoolize)" 2tool_libtoolize="$(type -P glibtoolize || type -P libtoolize)"
3if test -z "$tool_libtoolize" ; then 3if test -z "$tool_libtoolize" ; then
4 echo "Failed to find libtoolize." ; exit 1; 4 echo "Failed to find libtoolize." ; exit 1;
5fi 5fi
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
2eval 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,27 +1,29 @@
1AC_INIT([libopkele], [2.0.1], [libopkele-bugs@klever.net]) 1AC_INIT([libopkele], [2.0.2], [libopkele-bugs@klever.net])
2AC_CONFIG_SRCDIR([include/opkele/opkele-config.h]) 2AC_CONFIG_SRCDIR([include/opkele/opkele-config.h])
3AC_CONFIG_HEADERS([config.h include/opkele/acconfig.h]) 3AC_CONFIG_HEADERS([config.h include/opkele/acconfig.h])
4AC_CONFIG_MACRO_DIR([aclocal.d])
5AC_CONFIG_AUX_DIR([aux.d])
4AM_INIT_AUTOMAKE([dist-bzip2]) 6AM_INIT_AUTOMAKE([dist-bzip2])
5 7
6AC_PROG_INSTALL 8AC_PROG_INSTALL
7AC_PROG_CXX 9AC_PROG_CXX
8AC_PROG_CC 10AC_PROG_CC
9AC_PROG_LIBTOOL 11AC_PROG_LIBTOOL
10PKG_PROG_PKG_CONFIG 12PKG_PROG_PKG_CONFIG
11 13
12AC_HEADER_STDC 14AC_HEADER_STDC
13AC_CHECK_FUNCS([timegm]) 15AC_CHECK_FUNCS([timegm])
14 16
15AC_PATH_PROG([XSLTPROC],[xsltproc],[true]) 17AC_PATH_PROG([XSLTPROC],[xsltproc],[true])
16 18
17AC_MSG_CHECKING([for source tree version]) 19AC_MSG_CHECKING([for source tree version])
18if headrev=$(cd $srcdir && git rev-parse --verify HEAD 2>/dev/null) ; then 20if 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)"
20 test "$PACKAGE_SRC_VERSION" = "$PACKAGE_VERSION" \ 22 test "$PACKAGE_SRC_VERSION" = "$PACKAGE_VERSION" \
21 -o "${PACKAGE_SRC_VERSION#${PACKAGE_VERSION}-}" != "$PACKAGE_SRC_VERSION" || PACKAGE_SRC_VERSION="${PACKAGE_VERSION}:${PACKAGE_SRC_VERSION}" 23 -o "${PACKAGE_SRC_VERSION#${PACKAGE_VERSION}-}" != "$PACKAGE_SRC_VERSION" || PACKAGE_SRC_VERSION="${PACKAGE_VERSION}:${PACKAGE_SRC_VERSION}"
22 ( cd $srcdir && git diff-index $headrev | read dirt ) && PACKAGE_SRC_VERSION="${PACKAGE_SRC_VERSION}-dirty" 24 ( cd $srcdir && git diff-index $headrev | read dirt ) && PACKAGE_SRC_VERSION="${PACKAGE_SRC_VERSION}-dirty"
23else 25else
24 PACKAGE_SRC_VERSION="$PACKAGE_VERSION" 26 PACKAGE_SRC_VERSION="$PACKAGE_VERSION"
25fi 27fi
26AC_MSG_RESULT([$PACKAGE_SRC_VERSION]) 28AC_MSG_RESULT([$PACKAGE_SRC_VERSION])
27AC_SUBST([PACKAGE_SRC_VERSION]) 29AC_SUBST([PACKAGE_SRC_VERSION])
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
@@ -5,48 +5,51 @@
5#include <expat.h> 5#include <expat.h>
6 6
7namespace opkele { 7namespace opkele {
8 8
9 namespace util { 9 namespace util {
10 10
11 class expat_t { 11 class expat_t {
12 public: 12 public:
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();
45 48
46 virtual void default_handler(const XML_Char * /* s */,int /* l */) { } 49 virtual void default_handler(const XML_Char * /* s */,int /* l */) { }
47 void set_default_handler(); 50 void set_default_handler();
48 void set_default_handler_expand(); 51 void set_default_handler_expand();
49 52
50 virtual void start_namespace_decl(const XML_Char * /* p */,const XML_Char * /* u */) { } 53 virtual void start_namespace_decl(const XML_Char * /* p */,const XML_Char * /* u */) { }
51 virtual void end_namespace_decl(const XML_Char * /* p */) { } 54 virtual void end_namespace_decl(const XML_Char * /* p */) { }
52 void set_namespace_decl_handler(); 55 void set_namespace_decl_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
@@ -197,49 +197,50 @@ namespace opkele {
197 while(q<l) { 197 while(q<l) {
198 string::size_type eq = u.find('=',q); 198 string::size_type eq = u.find('=',q);
199 string::size_type am = u.find('&',q); 199 string::size_type am = u.find('&',q);
200 if(am==string::npos) { 200 if(am==string::npos) {
201 if(eq==string::npos) { 201 if(eq==string::npos) {
202 p[""] = u.substr(q); 202 p[""] = u.substr(q);
203 }else{ 203 }else{
204 p[u.substr(q,eq-q)] = u.substr(eq+1); 204 p[u.substr(q,eq-q)] = u.substr(eq+1);
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))
238 throw id_res_mismatch(OPKELE_CP_ "signature mismatch"); 239 throw id_res_mismatch(OPKELE_CP_ "signature mismatch");
239 }catch(dumb_RP& drp) { 240 }catch(dumb_RP& drp) {
240 go_dumb=true; 241 go_dumb=true;
241 }catch(failed_lookup& e) { 242 }catch(failed_lookup& e) {
242 go_dumb=true; 243 go_dumb=true;
243 } OPKELE_RETHROW 244 } OPKELE_RETHROW
244 if(go_dumb) { 245 if(go_dumb) {
245 try { 246 try {
diff --git a/lib/discovery.cc b/lib/discovery.cc
index bd1f917..b4ed3b6 100644
--- a/lib/discovery.cc
+++ b/lib/discovery.cc
@@ -262,48 +262,49 @@ namespace opkele {
262#endif /* NDEBUG */ 262#endif /* NDEBUG */
263 td.opt_set(TidyForceOutput,true); 263 td.opt_set(TidyForceOutput,true);
264 td.opt_set(TidyXhtmlOut,true); 264 td.opt_set(TidyXhtmlOut,true);
265 td.opt_set(TidyDoctypeMode,TidyDoctypeOmit); 265 td.opt_set(TidyDoctypeMode,TidyDoctypeOmit);
266 td.opt_set(TidyMark,false); 266 td.opt_set(TidyMark,false);
267 td.opt_set(TidyNumEntities,true); 267 td.opt_set(TidyNumEntities,true);
268 if(td.parse_string(save_html)<=0) 268 if(td.parse_string(save_html)<=0)
269 throw exception_tidy(OPKELE_CP_ "tidy failed to parse document"); 269 throw exception_tidy(OPKELE_CP_ "tidy failed to parse document");
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);
302 queue_endpoints(oi,id,&op_service_types[st_index_2]); 303 queue_endpoints(oi,id,&op_service_types[st_index_2]);
303 } 304 }
304 if(!html_openid1.uris.empty()) { 305 if(!html_openid1.uris.empty()) {
305 html_openid1.types.insert(STURI_OPENID11); 306 html_openid1.types.insert(STURI_OPENID11);
306 x.services.add(-1,html_openid1); 307 x.services.add(-1,html_openid1);
307 queue_endpoints(oi,id,&op_service_types[st_index_1]); 308 queue_endpoints(oi,id,&op_service_types[st_index_1]);
308 } 309 }
309 } 310 }
@@ -432,67 +433,82 @@ namespace opkele {
432 || is_qelement(n,NSURI_OPENID10 "\tDelegate") ) { 433 || is_qelement(n,NSURI_OPENID10 "\tDelegate") ) {
433 assert(xrd); assert(xrd_service); 434 assert(xrd); assert(xrd_service);
434 cdata = &(xrd_service->local_ids.add(element_priority(a),string())); 435 cdata = &(xrd_service->local_ids.add(element_priority(a),string()));
435 }else if(is_qelement(n,NSURI_XRD "\tProviderID")) { 436 }else if(is_qelement(n,NSURI_XRD "\tProviderID")) {
436 assert(xrd); assert(xrd_service); 437 assert(xrd); assert(xrd_service);
437 cdata = &(xrd_service->provider_id); 438 cdata = &(xrd_service->provider_id);
438 }else{ 439 }else{
439 skipping = 1; 440 skipping = 1;
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) {
458 assert(cdata==&cdata_buf);
457 xrd_service->types.insert(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)) {
463 skipping = -1;
464 }else{
460 assert(!pt_stack.empty()); 465 assert(!pt_stack.empty());
461 assert(pt_stack.back()==(NSURI_XRD "\tService")); 466 assert(pt_stack.back()==(NSURI_XRD "\tService"));
462 pt_stack.pop_back(); 467 pt_stack.pop_back();
463 xrd_service = 0; 468 xrd_service = 0;
469 }
464 }else if(is_qelement(n,NSURI_XRD "\tStatus")) { 470 }else if(is_qelement(n,NSURI_XRD "\tStatus")) {
465 assert(xrd); 471 if(!xrd) {
472 skipping=-1;
473 }else{
466 if(is_qelement(pt_stack.back().c_str(),n)) { 474 if(is_qelement(pt_stack.back().c_str(),n)) {
467 assert(cdata==&status_string); 475 assert(cdata==&status_string);
468 pt_stack.pop_back(); 476 pt_stack.pop_back();
469 if(status_code!=100) 477 if(status_code!=100)
470 skipping = -1; 478 skipping = -1;
471 } 479 }
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) {
483 skipping=-1;
484 }else{
474 xrd->expires = util::w3c_to_time(cdata_buf); 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")
491 || strcasecmp(a[1],XRDS_HEADER) )) 507 || strcasecmp(a[1],XRDS_HEADER) ))
492 heq = true; 508 heq = true;
493 else if(!strcasecmp(a[0],"content")) 509 else if(!strcasecmp(a[0],"content"))
494 l.assign(a[1]); 510 l.assign(a[1]);
495 } 511 }
496 if(heq) 512 if(heq)
497 xrds_location = l; 513 xrds_location = l;
498 }else if(is_element(n,"link")) { 514 }else if(is_element(n,"link")) {
@@ -548,40 +564,47 @@ namespace opkele {
548 if(id.xri_identity) { 564 if(id.xri_identity) {
549 if(iu->second.append=="qxri") { 565 if(iu->second.append=="qxri") {
550 ep.uri += id.normalized_id; 566 ep.uri += id.normalized_id;
551 } /* TODO: else handle other append attribute values */ 567 } /* TODO: else handle other append attribute values */
552 } 568 }
553 if(st->forceid) { 569 if(st->forceid) {
554 ep.local_id = ep.claimed_id = st->forceid; 570 ep.local_id = ep.claimed_id = st->forceid;
555 *(oi++) = ep; 571 *(oi++) = ep;
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
@@ -71,27 +71,36 @@ namespace opkele {
71 ((expat_t*)ud)->default_handler(s,l); 71 ((expat_t*)ud)->default_handler(s,l);
72 } 72 }
73 73
74 void expat_t::set_default_handler() { 74 void expat_t::set_default_handler() {
75 assert(_x); 75 assert(_x);
76 XML_SetDefaultHandler(_x,_default_handler); 76 XML_SetDefaultHandler(_x,_default_handler);
77 } 77 }
78 void expat_t::set_default_handler_expand() { 78 void expat_t::set_default_handler_expand() {
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}
diff --git a/test/RP.cc b/test/RP.cc
index 35ee71d..f015723 100644
--- a/test/RP.cc
+++ b/test/RP.cc
@@ -1,27 +1,28 @@
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>
8using namespace std; 9using 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>
19using namespace opkele; 20using namespace opkele;
20#include <opkele/prequeue_rp.h> 21#include <opkele/prequeue_rp.h>
21#include <opkele/debug.h> 22#include <opkele/debug.h>
22 23
23#include "sqlite.h" 24#include "sqlite.h"
24#include "kingate_openid_message.h" 25#include "kingate_openid_message.h"
25 26
26#undef DUMB_RP 27#undef DUMB_RP
27 28