author | Michael Krelin <hacker@klever.net> | 2007-09-22 20:56:57 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-09-22 20:56:57 (UTC) |
commit | 5cb71518360f865cd4448a083b5d481e6f356a3e (patch) (unidiff) | |
tree | 4faeab2b1a1a14c589745be714be18471879e781 | |
parent | 5cfe3f2743c2b2eb2689090516a4e667fd8ca29a (diff) | |
download | libopkele-5cb71518360f865cd4448a083b5d481e6f356a3e.zip libopkele-5cb71518360f865cd4448a083b5d481e6f356a3e.tar.gz libopkele-5cb71518360f865cd4448a083b5d481e6f356a3e.tar.bz2 |
got rid of all pcre wrappers altogether
although all claims against pcre++ make absolutely no sense. But for now I'll
live with no wrappers at all. I may reconsider it when implementing more
sophisticated discovery mechanisms for upcoming extensions.
Signed-off-by: Michael Krelin <hacker@klever.net>
-rw-r--r-- | configure.ac | 47 | ||||
-rw-r--r-- | include/opkele/exception.h | 9 | ||||
-rw-r--r-- | lib/Makefile.am | 4 | ||||
-rw-r--r-- | lib/consumer.cc | 124 | ||||
-rw-r--r-- | libopkele.pc.in | 2 |
5 files changed, 80 insertions, 106 deletions
diff --git a/configure.ac b/configure.ac index 00c6bc4..53e22ba 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -40,76 +40,35 @@ AC_ARG_ENABLE([doxygen], | |||
40 | [ | 40 | [ |
41 | test "${enableval}" = "no" && WANT_DOXYGEN="no" | 41 | test "${enableval}" = "no" && WANT_DOXYGEN="no" |
42 | ] | 42 | ] |
43 | ) | 43 | ) |
44 | if test "${WANT_DOXYGEN}" = "yes" ; then | 44 | if test "${WANT_DOXYGEN}" = "yes" ; then |
45 | AC_WITH_DOXYGEN | 45 | AC_WITH_DOXYGEN |
46 | AC_WITH_DOT | 46 | AC_WITH_DOT |
47 | else | 47 | else |
48 | AM_CONDITIONAL([HAVE_DOXYGEN],[false]) | 48 | AM_CONDITIONAL([HAVE_DOXYGEN],[false]) |
49 | AM_CONDITIONAL([HAVE_DOT],[false]) | 49 | AM_CONDITIONAL([HAVE_DOT],[false]) |
50 | fi | 50 | fi |
51 | 51 | ||
52 | LIBCURL_CHECK_CONFIG(,,,[ | 52 | LIBCURL_CHECK_CONFIG(,,,[ |
53 | AC_MSG_ERROR([no required libcurl library. get one from http://curl.haxx.se/]) | 53 | AC_MSG_ERROR([no required libcurl library. get one from http://curl.haxx.se/]) |
54 | ]) | 54 | ]) |
55 | 55 | ||
56 | want_pcre_impl="" | 56 | PKG_CHECK_MODULES([PCRE],[libpcre],,[ |
57 | AC_ARG_WITH([pcre-bindings], | 57 | AC_MSG_ERROR([no libpcre found, go get it at http://www.pcre.org/]) |
58 | AC_HELP_STRING([--with-pcre-bindings=(pcrepp|none|libpcrecpp)],[Specify which pcre c++ bindings to use. 'pcrepp' stands for quite sensible library, found at http://www.daemon.de/PCRE/, 'libcrecpp' makes use of crappy bindings by google and 'none' disables internal implementation of OP discovery]), | 58 | ]) |
59 | [ | ||
60 | case "$withval" in | ||
61 | pcrepp) want_pcre_impl="pcrepp" ;; | ||
62 | libpcrecpp) want_pcre_impl="libpcrecpp" ;; | ||
63 | none) want_pcre_impl="none";; | ||
64 | *) AC_MSG_ERROR([I'm not sure I understand what do you want for a pcre c++ bindings]) ;; | ||
65 | esac | ||
66 | ] | ||
67 | ) | ||
68 | |||
69 | found_pcre_impl="" | ||
70 | |||
71 | if test -z "$want_pcre_impl" -o "$want_pcre_impl" = "pcrepp" ; then | ||
72 | AC_WITH_PCRE([ | ||
73 | AC_WITH_PCREPP([ | ||
74 | found_pcre_impl=pcrepp | ||
75 | ]) | ||
76 | ],[ | ||
77 | AC_MSG_ERROR([no pcre library found. get one at http://www.pcre.org/]) | ||
78 | ] | ||
79 | ) | ||
80 | test "$want_pcre_impl,$found_pcre_impl" = "pcrepp," && AC_MSG_ERROR([no pcre++ library found. get one at http://www.daemon.de/PCRE]) | ||
81 | fi | ||
82 | |||
83 | if test "$found_pcre_impl,$want_pcre_impl" = "," -o "$want_pcre_impl" = "libpcrecpp" ; then | ||
84 | test -z "$want_pcre_impl" || AC_MSG_NOTICE([You want to use crappy libpcre c++ bindings]) | ||
85 | PKG_CHECK_MODULES([LIBPCRECPP],[libpcrecpp],[ | ||
86 | found_pcre_impl=libpcrecpp | ||
87 | CXXFLAGS="$CXXFLAGS $LIBPCRECPP_CFLAGS" | ||
88 | LIBS="$LIBS $LIBPCRECPP_LIBS" | ||
89 | ],[ | ||
90 | test -z "$want_pcre_impl" || AC_MSG_ERROR([no libpcre c++ bindings found. why would you want it if you don't have it installed?]) | ||
91 | ] | ||
92 | ) | ||
93 | fi | ||
94 | test "$want_pcre_impl,$found_pcre_impl" = "," && AC_MSG_ERROR([no pcre c++ bindings found, use --with-pcre-bindings=none to disable code that makes use of it]) | ||
95 | |||
96 | case "$found_pcre_impl" in | ||
97 | pcrepp) AC_DEFINE([USE_PCREPP],,[defined if pcre++ is to be used]) ;; | ||
98 | libpcrecpp) AC_DEFINE([USE_LIBPCRECPP],,[defined if crappy google bindings are to be used]) ;; | ||
99 | esac | ||
100 | 59 | ||
101 | curl_ssl_verify_host="true" | 60 | curl_ssl_verify_host="true" |
102 | AC_ARG_ENABLE([ssl-verify-host], | 61 | AC_ARG_ENABLE([ssl-verify-host], |
103 | AC_HELP_STRING([--disable-ssl-verify-host],[disable cURL cert/host relationships verification]), | 62 | AC_HELP_STRING([--disable-ssl-verify-host],[disable cURL cert/host relationships verification]), |
104 | [ test "${enableval}" = "no" && curl_ssl_verify_host="false" ] | 63 | [ test "${enableval}" = "no" && curl_ssl_verify_host="false" ] |
105 | ) | 64 | ) |
106 | ${curl_ssl_verify_host} || AC_DEFINE([DISABLE_CURL_SSL_VERIFYHOST],,[defined if cURL is not to verify cert/host]) | 65 | ${curl_ssl_verify_host} || AC_DEFINE([DISABLE_CURL_SSL_VERIFYHOST],,[defined if cURL is not to verify cert/host]) |
107 | 66 | ||
108 | curl_ssl_verify_peer="true" | 67 | curl_ssl_verify_peer="true" |
109 | AC_ARG_ENABLE([ssl-verify-peer], | 68 | AC_ARG_ENABLE([ssl-verify-peer], |
110 | AC_HELP_STRING([--disable-ssl-verify-peer],[disable cURL cert validity verification]), | 69 | AC_HELP_STRING([--disable-ssl-verify-peer],[disable cURL cert validity verification]), |
111 | [ test "${enableval}" = "no" && curl_ssl_verify_peer="false" ] | 70 | [ test "${enableval}" = "no" && curl_ssl_verify_peer="false" ] |
112 | ) | 71 | ) |
113 | ${curl_ssl_verify_peer} || AC_DEFINE([DISABLE_CURL_SSL_VERIFYPEER],,[defined if cURL is not to verify cert validity]) | 72 | ${curl_ssl_verify_peer} || AC_DEFINE([DISABLE_CURL_SSL_VERIFYPEER],,[defined if cURL is not to verify cert validity]) |
114 | 73 | ||
115 | postels_law=true | 74 | postels_law=true |
diff --git a/include/opkele/exception.h b/include/opkele/exception.h index 0150e6b..753a818 100644 --- a/include/opkele/exception.h +++ b/include/opkele/exception.h | |||
@@ -199,19 +199,28 @@ namespace opkele { | |||
199 | string _curl_string; | 199 | string _curl_string; |
200 | exception_curl(OPKELE_E_PARS); | 200 | exception_curl(OPKELE_E_PARS); |
201 | exception_curl(OPKELE_E_PARS,CURLcode e); | 201 | exception_curl(OPKELE_E_PARS,CURLcode e); |
202 | ~exception_curl() throw() { } | 202 | ~exception_curl() throw() { } |
203 | }; | 203 | }; |
204 | 204 | ||
205 | /** | 205 | /** |
206 | * not implemented (think pure virtual) member function executed, signfies | 206 | * not implemented (think pure virtual) member function executed, signfies |
207 | * programmer error | 207 | * programmer error |
208 | */ | 208 | */ |
209 | class not_implemented : public exception { | 209 | class not_implemented : public exception { |
210 | public: | 210 | public: |
211 | not_implemented(OPKELE_E_PARS) | 211 | not_implemented(OPKELE_E_PARS) |
212 | : exception(OPKELE_E_CONS) { } | 212 | : exception(OPKELE_E_CONS) { } |
213 | }; | 213 | }; |
214 | 214 | ||
215 | /** | ||
216 | * internal error, indicates internal libopkele problem | ||
217 | */ | ||
218 | class internal_error : public exception { | ||
219 | public: | ||
220 | internal_error(OPKELE_E_PARS) | ||
221 | : exception(OPKELE_E_CONS) { } | ||
222 | }; | ||
223 | |||
215 | } | 224 | } |
216 | 225 | ||
217 | #endif /* __OPKELE_EXCEPTION_H */ | 226 | #endif /* __OPKELE_EXCEPTION_H */ |
diff --git a/lib/Makefile.am b/lib/Makefile.am index a68faf6..b008a52 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am | |||
@@ -1,27 +1,27 @@ | |||
1 | lib_LTLIBRARIES = libopkele.la | 1 | lib_LTLIBRARIES = libopkele.la |
2 | 2 | ||
3 | INCLUDES = \ | 3 | INCLUDES = \ |
4 | -I${top_srcdir}/include/ \ | 4 | -I${top_srcdir}/include/ \ |
5 | ${KONFORKA_CFLAGS} \ | 5 | ${KONFORKA_CFLAGS} \ |
6 | ${OPENSSL_CFLAGS} \ | 6 | ${OPENSSL_CFLAGS} \ |
7 | ${LIBCURL_CPPFLAGS} \ | 7 | ${LIBCURL_CPPFLAGS} \ |
8 | ${PCREPP_CFLAGS} | 8 | ${PCRE_CFLAGS} |
9 | libopkele_la_LIBADD = \ | 9 | libopkele_la_LIBADD = \ |
10 | ${LIBCURL} \ | 10 | ${LIBCURL} \ |
11 | ${PCREPP_LIBS} \ | 11 | ${PCRE_LIBS} \ |
12 | ${OPENSSL_LIBS} \ | 12 | ${OPENSSL_LIBS} \ |
13 | ${KONFORKA_LIBS} | 13 | ${KONFORKA_LIBS} |
14 | 14 | ||
15 | libopkele_la_SOURCES = \ | 15 | libopkele_la_SOURCES = \ |
16 | params.cc \ | 16 | params.cc \ |
17 | util.cc \ | 17 | util.cc \ |
18 | server.cc \ | 18 | server.cc \ |
19 | secret.cc \ | 19 | secret.cc \ |
20 | data.cc \ | 20 | data.cc \ |
21 | consumer.cc \ | 21 | consumer.cc \ |
22 | exception.cc \ | 22 | exception.cc \ |
23 | extension.cc \ | 23 | extension.cc \ |
24 | sreg.cc \ | 24 | sreg.cc \ |
25 | extension_chain.cc | 25 | extension_chain.cc |
26 | libopkele_la_LDFLAGS = \ | 26 | libopkele_la_LDFLAGS = \ |
27 | -version-info 2:0:0 | 27 | -version-info 2:0:0 |
diff --git a/lib/consumer.cc b/lib/consumer.cc index ff5da91..df95b64 100644 --- a/lib/consumer.cc +++ b/lib/consumer.cc | |||
@@ -1,41 +1,79 @@ | |||
1 | #include <algorithm> | 1 | #include <algorithm> |
2 | #include <cassert> | 2 | #include <cassert> |
3 | #include <opkele/util.h> | 3 | #include <opkele/util.h> |
4 | #include <opkele/exception.h> | 4 | #include <opkele/exception.h> |
5 | #include <opkele/data.h> | 5 | #include <opkele/data.h> |
6 | #include <opkele/consumer.h> | 6 | #include <opkele/consumer.h> |
7 | #include <openssl/sha.h> | 7 | #include <openssl/sha.h> |
8 | #include <openssl/hmac.h> | 8 | #include <openssl/hmac.h> |
9 | #include <curl/curl.h> | 9 | #include <curl/curl.h> |
10 | 10 | ||
11 | #include <iostream> | 11 | #include <iostream> |
12 | 12 | ||
13 | #include "config.h" | 13 | #include "config.h" |
14 | 14 | ||
15 | #if defined(USE_LIBPCRECPP) | 15 | #include <pcre.h> |
16 | # include <pcrecpp.h> | ||
17 | #elif defined(USE_PCREPP) | ||
18 | # include <pcre++.h> | ||
19 | #else | ||
20 | /* internal implementation won't be built */ | ||
21 | #endif | ||
22 | 16 | ||
23 | namespace opkele { | 17 | namespace opkele { |
24 | using namespace std; | 18 | using namespace std; |
25 | 19 | ||
20 | class pcre_matches_t { | ||
21 | public: | ||
22 | int *_ov; | ||
23 | int _s; | ||
24 | |||
25 | pcre_matches_t() : _ov(0), _s(0) { } | ||
26 | pcre_matches_t(int s) : _ov(0), _s(s) { | ||
27 | if(_s&1) ++_s; | ||
28 | _s += _s>>1; | ||
29 | _ov = new int[_s]; | ||
30 | } | ||
31 | ~pcre_matches_t() throw() { if(_ov) delete[] _ov; } | ||
32 | |||
33 | int begin(int i) const { return _ov[i<<1]; } | ||
34 | int end(int i) const { return _ov[(i<<1)+1]; } | ||
35 | int length(int i) const { int t=i<<1; return _ov[t+1]-_ov[t]; } | ||
36 | }; | ||
37 | |||
38 | class pcre_t { | ||
39 | public: | ||
40 | pcre *_p; | ||
41 | |||
42 | pcre_t() : _p(0) { } | ||
43 | pcre_t(pcre *p) : _p(p) { } | ||
44 | pcre_t(const char *re,int opts) : _p(0) { | ||
45 | static const char *errptr; static int erroffset; | ||
46 | _p = pcre_compile(re,opts,&errptr,&erroffset,NULL); | ||
47 | if(!_p) | ||
48 | throw internal_error(OPKELE_CP_ string("Failed to compile regexp: ")+errptr); | ||
49 | } | ||
50 | ~pcre_t() throw() { if(_p) (*pcre_free)(_p); } | ||
51 | |||
52 | pcre_t& operator=(pcre *p) { if(_p) (*pcre_free)(_p); _p=p; return *this; } | ||
53 | |||
54 | operator const pcre*(void) const { return _p; } | ||
55 | operator pcre*(void) { return _p; } | ||
56 | |||
57 | int exec(const string& s,pcre_matches_t& m) { | ||
58 | if(!_p) | ||
59 | throw internal_error(OPKELE_CP_ "Trying to execute absent regexp"); | ||
60 | return pcre_exec(_p,NULL,s.c_str(),s.length(),0,0,m._ov,m._s); | ||
61 | } | ||
62 | }; | ||
63 | |||
26 | class curl_t { | 64 | class curl_t { |
27 | public: | 65 | public: |
28 | CURL *_c; | 66 | CURL *_c; |
29 | 67 | ||
30 | curl_t() : _c(0) { } | 68 | curl_t() : _c(0) { } |
31 | curl_t(CURL *c) : _c(c) { } | 69 | curl_t(CURL *c) : _c(c) { } |
32 | ~curl_t() throw() { if(_c) curl_easy_cleanup(_c); } | 70 | ~curl_t() throw() { if(_c) curl_easy_cleanup(_c); } |
33 | 71 | ||
34 | curl_t& operator=(CURL *c) { if(_c) curl_easy_cleanup(_c); _c=c; return *this; } | 72 | curl_t& operator=(CURL *c) { if(_c) curl_easy_cleanup(_c); _c=c; return *this; } |
35 | 73 | ||
36 | operator const CURL*(void) const { return _c; } | 74 | operator const CURL*(void) const { return _c; } |
37 | operator CURL*(void) { return _c; } | 75 | operator CURL*(void) { return _c; } |
38 | }; | 76 | }; |
39 | 77 | ||
40 | static CURLcode curl_misc_sets(CURL* c) { | 78 | static CURLcode curl_misc_sets(CURL* c) { |
41 | CURLcode r; | 79 | CURLcode r; |
@@ -255,111 +293,79 @@ namespace opkele { | |||
255 | if(r=curl_easy_perform(curl)) | 293 | if(r=curl_easy_perform(curl)) |
256 | throw exception_curl(OPKELE_CP_ "failed to curl_easy_perform()",r); | 294 | throw exception_curl(OPKELE_CP_ "failed to curl_easy_perform()",r); |
257 | params_t pp; pp.parse_keyvalues(response); | 295 | params_t pp; pp.parse_keyvalues(response); |
258 | if(pp.has_param("invalidate_handle")) | 296 | if(pp.has_param("invalidate_handle")) |
259 | invalidate_assoc(server,pp.get_param("invalidate_handle")); | 297 | invalidate_assoc(server,pp.get_param("invalidate_handle")); |
260 | if(pp.has_param("is_valid")) { | 298 | if(pp.has_param("is_valid")) { |
261 | if(pp.get_param("is_valid")=="true") | 299 | if(pp.get_param("is_valid")=="true") |
262 | return; | 300 | return; |
263 | }else if(pp.has_param("lifetime")) { | 301 | }else if(pp.has_param("lifetime")) { |
264 | if(util::string_to_long(pp.get_param("lifetime"))) | 302 | if(util::string_to_long(pp.get_param("lifetime"))) |
265 | return; | 303 | return; |
266 | } | 304 | } |
267 | throw failed_check_authentication(OPKELE_CP_ "failed to verify response"); | 305 | throw failed_check_authentication(OPKELE_CP_ "failed to verify response"); |
268 | } | 306 | } |
269 | 307 | ||
270 | void consumer_t::retrieve_links(const string& url,string& server,string& delegate) { | 308 | void consumer_t::retrieve_links(const string& url,string& server,string& delegate) { |
271 | #if defined(USE_LIBPCRECPP) || defined(USE_PCREPP) | ||
272 | server.erase(); | 309 | server.erase(); |
273 | delegate.erase(); | 310 | delegate.erase(); |
274 | curl_t curl = curl_easy_init(); | 311 | curl_t curl = curl_easy_init(); |
275 | if(!curl) | 312 | if(!curl) |
276 | throw exception_curl(OPKELE_CP_ "failed to curl_easy_init()"); | 313 | throw exception_curl(OPKELE_CP_ "failed to curl_easy_init()"); |
277 | string html; | 314 | string html; |
278 | CURLcode r; | 315 | CURLcode r; |
279 | (r=curl_misc_sets(curl)) | 316 | (r=curl_misc_sets(curl)) |
280 | || (r=curl_easy_setopt(curl,CURLOPT_URL,url.c_str())) | 317 | || (r=curl_easy_setopt(curl,CURLOPT_URL,url.c_str())) |
281 | || (r=curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,_curl_tostring)) | 318 | || (r=curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,_curl_tostring)) |
282 | || (r=curl_easy_setopt(curl,CURLOPT_WRITEDATA,&html)) | 319 | || (r=curl_easy_setopt(curl,CURLOPT_WRITEDATA,&html)) |
283 | ; | 320 | ; |
284 | if(r) | 321 | if(r) |
285 | throw exception_curl(OPKELE_CP_ "failed to curl_easy_setopt()",r); | 322 | throw exception_curl(OPKELE_CP_ "failed to curl_easy_setopt()",r); |
286 | r = curl_easy_perform(curl); | 323 | r = curl_easy_perform(curl); |
287 | if(r && r!=CURLE_WRITE_ERROR) | 324 | if(r && r!=CURLE_WRITE_ERROR) |
288 | throw exception_curl(OPKELE_CP_ "failed to curl_easy_perform()",r); | 325 | throw exception_curl(OPKELE_CP_ "failed to curl_easy_perform()",r); |
289 | // strip out everything past body | 326 | static const char *re_bre = "<\\s*body\\b", *re_hdre = "<\\s*head[^>]*>", |
290 | static const char *re_hdre = "<\\s*head[^>]*>", | ||
291 | *re_lre = "<\\s*link\\b([^>]+)>", | 327 | *re_lre = "<\\s*link\\b([^>]+)>", |
292 | *re_rre = "\\brel\\s*=\\s*['\"]\\s*([^'\"\\s]+)\\s*['\"]", | 328 | *re_rre = "\\brel\\s*=\\s*['\"]\\s*([^'\"\\s]+)\\s*['\"]", |
293 | *re_hre = "\\bhref\\s*=\\s*['\"]\\s*([^'\"\\s]+)\\s*['\"]"; | 329 | *re_hre = "\\bhref\\s*=\\s*['\"]\\s*([^'\"\\s]+)\\s*['\"]"; |
294 | #if defined(USE_LIBPCRECPP) | 330 | pcre_matches_t m1(3), m2(3); |
295 | static pcrecpp::RE_Options ro(PCRE_CASELESS|PCRE_DOTALL); | 331 | pcre_t bre(re_bre,PCRE_CASELESS); |
296 | static pcrecpp::RE | 332 | if(bre.exec(html,m1)>0) |
297 | bre("<body\\b.*",ro), hdre(re_hdre,ro), | 333 | html.erase(m1.begin(0)); |
298 | lre(re_lre,ro), rre(re_rre), hre(re_hre,ro); | 334 | pcre_t hdre(re_hdre,PCRE_CASELESS); |
299 | bre.Replace("",&html); | 335 | if(hdre.exec(html,m1)<=0) |
300 | pcrecpp::StringPiece hpiece(html); | 336 | throw bad_input(OPKELE_CP_ "failed to find <head>"); |
301 | if(!hdre.FindAndConsume(&hpiece)) | 337 | html.erase(0,m1.end(0)+1); |
302 | throw bad_input(OPKELE_CP_ "failed to find head"); | 338 | pcre_t lre(re_lre,PCRE_CASELESS), rre(re_rre,PCRE_CASELESS), hre(re_hre,PCRE_CASELESS); |
303 | string attrs; | 339 | while(lre.exec(html,m1)>=2) { |
304 | while(lre.FindAndConsume(&hpiece,&attrs)) { | 340 | string attrs(html,m1.begin(1),m1.length(1)); |
305 | pcrecpp::StringPiece rel, href; | 341 | html.erase(0,m1.end(0)+1); |
306 | if(!(rre.PartialMatch(attrs,&rel) && hre.PartialMatch(attrs,&href))) | 342 | if(!( rre.exec(attrs,m1)>=2 && hre.exec(attrs,m2)>=2 )) |
307 | continue; | 343 | continue; |
344 | string rel(attrs,m1.begin(1),m1.length(1)); | ||
345 | string href(attrs,m2.begin(1),m2.length(1)); | ||
308 | if(rel=="openid.server") { | 346 | if(rel=="openid.server") { |
309 | href.CopyToString(&server); | 347 | server = href; |
310 | if(!delegate.empty()) | 348 | if(!delegate.empty()) break; |
311 | break; | ||
312 | }else if(rel=="openid.delegate") { | 349 | }else if(rel=="openid.delegate") { |
313 | href.CopyToString(&delegate); | 350 | delegate = href; |
314 | if(!server.empty()) | 351 | if(!server.empty()) break; |
315 | break; | ||
316 | } | ||
317 | } | ||
318 | #elif defined(USE_PCREPP) | ||
319 | pcrepp::Pcre bre("<body\\b",PCRE_CASELESS); | ||
320 | if(bre.search(html)) | ||
321 | html.erase(bre.get_match_start()); | ||
322 | pcrepp::Pcre hdre(re_hdre,PCRE_CASELESS); | ||
323 | if(!hdre.search(html)) | ||
324 | throw bad_input(OPKELE_CP_ "failed to find head"); | ||
325 | html.erase(0,hdre.get_match_end()+1); | ||
326 | pcrepp::Pcre lre(re_lre,PCRE_CASELESS), rre(re_rre,PCRE_CASELESS), hre(re_hre,PCRE_CASELESS); | ||
327 | while(lre.search(html)) { | ||
328 | string attrs = lre[0]; | ||
329 | html.erase(0,lre.get_match_end()+1); | ||
330 | if(!(rre.search(attrs)&&hre.search(attrs))) | ||
331 | continue; | ||
332 | if(rre[0]=="openid.server") { | ||
333 | server = hre[0]; | ||
334 | if(!delegate.empty()) | ||
335 | break; | ||
336 | }else if(rre[0]=="openid.delegate") { | ||
337 | delegate = hre[0]; | ||
338 | if(!server.empty()) | ||
339 | break; | ||
340 | } | 352 | } |
341 | } | 353 | } |
342 | #else | ||
343 | #error "I must have gone crazy" | ||
344 | #endif | ||
345 | if(server.empty()) | 354 | if(server.empty()) |
346 | throw failed_assertion(OPKELE_CP_ "The location has no openid.server declaration"); | 355 | throw failed_assertion(OPKELE_CP_ "The location has no openid.server declaration"); |
347 | #else /* none of the RE bindings enabled */ | ||
348 | throw not_implemented(OPKELE_CP_ "No internal implementation of retrieve_links were provided at compile-time"); | ||
349 | #endif | ||
350 | } | 356 | } |
351 | 357 | ||
352 | assoc_t consumer_t::find_assoc(const string& server) { | 358 | assoc_t consumer_t::find_assoc(const string& server) { |
353 | throw failed_lookup(OPKELE_CP_ "no find_assoc() provided"); | 359 | throw failed_lookup(OPKELE_CP_ "no find_assoc() provided"); |
354 | } | 360 | } |
355 | 361 | ||
356 | string consumer_t::normalize(const string& url) { | 362 | string consumer_t::normalize(const string& url) { |
357 | string rv = url; | 363 | string rv = url; |
358 | // strip leading and trailing spaces | 364 | // strip leading and trailing spaces |
359 | string::size_type i = rv.find_first_not_of(" \t\r\n"); | 365 | string::size_type i = rv.find_first_not_of(" \t\r\n"); |
360 | if(i==string::npos) | 366 | if(i==string::npos) |
361 | throw bad_input(OPKELE_CP_ "empty URL"); | 367 | throw bad_input(OPKELE_CP_ "empty URL"); |
362 | if(i) | 368 | if(i) |
363 | rv.erase(0,i); | 369 | rv.erase(0,i); |
364 | i = rv.find_last_not_of(" \t\r\n"); | 370 | i = rv.find_last_not_of(" \t\r\n"); |
365 | assert(i!=string::npos); | 371 | assert(i!=string::npos); |
diff --git a/libopkele.pc.in b/libopkele.pc.in index 286720e..5f8684b 100644 --- a/libopkele.pc.in +++ b/libopkele.pc.in | |||
@@ -1,11 +1,11 @@ | |||
1 | prefix=@prefix@ | 1 | prefix=@prefix@ |
2 | exec_prefix=@exec_prefix@ | 2 | exec_prefix=@exec_prefix@ |
3 | libdir=@libdir@ | 3 | libdir=@libdir@ |
4 | includedir=@includedir@ | 4 | includedir=@includedir@ |
5 | 5 | ||
6 | Name: libopkele | 6 | Name: libopkele |
7 | Description: C++ implementation of OpenID protocol | 7 | Description: C++ implementation of OpenID protocol |
8 | Version: @VERSION@ | 8 | Version: @VERSION@ |
9 | Requires: openssl @KONFORKA_KONFORKA@ | 9 | Requires: openssl libpcre @KONFORKA_KONFORKA@ |
10 | Cflags: -I${includedir} @LIBCURL_CPPFLAGS@ @PCREPP_CFLAGS@ | 10 | Cflags: -I${includedir} @LIBCURL_CPPFLAGS@ @PCREPP_CFLAGS@ |
11 | Libs: -L${libdir} -lopkele @LIBCURL@ @PCREPP_LIBS@ | 11 | Libs: -L${libdir} -lopkele @LIBCURL@ @PCREPP_LIBS@ |