From: Adam Dickmeiss Date: Mon, 15 May 2006 11:43:01 +0000 (+0000) Subject: Fixed bug #574: Database names are recognised case-sensitively. X-Git-Tag: METAPROXY.1.0.3~5 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=4c42fcd314fe52e0a896b08ed9d818bf6f323fe7;p=metaproxy-moved-to-github.git Fixed bug #574: Database names are recognised case-sensitively. Note that virtual targets identifiers are still case-sensitive, i.e. names used in virt_db and multi.. It is the database (names) in the Z39.50 search requests which aren't case-sensitive by this patch. --- diff --git a/NEWS b/NEWS index cbe4f27..93732d7 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,7 @@ --- 1.0.3 [in progress] +Fixed bug #574: Database names are recognised case-sensitively. + Fixed bug #567: Fix up database name in Name-Plus-Record. Fixed bug #568: Update win/makefile for VS 2005. diff --git a/src/filter_auth_simple.cpp b/src/filter_auth_simple.cpp index 7b0cba8..4b10cac 100644 --- a/src/filter_auth_simple.cpp +++ b/src/filter_auth_simple.cpp @@ -1,4 +1,4 @@ -/* $Id: filter_auth_simple.cpp,v 1.18 2006-03-16 10:40:59 adam Exp $ +/* $Id: filter_auth_simple.cpp,v 1.19 2006-05-15 11:43:01 adam Exp $ Copyright (c) 2005-2006, Index Data. %LICENSE% @@ -242,9 +242,10 @@ void yf::AuthSimple::process_init(mp::Package &package) const static bool contains(std::list list, std::string thing) { std::list::const_iterator i; for (i = list.begin(); i != list.end(); i++) - if (*i == thing) + if (mp::util::database_name_normalize(*i) == + mp::util::database_name_normalize(thing)) return true; - + return false; } diff --git a/src/filter_virt_db.cpp b/src/filter_virt_db.cpp index bf6e02d..69a3ee4 100644 --- a/src/filter_virt_db.cpp +++ b/src/filter_virt_db.cpp @@ -1,4 +1,4 @@ -/* $Id: filter_virt_db.cpp,v 1.37 2006-04-29 08:09:13 adam Exp $ +/* $Id: filter_virt_db.cpp,v 1.38 2006-05-15 11:43:01 adam Exp $ Copyright (c) 2005-2006, Index Data. %LICENSE% @@ -92,11 +92,8 @@ namespace metaproxy_1 { FrontendPtr get_frontend(Package &package); void release_frontend(Package &package); private: - boost::mutex m_sessions_mutex; std::mapm_maps; - typedef std::map::iterator Sets_it; - boost::mutex m_mutex; boost::condition m_cond_session_ready; std::map m_clients; @@ -104,8 +101,6 @@ namespace metaproxy_1 { } } -using namespace mp; - yf::Virt_db::BackendPtr yf::Virt_db::Frontend::lookup_backend_from_databases( std::list databases) { @@ -134,7 +129,7 @@ yf::Virt_db::BackendPtr yf::Virt_db::Frontend::create_backend_from_databases( for (; db_it != databases.end(); db_it++) { std::map::iterator map_it; - map_it = m_p->m_maps.find(*db_it); + map_it = m_p->m_maps.find(mp::util::database_name_normalize(*db_it)); if (map_it == m_p->m_maps.end()) // database not found { error_code = YAZ_BIB1_DATABASE_UNAVAILABLE; @@ -623,7 +618,8 @@ void yf::Virt_db::add_map_db2targets(std::string db, std::list targets, std::string route) { - m_p->m_maps[db] = Virt_db::Map(targets, route); + m_p->m_maps[mp::util::database_name_normalize(db)] + = Virt_db::Map(targets, route); } @@ -634,7 +630,8 @@ void yf::Virt_db::add_map_db2target(std::string db, std::list targets; targets.push_back(target); - m_p->m_maps[db] = Virt_db::Map(targets, route); + m_p->m_maps[mp::util::database_name_normalize(db)] + = Virt_db::Map(targets, route); } void yf::Virt_db::process(Package &package) const diff --git a/src/util.cpp b/src/util.cpp index 8bb34f9..b2a70c5 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -1,4 +1,4 @@ -/* $Id: util.cpp,v 1.14 2006-03-16 10:40:59 adam Exp $ +/* $Id: util.cpp,v 1.15 2006-05-15 11:43:01 adam Exp $ Copyright (c) 2005-2006, Index Data. %LICENSE% @@ -16,6 +16,20 @@ namespace mp = metaproxy_1; +std::string mp::util::database_name_normalize(const std::string &s) +{ + std::string r = s; + size_t i; + for (i = 0; i < r.length(); i++) + { + int ch = r[i]; + if (ch >= 'A' && ch <= 'Z') + r[i] = ch + 'a' - 'A'; + } + return r; + +} + void mp::util::piggyback(int smallSetUpperBound, int largeSetLowerBound, int mediumSetPresentNumber, diff --git a/src/util.hpp b/src/util.hpp index ee920f1..f60e818 100644 --- a/src/util.hpp +++ b/src/util.hpp @@ -1,4 +1,4 @@ -/* $Id: util.hpp,v 1.13 2006-03-16 10:40:59 adam Exp $ +/* $Id: util.hpp,v 1.14 2006-05-15 11:43:01 adam Exp $ Copyright (c) 2005-2006, Index Data. %LICENSE% @@ -18,6 +18,8 @@ namespace metaproxy_1 { namespace util { + std::string database_name_normalize(const std::string &s); + bool pqf(ODR odr, Z_APDU *apdu, const std::string &q); std::string zQueryToString(Z_Query *query);