summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore 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.cc53
-rw-r--r--lib/expat.cc9
-rw-r--r--test/RP.cc1
12 files changed, 82 insertions, 39 deletions
diff --git a/.gitignore b/.gitignore
index 87771db..16be7d8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,21 +1,16 @@
-configure
+/configure
Makefile.in
-Doxyfile
-config.log
-depcomp
-config.guess
-config.h
-config.sub
-ltmain.sh
-INSTALL
-NEWS
+/Doxyfile
+/config.log
+/config.h
+/INSTALL
+/NEWS
Makefile
-config.status
-stamp-h1
-config.h.in
-libtool
-autom4te.cache
-libopkele.pc
-missing
-aclocal.m4
-install-sh
+/config.status
+/stamp-h1
+/config.h.in
+/autom4te.cache
+/libopkele.pc
+/aclocal.m4
+/aclocal.d
+/aux.d
diff --git a/COPYING b/COPYING
index 46d3f30..b9cc74c 100644
--- a/COPYING
+++ b/COPYING
@@ -1,17 +1,17 @@
-Copyright (c) 2005-2008 Klever Group (http://www.klever.net/)
+Copyright (c) 2005-2009 Klever Group (http://www.klever.net/)
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
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 @@
-
SUBDIRS=include lib test
EXTRA_DIST= NEWS NEWS.xml NEWS.xsl
+ACLOCAL_AMFLAGS=-I aclocal.d
+
pkgconfigdir=${libdir}/pkgconfig
pkgconfig_DATA=libopkele.pc
all-local: NEWS
if HAVE_DOXYGEN
clean-local:
rm -rf doxydox
endif
NEWS: NEWS.xsl NEWS.xml
${XSLTPROC} -o $@ NEWS.xsl NEWS.xml
if HAVE_DOXYGEN
dox: Doxyfile
${DOXYGEN}
endif
diff --git a/NEWS.xml b/NEWS.xml
index 160b197..0206018 100644
--- a/NEWS.xml
+++ b/NEWS.xml
@@ -1,18 +1,24 @@
<?xml version="1.0" encoding="us-ascii"?>
<news>
+ <version version="2.0.2" date="April 11th, 2009">
+ <ni>Handling of unknown encodings during discovery</ni>
+ <ni>Discovery robustness improvements</ni>
+ <ni>Workaround for OPs (e.g. livejournal.com) breaking specs</ni>
+ <ni>Build fixes and improvements</ni>
+ </version>
<version version="2.0.1" date="November 22nd, 2008">
<ni>Compile-time fixes and improvements</ni>
<ni>Portability improvements for FreeBSD</ni>
<ni>Really suppress debugging message from htmltidy when --disable-debug is in
effect</ni>
<ni>minor bugfixes</ni>
<ni>thread-safety improvements</ni>
</version>
<version version="2.0" date="June 26th, 2008">
<ni>OpenID 2.0 support</ni>
<ni>Major rewrite of the whole thing</ni>
<ni>Support for XRDS (YADIS and XRI/inames) discovery</ni>
<ni>Sheerly improved html-based discovery (only code using new, 2.0-enabled
classes benefits from it)</ni>
<ni>Deprecation of the old api</ni>
<ni>Added sample RP and OP implementations</ni>
diff --git a/autogen.sh b/autogen.sh
index bf32a35..578206d 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -1,11 +1,11 @@
#!/bin/sh
tool_libtoolize="$(type -P glibtoolize || type -P libtoolize)"
if test -z "$tool_libtoolize" ; then
echo "Failed to find libtoolize." ; exit 1;
fi
"$tool_libtoolize" -f \
-&& aclocal \
+&& aclocal -I aclocal.d \
&& autoheader \
&& automake -a \
&& autoconf \
&& ./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 @@
+#!/bin/bash
+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 @@
-AC_INIT([libopkele], [2.0.1], [libopkele-bugs@klever.net])
+AC_INIT([libopkele], [2.0.2], [libopkele-bugs@klever.net])
AC_CONFIG_SRCDIR([include/opkele/opkele-config.h])
AC_CONFIG_HEADERS([config.h include/opkele/acconfig.h])
+AC_CONFIG_MACRO_DIR([aclocal.d])
+AC_CONFIG_AUX_DIR([aux.d])
AM_INIT_AUTOMAKE([dist-bzip2])
AC_PROG_INSTALL
AC_PROG_CXX
AC_PROG_CC
AC_PROG_LIBTOOL
PKG_PROG_PKG_CONFIG
AC_HEADER_STDC
AC_CHECK_FUNCS([timegm])
AC_PATH_PROG([XSLTPROC],[xsltproc],[true])
AC_MSG_CHECKING([for source tree version])
if headrev=$(cd $srcdir && git rev-parse --verify HEAD 2>/dev/null) ; then
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 {
XML_Parser _x;
expat_t() : _x(0) { }
expat_t(XML_Parser x) : _x(x) { }
virtual ~expat_t() throw();
expat_t& operator=(XML_Parser x);
operator const XML_Parser(void) const { return _x; }
operator XML_Parser(void) { return _x; }
inline bool parse(const char *s,int len,bool final=false) {
assert(_x);
return XML_Parse(_x,s,len,final);
}
+ virtual int unknown_encoding(const XML_Char * /* n */,XML_Encoding * /* i */) { return XML_STATUS_ERROR; }
+ void set_unknown_encoding_handler();
+
virtual void start_element(const XML_Char * /* n */,const XML_Char ** /* a */) { }
virtual void end_element(const XML_Char * /* n */) { }
void set_element_handler();
virtual void character_data(const XML_Char * /* s */,int /* l */) { }
void set_character_data_handler();
virtual void processing_instruction(const XML_Char * /* t */,const XML_Char * /* d */) { }
void set_processing_instruction_handler();
virtual void comment(const XML_Char * /* d */) { }
void set_comment_handler();
virtual void start_cdata_section() { }
virtual void end_cdata_section() { }
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 {
}
break;
}else{
if(eq==string::npos || eq>am) {
p[""] = u.substr(q,eq-q);
}else{
p[u.substr(q,eq-q)] = u.substr(eq+1,am-eq-1);
}
q = ++am;
}
}
}
void basic_RP::id_res(const basic_openid_message& om,extension_t *ext) {
reset_vars();
bool o2 = om.has_field("ns")
- && om.get_field("ns")==OIURI_OPENID20;
+ && om.get_field("ns")==OIURI_OPENID20
+ && om.has_field("op_endpoint") && !om.get_field("op_endpoint").empty();
if( (!o2) && om.has_field("user_setup_url"))
throw id_res_setup(OPKELE_CP_ "assertion failed, setup url provided",
om.get_field("user_setup_url"));
string m = om.get_field("mode");
if(o2 && m=="setup_needed")
throw id_res_setup(OPKELE_CP_ "setup needed, no setup url provided");
if(m=="cancel")
throw id_res_cancel(OPKELE_CP_ "authentication cancelled");
bool go_dumb=false;
try {
string OP = o2
?om.get_field("op_endpoint")
:get_endpoint().uri;
assoc_t assoc = retrieve_assoc(
OP,om.get_field("assoc_handle"));
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 {
if(td.clean_and_repair()<=0)
throw exception_tidy(OPKELE_CP_ "tidy failed to clean and repair");
util::tidy_buf_t tide;
if(td.save_buffer(tide)<=0)
throw exception_tidy(OPKELE_CP_ "tidy failed to save buffer");
prepare_to_parse();
parse(tide.c_str(),tide.size(),true);
}catch(exception_tidy& et) { }
}
save_html.clear();
}
void prepare_to_parse() {
(*(expat_t*)this) = parser_create_ns();
set_user_data(); set_element_handler();
set_character_data_handler();
+ set_unknown_encoding_handler();
if(xmode&xmode_html) {
html_openid1.clear(); html_openid2.clear();
parser_choked = false;
}
cdata = 0; xrd_service = 0; skipping = 0;
pt_stack.clear();
status_code = 100; status_string.clear();
}
void html2xrd(endpoint_discovery_iterator& oi,idiscovery_t& id) {
XRD_t& x = id.xrd;
if(!html_openid2.uris.empty()) {
html_openid2.types.insert(STURI_OPENID20);
x.services.add(-1,html_openid2);
@@ -440,51 +441,66 @@ namespace opkele {
}
}else
skipping = 1;
}else if(xmode&xmode_html) {
html_start_element(n,a);
}else{
skipping = 1;
}
}
}
void end_element(const XML_Char *n) {
if(skipping<0) return;
if(skipping) {
--skipping; return;
}
if(is_qelement(n,NSURI_XRD "\tType")) {
- assert(xrd); assert(xrd_service); assert(cdata==&cdata_buf);
- xrd_service->types.insert(cdata_buf);
+ if(xrd && xrd_service) {
+ assert(cdata==&cdata_buf);
+ xrd_service->types.insert(cdata_buf);
+ }
}else if(is_qelement(n,NSURI_XRD "\tService")) {
- assert(xrd); assert(xrd_service);
- assert(!pt_stack.empty());
- assert(pt_stack.back()==(NSURI_XRD "\tService"));
- pt_stack.pop_back();
- xrd_service = 0;
- }else if(is_qelement(n,NSURI_XRD "\tStatus")) {
- assert(xrd);
- if(is_qelement(pt_stack.back().c_str(),n)) {
- assert(cdata==&status_string);
+ if(!(xrd && xrd_service)) {
+ skipping = -1;
+ }else{
+ assert(!pt_stack.empty());
+ assert(pt_stack.back()==(NSURI_XRD "\tService"));
pt_stack.pop_back();
- if(status_code!=100)
- skipping = -1;
+ xrd_service = 0;
+ }
+ }else if(is_qelement(n,NSURI_XRD "\tStatus")) {
+ if(!xrd) {
+ skipping=-1;
+ }else{
+ if(is_qelement(pt_stack.back().c_str(),n)) {
+ assert(cdata==&status_string);
+ pt_stack.pop_back();
+ if(status_code!=100)
+ skipping = -1;
+ }
}
}else if(is_qelement(n,NSURI_XRD "\tExpires")) {
- assert(xrd);
- xrd->expires = util::w3c_to_time(cdata_buf);
+ if(!xrd) {
+ skipping=-1;
+ }else{
+ xrd->expires = util::w3c_to_time(cdata_buf);
+ }
+ }else if(is_qelement(n,NSURI_XRD "\tXRD")) {
+ assert(!pt_stack.empty());
+ assert(pt_stack.back()==(NSURI_XRD "\tXRD"));
+ pt_stack.pop_back();
}else if((xmode&xmode_html) && is_element(n,"head")) {
skipping = -1;
}
cdata = 0;
}
void character_data(const XML_Char *s,int l) {
if(skipping) return;
if(cdata) cdata->append(s,l);
}
void html_start_element(const XML_Char *n,const XML_Char **a) {
if(is_element(n,"meta")) {
bool heq = false;
string l;
for(;*a;a+=2) {
if(!( strcasecmp(a[0],"http-equiv")
@@ -556,32 +572,39 @@ namespace opkele {
}else{
if(svc.local_ids.empty()) {
ep.local_id = ep.claimed_id;
*(oi++) = ep;
}else{
for(xrd::local_ids_t::const_iterator ilid=svc.local_ids.begin();
ilid!=svc.local_ids.end(); ++ilid) {
ep.local_id = ilid->second;
*(oi++) = ep;
}
}
}
}
}
}
+ int unknown_encoding(const XML_Char* /* n */,XML_Encoding *i) {
+ for(unsigned int ii=0;ii < sizeof(i->map)/sizeof(i->map[0]);++ii)
+ i->map[ii] = ii;
+ i->convert = 0; i->release = 0;
+ return XML_STATUS_OK;
+ }
+
};
string idiscover(endpoint_discovery_iterator oi,const string& identity) {
idigger_t idigger;
return idigger.discover(oi,identity);
}
void yadiscover(endpoint_discovery_iterator oi,const string& yurl,const char **types,bool redirs) try {
idigger_t idigger;
idigger.yadiscover(oi,yurl,types,redirs);
}catch(exception_curl& ec) {
if(redirs || ec._error!=CURLE_TOO_MANY_REDIRECTS)
throw;
}
}
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 {
assert(_x);
XML_SetDefaultHandlerExpand(_x,_default_handler);
}
static void _start_namespace_decl(void *ud,const XML_Char *p,const XML_Char *u) {
((expat_t*)ud)->start_namespace_decl(p,u);
}
static void _end_namespace_decl(void *ud,const XML_Char *p) {
((expat_t*)ud)->end_namespace_decl(p);
}
void expat_t::set_namespace_decl_handler() {
assert(_x);
XML_SetNamespaceDeclHandler(_x,_start_namespace_decl,_end_namespace_decl);
}
+ static int _unknown_encoding(void *ehd,const XML_Char *n,XML_Encoding *i) {
+ return ((expat_t*)ehd)->unknown_encoding(n,i);
+ }
+
+ void expat_t::set_unknown_encoding_handler() {
+ assert(_x);
+ XML_SetUnknownEncodingHandler(_x,_unknown_encoding,this);
+ }
+
}
}
diff --git a/test/RP.cc b/test/RP.cc
index 35ee71d..f015723 100644
--- a/test/RP.cc
+++ b/test/RP.cc
@@ -1,19 +1,20 @@
#include <uuid/uuid.h>
#include <iostream>
#include <cassert>
+#include <cstdlib>
#include <stdexcept>
#include <string>
#include <set>
#include <iterator>
using namespace std;
#include <kingate/exception.h>
#include <kingate/plaincgi.h>
#include <kingate/cgi_gateway.h>
#include <opkele/exception.h>
#include <opkele/types.h>
#include <opkele/util.h>
#include <opkele/uris.h>
#include <opkele/discovery.h>
#include <opkele/association.h>
#include <opkele/sreg.h>
using namespace opkele;