summaryrefslogtreecommitdiff
path: root/configmgr
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2015-07-13 14:07:38 +0200
committerStephan Bergmann <sbergman@redhat.com>2015-07-13 14:08:07 +0200
commite80df0d58ba32e3041ff9c8cdea9c617ea7e633b (patch)
treee4b4a44a629795d2b41e78f5a14d3b1c5babbfee /configmgr
parent888f51c749bc504f12295433a747dd507723bb56 (diff)
tdf#92639: Slashes are allowed in set member names, of course
Change-Id: I30944fe9611e83566c891a7d1461ad02979daddd
Diffstat (limited to 'configmgr')
-rw-r--r--configmgr/qa/unit/test.cxx5
-rw-r--r--configmgr/source/access.cxx12
2 files changed, 9 insertions, 8 deletions
diff --git a/configmgr/qa/unit/test.cxx b/configmgr/qa/unit/test.cxx
index 544a808e4832..a9f609bc3677 100644
--- a/configmgr/qa/unit/test.cxx
+++ b/configmgr/qa/unit/test.cxx
@@ -315,8 +315,9 @@ void Test::testInsertSetMember() {
} catch (css::lang::IllegalArgumentException &) {}
try {
access->insertByName("a/b", css::uno::makeAny(member));
- CPPUNIT_FAIL("expected IllegalArgumentException");
- } catch (css::lang::IllegalArgumentException &) {}
+ } catch (css::lang::IllegalArgumentException &) {
+ CPPUNIT_FAIL("unexpected IllegalArgumentException");
+ }
css::uno::Reference<css::util::XChangesBatch>(
access, css::uno::UNO_QUERY_THROW)->commitChanges();
css::uno::Reference<css::lang::XComponent>(
diff --git a/configmgr/source/access.cxx b/configmgr/source/access.cxx
index b8fadbcc62f8..fa2930a8cbf0 100644
--- a/configmgr/source/access.cxx
+++ b/configmgr/source/access.cxx
@@ -109,12 +109,12 @@ namespace {
// Conservatively forbid what is either not an XML Char (including lone
// surrogates, even though they should not appear in well-formed UNO OUString
// instances anyway), or is a slash (as it causes problems in path syntax):
-bool isValidName(OUString const & name) {
+bool isValidName(OUString const & name, bool setMember) {
for (sal_Int32 i = 0; i != name.getLength();) {
sal_uInt32 c = name.iterateCodePoints(&i);
if ((c < 0x20 && !(c == 0x09 || c == 0x0A || c == 0x0D))
|| rtl::isHighSurrogate(c) || rtl::isLowSurrogate(c) || c == 0xFFFE
- || c == 0xFFFF || c == '/')
+ || c == 0xFFFF || (!setMember && c == '/'))
{
return false;
}
@@ -669,7 +669,7 @@ void Access::setName(OUString const & aName)
if (node->getMandatory() == Data::NO_LAYER &&
!(other.is() && other->isFinalized()))
{
- if (!isValidName(aName)) {
+ if (!isValidName(aName, true)) {
throw css::uno::RuntimeException(
"invalid element name " + aName);
}
@@ -1188,7 +1188,7 @@ void Access::insertByName(
Modifications localMods;
switch (getNode()->kind()) {
case Node::KIND_LOCALIZED_PROPERTY:
- if (!isValidName(aName)) {
+ if (!isValidName(aName, false)) {
throw css::lang::IllegalArgumentException(
aName, static_cast<cppu::OWeakObject *>(this), 0);
}
@@ -1196,7 +1196,7 @@ void Access::insertByName(
break;
case Node::KIND_GROUP:
{
- if (!isValidName(aName)) {
+ if (!isValidName(aName, false)) {
throw css::lang::IllegalArgumentException(
aName, static_cast<cppu::OWeakObject *>(this), 0);
}
@@ -1212,7 +1212,7 @@ void Access::insertByName(
break;
case Node::KIND_SET:
{
- if (!isValidName(aName)) {
+ if (!isValidName(aName, true)) {
throw css::lang::IllegalArgumentException(
aName, static_cast<cppu::OWeakObject *>(this), 0);
}