From 6be5ede56e925434f5fc91603cce314b0a297a5b Mon Sep 17 00:00:00 2001 From: Markus Frank <Markus.Frank@cern.ch> Date: Mon, 9 Apr 2018 17:02:26 +0200 Subject: [PATCH] Fix uri blocker in XML entity resolver --- DDCore/include/XML/UriReader.h | 10 ++++++++++ DDCore/src/XML/UriReader.cpp | 10 ++++++++++ examples/DDDB/include/DDDB/DDDBReader.h | 4 ++-- examples/DDDB/include/Detector/DeVPSensor.h | 8 ++++---- examples/DDDB/src/plugins/CondDB2DDDB.cpp | 8 ++++---- 5 files changed, 30 insertions(+), 10 deletions(-) diff --git a/DDCore/include/XML/UriReader.h b/DDCore/include/XML/UriReader.h index 1e5d169f1..042641376 100644 --- a/DDCore/include/XML/UriReader.h +++ b/DDCore/include/XML/UriReader.h @@ -54,6 +54,11 @@ namespace dd4hep { virtual ~UriReader(); /// Access to local context virtual UserContext* context() = 0; + /** Helpers for selective parsing */ + /// Add a blocked path entry + virtual void blockPath(const std::string& /* path */) {} + /// Check if a URI path is blocked + virtual bool isBlocked(const std::string& /* path */) const { return false; } /// Resolve a given URI to a string containing the data virtual bool load(const std::string& system_id, std::string& data); /// Resolve a given URI to a string containing the data with context @@ -90,6 +95,11 @@ namespace dd4hep { virtual ~UriContextReader(); /// Access to local context virtual UserContext* context() override { return m_context; } + /** Helpers for selective parsing */ + /// Add a blocked path entry + virtual void blockPath(const std::string& path) override; + /// Check if a URI path is blocked + virtual bool isBlocked(const std::string& path) const override; /// Resolve a given URI to a string containing the data virtual bool load(const std::string& system_id, std::string& data) override; /// Resolve a given URI to a string containing the data with context diff --git a/DDCore/src/XML/UriReader.cpp b/DDCore/src/XML/UriReader.cpp index efd54db09..8efc65272 100644 --- a/DDCore/src/XML/UriReader.cpp +++ b/DDCore/src/XML/UriReader.cpp @@ -46,6 +46,16 @@ dd4hep::xml::UriContextReader::UriContextReader(const UriContextReader& copy) dd4hep::xml::UriContextReader::~UriContextReader() { } +/// Add a blocked path entry +void dd4hep::xml::UriContextReader::blockPath(const std::string& path) { + return m_reader->blockPath(path); +} + +/// Check if a URI path is blocked +bool dd4hep::xml::UriContextReader::isBlocked(const std::string& path) const { + return m_reader->isBlocked(path); +} + /// Resolve a given URI to a string containing the data bool dd4hep::xml::UriContextReader::load(const string& system_id, string& data) { return m_reader->load(system_id, context(), data); diff --git a/examples/DDDB/include/DDDB/DDDBReader.h b/examples/DDDB/include/DDDB/DDDBReader.h index 70a2e393a..335e6910c 100644 --- a/examples/DDDB/include/DDDB/DDDBReader.h +++ b/examples/DDDB/include/DDDB/DDDBReader.h @@ -79,9 +79,9 @@ namespace dd4hep { /** Helpers for selective parsing */ /// Add a blocked path entry - void blockPath(const std::string& path); + virtual void blockPath(const std::string& path) override; /// Check if a URI path is blocked - bool isBlocked(const std::string& path) const; + virtual bool isBlocked(const std::string& path) const override; protected: /// File directory diff --git a/examples/DDDB/include/Detector/DeVPSensor.h b/examples/DDDB/include/Detector/DeVPSensor.h index f15bcbfcf..20a217095 100644 --- a/examples/DDDB/include/Detector/DeVPSensor.h +++ b/examples/DDDB/include/Detector/DeVPSensor.h @@ -19,10 +19,10 @@ #include <array> // Framework include files +#include "Kernel/VPConstants.h" #include "Detector/DetectorElement.h" #include "Detector/DeStatic.h" #include "Detector/DeIOV.h" -#include "Kernel/VPConstants.h" /// Gaudi namespace declaration namespace gaudi { @@ -161,9 +161,9 @@ namespace gaudi { /// Standard constructors and assignment DE_CTORS_HANDLE(DeVPSensorElement,Base); /// Access to the static data. Does this need to be optionized??? - static_t& staticData() const { return access()->sensor_static; } - bool isLeft() const { return (ptr()->de_user&VP::LEFT) != 0; } - bool isRight() const { return (ptr()->de_user&VP::LEFT) == 0; } + static_t& staticData() const { return access()->sensor_static; } + //bool isLeft() const { return (ptr()->de_user & VP::RIGHT) == 0; } + //bool isRight() const { return (ptr()->de_user & VP::RIGHT) != 0; } }; /// For the full sensor object, we have to combine it with the geometry stuff: diff --git a/examples/DDDB/src/plugins/CondDB2DDDB.cpp b/examples/DDDB/src/plugins/CondDB2DDDB.cpp index 85151688a..23590dfa8 100644 --- a/examples/DDDB/src/plugins/CondDB2DDDB.cpp +++ b/examples/DDDB/src/plugins/CondDB2DDDB.cpp @@ -158,7 +158,7 @@ namespace dd4hep { public: Detector* description = 0; - DDDBReader* resolver = 0; + xml::UriReader* resolver = 0; dddb* geo = 0; Locals locals; bool check = true; @@ -444,7 +444,7 @@ namespace dd4hep { void fixCatalogs(DDDBContext* context) { dddb* geo = context->geo; - DDDBReader* rdr = context->resolver; + xml::UriReader* rdr = context->resolver; for(dddb::Catalogs::iterator i=geo->catalogs.begin(); i!=geo->catalogs.end(); ++i) { DDDBCatalog* det = (*i).second; for(dddb::Catalogs::iterator j=det->catalogrefs.begin(); j!=det->catalogrefs.end(); ++j) { @@ -1786,7 +1786,7 @@ namespace dd4hep { size_t hash = ref.find("#"); if ( hash != 0 ) { try { - DDDBReader* rdr = context->resolver; + xml::UriReader* rdr = context->resolver; DDDBReaderContext* ctx = (DDDBReaderContext*)rdr->context(); string doc_path = element.ptr() ? reference_href(element,ref) : ref; if ( ref == ctx->match+"/Conditions/Online" ) @@ -1869,7 +1869,7 @@ namespace dd4hep { DDDBHelper* hlp, const std::string& doc_path, const std::string& obj_path) { - DDDBReader* rdr = hlp->reader<DDDBReader>(); + xml::UriReader* rdr = hlp->reader<xml::UriReader>(); DDDBReaderContext* ctx = (DDDBReaderContext*)rdr->context(); DDDBDocument* doc = new DDDBDocument(); doc->name = obj_path; -- GitLab