Skip to content

Commit

Permalink
tdf#92639: Slashes are allowed in set member names, of course
Browse files Browse the repository at this point in the history
Change-Id: I30944fe9611e83566c891a7d1461ad02979daddd
  • Loading branch information
stbergmann committed Jul 13, 2015
1 parent 888f51c commit e80df0d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
5 changes: 3 additions & 2 deletions configmgr/qa/unit/test.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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>(
Expand Down
12 changes: 6 additions & 6 deletions configmgr/source/access.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -1188,15 +1188,15 @@ 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);
}
insertLocalizedValueChild(aName, aElement, &localMods);
break;
case Node::KIND_GROUP:
{
if (!isValidName(aName)) {
if (!isValidName(aName, false)) {
throw css::lang::IllegalArgumentException(
aName, static_cast<cppu::OWeakObject *>(this), 0);
}
Expand All @@ -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);
}
Expand Down

0 comments on commit e80df0d

Please sign in to comment.