[cpp-sp] branch master updated: SSPCPP-862 - Configurable attribute value separator
Scott Cantor
cantor.2 at osu.edu
Wed Oct 9 18:35:16 EDT 2019
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch master
in repository cpp-sp.
View the commit online:
http://git.shibboleth.net/view/?p=cpp-sp.git;a=commit;h=8044713e31bb3f7b1702d64b1f571caa19bb7510
The following commit(s) were added to refs/heads/master by this push:
new 8044713 SSPCPP-862 - Configurable attribute value separator
8044713 is described below
commit 8044713e31bb3f7b1702d64b1f571caa19bb7510
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Oct 9 18:34:45 2019 -0400
SSPCPP-862 - Configurable attribute value separator
https://issues.shibboleth.net/jira/browse/SSPCPP-862
---
schemas/shibboleth-3.0-native-sp-config.xsd | 1 +
shibsp/SPConfig.h | 8 +++++++-
shibsp/ServiceProvider.cpp | 23 +++++++++++++++--------
shibsp/handler/impl/SessionHandler.cpp | 16 +++++++++++-----
4 files changed, 34 insertions(+), 14 deletions(-)
diff --git a/schemas/shibboleth-3.0-native-sp-config.xsd b/schemas/shibboleth-3.0-native-sp-config.xsd
index 22fd8ee..e32d5f4 100644
--- a/schemas/shibboleth-3.0-native-sp-config.xsd
+++ b/schemas/shibboleth-3.0-native-sp-config.xsd
@@ -295,6 +295,7 @@
<attribute name="acsIndex" type="unsignedShort"/>
<attribute name="REMOTE_ADDR" type="conf:string"/>
<attribute name="encoding" type="conf:string"/>
+ <attribute name="attributeValueDelimiter" type="conf:string"/>
<attribute name="unset" type="conf:listOfStrings"/>
<anyAttribute namespace="##other" processContents="lax"/>
</attributeGroup>
diff --git a/shibsp/SPConfig.h b/shibsp/SPConfig.h
index ed021f5..b2ed199 100644
--- a/shibsp/SPConfig.h
+++ b/shibsp/SPConfig.h
@@ -194,7 +194,13 @@ namespace shibsp {
const opensaml::MessageDecoder::ArtifactResolver* getArtifactResolver() const;
#endif
- /** Separator for serialized values of multi-valued attributes. */
+ /**
+ * Separator for serialized values of multi-valued attributes.
+ *
+ * <p>This is deprecated, and was never actually read within the code.</p>
+ *
+ * @deprecated
+ */
char attribute_value_delimeter;
/**
diff --git a/shibsp/ServiceProvider.cpp b/shibsp/ServiceProvider.cpp
index aacbba1..0b184eb 100644
--- a/shibsp/ServiceProvider.cpp
+++ b/shibsp/ServiceProvider.cpp
@@ -174,6 +174,13 @@ namespace shibsp {
const URLEncoder* encoder = XMLToolingConfig::getConfig().getURLEncoder();
+ // Default delimiter is semicolon but is now configurable.
+ pair<bool,const char*> delim = settings.first->getString("attributeValueDelimiter");
+ if (enc.first || !delim.first) {
+ delim.second = ";";
+ }
+ size_t delim_len = strlen(delim.second);
+
pair<bool,bool> exportDups = settings.first->getBool("exportDuplicateValues");
const multimap<string,const Attribute*>& attributes = session->getIndexedAttributes();
@@ -186,18 +193,18 @@ namespace shibsp {
const vector<string>& vals = a->second->getSerializedValues();
for (vector<string>::const_iterator v = vals.begin(); v != vals.end(); ++v) {
if (!header.empty())
- header += ';';
+ header += delim.second;
if (enc.first) {
// If URL-encoding, any semicolons will get escaped anyway.
header += encoder->encode(v->c_str());
}
else {
- string::size_type pos = v->find_first_of(';', string::size_type(0));
+ string::size_type pos = v->find(delim.second, string::size_type(0));
if (pos != string::npos) {
string value(*v);
- for (; pos != string::npos; pos = value.find_first_of(';', pos)) {
+ for (; pos != string::npos; pos = value.find(delim.second, pos)) {
value.insert(pos, "\\");
- pos += 2;
+ pos += delim_len + 1;
}
header += value;
}
@@ -224,18 +231,18 @@ namespace shibsp {
string header;
for (set<string>::const_iterator v = deduped->second.begin(); v != deduped->second.end(); ++v) {
if (!header.empty())
- header += ';';
+ header += delim.second;
if (enc.first) {
// If URL-encoding, any semicolons will get escaped anyway.
header += encoder->encode(v->c_str());
}
else {
- string::size_type pos = v->find_first_of(';', string::size_type(0));
+ string::size_type pos = v->find(delim.second, string::size_type(0));
if (pos != string::npos) {
string value(*v);
- for (; pos != string::npos; pos = value.find_first_of(';', pos)) {
+ for (; pos != string::npos; pos = value.find(delim.second, pos)) {
value.insert(pos, "\\");
- pos += 2;
+ pos += delim_len + 1;
}
header += value;
}
diff --git a/shibsp/handler/impl/SessionHandler.cpp b/shibsp/handler/impl/SessionHandler.cpp
index 2e33491..c777ae0 100644
--- a/shibsp/handler/impl/SessionHandler.cpp
+++ b/shibsp/handler/impl/SessionHandler.cpp
@@ -313,16 +313,22 @@ pair<bool,long> SessionHandler::doHTML(SPRequest& request) const
}
if (m_values) {
+ // Default delimiter is semicolon but is now configurable.
+ pair<bool,const char*> delim = request.getRequestSettings().first->getString("attributeValueDelimiter");
+ if (!delim.first)
+ delim.second = ";";
+ size_t delim_len = strlen(delim.second);
+
const vector<string>& vals = a->second->getSerializedValues();
for (vector<string>::const_iterator v = vals.begin(); v!=vals.end(); ++v) {
if (v != vals.begin() || a->first == key)
- s << ';';
- string::size_type pos = v->find_first_of(';',string::size_type(0));
- if (pos!=string::npos) {
+ s << delim.second;
+ string::size_type pos = v->find(delim.second, string::size_type(0));
+ if (pos != string::npos) {
string value(*v);
- for (; pos != string::npos; pos = value.find_first_of(';',pos)) {
+ for (; pos != string::npos; pos = value.find(delim.second, pos)) {
value.insert(pos, "\\");
- pos += 2;
+ pos += delim_len + 1;
}
s << value;
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list