[log4shib] 09/10: SSPCPP-706 Constrain the addition of elements to PropertyConfiguratorImpl::getCategories
Etienne Dysli Metref
edm-guest at moszumanska.debian.org
Thu Nov 16 07:43:20 UTC 2017
This is an automated email from the git hooks/post-receive script.
edm-guest pushed a commit to branch master
in repository log4shib.
commit fd0bb182da0e9a6c3511096e7bd6276d6c67a47e
Author: Rod Widdowson <rdw at steadingsoftware.com>
Date: Sat Feb 25 15:35:05 2017 +0000
SSPCPP-706 Constrain the addition of elements to PropertyConfiguratorImpl::getCategories
https://issues.shibboleth.net/jira/browse/SSPCPP-706
Do not add duplicates and do not add null categories (being a degenerate
duplicate since "rootCategory" is always added and "" means "rootCategory".
---
msvc14/sscpp706/sscpp706.VCXPROJ.filters | 16 ++++++++++++++++
src/PropertyConfiguratorImpl.cpp | 9 ++++++++-
tests/sscpp706.txt | 5 ++++-
3 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/msvc14/sscpp706/sscpp706.VCXPROJ.filters b/msvc14/sscpp706/sscpp706.VCXPROJ.filters
new file mode 100644
index 0000000..990a9c0
--- /dev/null
+++ b/msvc14/sscpp706/sscpp706.VCXPROJ.filters
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <ClCompile Include="..\..\tests\sscpp706.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <Filter Include="Data">
+ <UniqueIdentifier>{6aafd29c-1884-4c25-8664-ef39e2dd1b89}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <Text Include="..\..\tests\sscpp706.txt">
+ <Filter>Data</Filter>
+ </Text>
+ </ItemGroup>
+</Project>
\ No newline at end of file
diff --git a/src/PropertyConfiguratorImpl.cpp b/src/PropertyConfiguratorImpl.cpp
index fbc557c..86a9ae6 100644
--- a/src/PropertyConfiguratorImpl.cpp
+++ b/src/PropertyConfiguratorImpl.cpp
@@ -337,14 +337,21 @@ namespace log4shib {
categories.clear();
// add the root category first
+ std::set<std::string> contents;
categories.push_back(std::string("rootCategory"));
+ contents.insert(std::string("rootCategory"));
// then look for "category."
std::string prefix("category");
Properties::const_iterator from = _properties.lower_bound(prefix + '.');
Properties::const_iterator to = _properties.lower_bound(prefix + (char)('.' + 1));
for (Properties::const_iterator iter = from; iter != to; iter++) {
- categories.push_back((*iter).first.substr(prefix.size() + 1));
+ std::string what((*iter).first.substr(prefix.size() + 1));
+ bool is_in = (contents.find(what) != contents.end());
+ if ("" != what && !is_in) {
+ categories.push_back(what);
+ contents.insert(what);
+ }
}
}
}
diff --git a/tests/sscpp706.txt b/tests/sscpp706.txt
index fce8ab4..b7e2c96 100644
--- a/tests/sscpp706.txt
+++ b/tests/sscpp706.txt
@@ -1,5 +1,8 @@
log4shib.rootCategory=DEBUG, rootAppender
-#log4shib.category.rootCategory=DEBUG, rootAppender
+log4shib.category.rootCategory=DEBUG, rootAppender
+log4shib.category.flinby=DEBUG, rootAppender
+#log4shib.rootCategory=DEBUG, rootAppender
+#log4shib.category.=DEBUG, rootAppender
log4shib.appender.rootAppender=ConsoleAppender
log4shib.appender.rootAppender.layout=PatternLayout
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-shibboleth/log4shib.git
More information about the Pkg-shibboleth-devel
mailing list