[shibboleth-sp2] 54/89: SSPCPP-691 replace ignoreCase with caseSensitive
Ferenc Wágner
wferi at moszumanska.debian.org
Thu Sep 1 09:24:09 UTC 2016
This is an automated email from the git hooks/post-receive script.
wferi pushed a commit to branch master
in repository shibboleth-sp2.
commit 08c1e7b5b304d88ff310205b44a4bf3a7fe8319f
Author: Rod Widdowson <rdw at steadingsoftware.com>
Date: Thu Jun 9 15:56:49 2016 +0100
SSPCPP-691 replace ignoreCase with caseSensitive
https://issues.shibboleth.net/jira/browse/SSPCPP-691
XMLAccessControl is relatively uncontroversion.
XMLRequestMapper is harder - we need to maintain the legacy broken behavior whereby
'ignoreCase' means 'caseSensitive' in the PathRegex case.
So we for a PathRegex we issue an ERROR on ignoreCase and give it caseSensitive
behavior (backwards compatibility).
We do the right thing for caseSensitivity.
We default to caseSensitivity = false (a change in default, but one which fixes
legacy misbehavior).
---
shibsp/impl/XMLAccessControl.cpp | 25 ++++++++++++-------------
shibsp/impl/XMLRequestMapper.cpp | 17 ++++++++++++-----
2 files changed, 24 insertions(+), 18 deletions(-)
diff --git a/shibsp/impl/XMLAccessControl.cpp b/shibsp/impl/XMLAccessControl.cpp
index 29829ea..4fd8429 100644
--- a/shibsp/impl/XMLAccessControl.cpp
+++ b/shibsp/impl/XMLAccessControl.cpp
@@ -137,17 +137,16 @@ namespace shibsp {
return new XMLAccessControl(e);
}
- static const XMLCh _AccessControl[] = UNICODE_LITERAL_13(A,c,c,e,s,s,C,o,n,t,r,o,l);
- static const XMLCh _Handler[] = UNICODE_LITERAL_7(H,a,n,d,l,e,r);
- static const XMLCh ignoreCase[] = UNICODE_LITERAL_10(i,g,n,o,r,e,C,a,s,e);
- static const XMLCh ignoreOption[] = UNICODE_LITERAL_1(i);
- static const XMLCh _list[] = UNICODE_LITERAL_4(l,i,s,t);
- static const XMLCh require[] = UNICODE_LITERAL_7(r,e,q,u,i,r,e);
- static const XMLCh NOT[] = UNICODE_LITERAL_3(N,O,T);
- static const XMLCh AND[] = UNICODE_LITERAL_3(A,N,D);
- static const XMLCh OR[] = UNICODE_LITERAL_2(O,R);
- static const XMLCh _Rule[] = UNICODE_LITERAL_4(R,u,l,e);
- static const XMLCh _RuleRegex[] = UNICODE_LITERAL_9(R,u,l,e,R,e,g,e,x);
+ static const XMLCh _AccessControl[] = UNICODE_LITERAL_13(A,c,c,e,s,s,C,o,n,t,r,o,l);
+ static const XMLCh _Handler[] = UNICODE_LITERAL_7(H,a,n,d,l,e,r);
+ static const XMLCh caseInsensitiveOption[] = UNICODE_LITERAL_1(i);
+ static const XMLCh _list[] = UNICODE_LITERAL_4(l,i,s,t);
+ static const XMLCh require[] = UNICODE_LITERAL_7(r,e,q,u,i,r,e);
+ static const XMLCh NOT[] = UNICODE_LITERAL_3(N,O,T);
+ static const XMLCh AND[] = UNICODE_LITERAL_3(A,N,D);
+ static const XMLCh OR[] = UNICODE_LITERAL_2(O,R);
+ static const XMLCh _Rule[] = UNICODE_LITERAL_4(R,u,l,e);
+ static const XMLCh _RuleRegex[] = UNICODE_LITERAL_9(R,u,l,e,R,e,g,e,x);
}
Rule::Rule(const DOMElement* e) : m_alias(XMLHelper::getAttrString(e, nullptr, require))
@@ -253,9 +252,9 @@ RuleRegex::RuleRegex(const DOMElement* e)
if (m_alias.empty() || !m_exp.get() || !*m_exp.get())
throw ConfigurationException("Access control rule missing require attribute or element content.");
- bool ignore = XMLHelper::getAttrBool(e, false, ignoreCase);
+ bool caseSensitive = XMLHelper::getCaseSensitive(e, true);
try {
- m_re.reset(new RegularExpression(e->getFirstChild()->getNodeValue(), (ignore ? ignoreOption : &chNull)));
+ m_re.reset(new RegularExpression(e->getFirstChild()->getNodeValue(), (caseSensitive ? &chNull: caseInsensitiveOption )));
}
catch (XMLException& ex) {
auto_ptr_char tmp(ex.getMessage());
diff --git a/shibsp/impl/XMLRequestMapper.cpp b/shibsp/impl/XMLRequestMapper.cpp
index 2b4905d..ee23a9e 100644
--- a/shibsp/impl/XMLRequestMapper.cpp
+++ b/shibsp/impl/XMLRequestMapper.cpp
@@ -156,11 +156,12 @@ namespace shibsp {
static const XMLCh _AccessControl[] = UNICODE_LITERAL_13(A,c,c,e,s,s,C,o,n,t,r,o,l);
static const XMLCh AccessControlProvider[] = UNICODE_LITERAL_21(A,c,c,e,s,s,C,o,n,t,r,o,l,P,r,o,v,i,d,e,r);
+ static const XMLCh caseInsensitiveOption[] = UNICODE_LITERAL_1(i);
+ static const XMLCh caseSensitiveAttr[] = UNICODE_LITERAL_13(c,a,s,e,S,e,n,s,i,t,i,v,e);
static const XMLCh Host[] = UNICODE_LITERAL_4(H,o,s,t);
static const XMLCh HostRegex[] = UNICODE_LITERAL_9(H,o,s,t,R,e,g,e,x);
static const XMLCh htaccess[] = UNICODE_LITERAL_8(h,t,a,c,c,e,s,s);
static const XMLCh ignoreCase[] = UNICODE_LITERAL_10(i,g,n,o,r,e,C,a,s,e);
- static const XMLCh ignoreOption[] = UNICODE_LITERAL_1(i);
static const XMLCh Path[] = UNICODE_LITERAL_4(P,a,t,h);
static const XMLCh PathRegex[] = UNICODE_LITERAL_9(P,a,t,h,R,e,g,e,x);
static const XMLCh Query[] = UNICODE_LITERAL_5(Q,u,e,r,y);
@@ -316,9 +317,15 @@ Override::Override(bool unicodeAware, const DOMElement* e, Category& log, const
boost::shared_ptr<Override> o(new Override(m_unicodeAware, path, log, this));
- bool flag = XMLHelper::getAttrBool(path, true, ignoreCase);
+ bool caseSensitive;
+ if (path && path->hasAttributeNS(nullptr, ignoreCase)) {
+ log.error("Legacy interpretation of PathRegex ignoreCase attribute has incorrect sense. Use caseSensitive");
+ caseSensitive = XMLHelper::getAttrBool(path, true, ignoreCase);
+ } else {
+ caseSensitive = XMLHelper::getCaseSensitive(path, false);
+ }
try {
- boost::shared_ptr<RegularExpression> re(new RegularExpression(n, flag ? &chNull : ignoreOption));
+ boost::shared_ptr<RegularExpression> re(new RegularExpression(n, caseSensitive ? &chNull : caseInsensitiveOption));
m_regexps.push_back(make_pair(re, o));
}
catch (XMLException& ex) {
@@ -479,10 +486,10 @@ XMLRequestMapperImpl::XMLRequestMapperImpl(const DOMElement* e, Category& log) :
boost::shared_ptr<Override> o(new Override(m_unicodeAware, host, log, this));
- const XMLCh* flag = host->getAttributeNS(nullptr,ignoreCase);
+ const bool caseSensitive = XMLHelper::getCaseSensitive(host, false);
try {
boost::shared_ptr<RegularExpression> re(
- new RegularExpression(n, (flag && (*flag==chLatin_f || *flag==chDigit_0)) ? &chNull : ignoreOption)
+ new RegularExpression(n, caseSensitive ? &chNull : caseInsensitiveOption)
);
m_regexps.push_back(make_pair(re, o));
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-shibboleth/shibboleth-sp2.git
More information about the Pkg-shibboleth-devel
mailing list