summaryrefslogtreecommitdiff
path: root/comphelper/source
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2023-01-24 08:52:01 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2023-01-24 09:46:52 +0000
commitda8d369a1fb06dfe6ef47d6e0da4402bb12ede27 (patch)
tree1a141ff882e19e923e9df4eaf3e1d4e026304607 /comphelper/source
parent22c292a2a9f4f459539d042ad902441a3583c804 (diff)
AddAttribute may take 'namespace:full:uri^attribute_name'
... e.g., created in SaxNamespaceFilter::startElement, which calls XMLNamespaces::applyNSToAttributeName to make such a name. See https://gerrit.libreoffice.org/c/core/+/145526/comments/26536db2_d8fb1e1b, which notified that the assert from f2f008c52aaa88329c07f441de60d6fdfce9f0b3 ("Merge SvXMLAttributeList to comphelper::AttributeList", 2023-01-15) started to fail on some input. Change-Id: Ia0afc167aefac463bcd354dc009bff6e14a64dfa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146054 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'comphelper/source')
-rw-r--r--comphelper/source/xml/attributelist.cxx5
1 files changed, 4 insertions, 1 deletions
diff --git a/comphelper/source/xml/attributelist.cxx b/comphelper/source/xml/attributelist.cxx
index 69f8a2aca62c..664dcf569097 100644
--- a/comphelper/source/xml/attributelist.cxx
+++ b/comphelper/source/xml/attributelist.cxx
@@ -65,7 +65,10 @@ css::uno::Reference< css::util::XCloneable > AttributeList::createClone()
void AttributeList::AddAttribute(const OUString& sName, const OUString& sValue)
{
assert(!sName.isEmpty() && "empty attribute name is invalid");
- assert(std::count(sName.getStr(), sName.getStr() + sName.getLength(), u':') <= 1
+ // Either it's 'namespace_prefix:attribute_name',
+ // or as in XMLNamespaces::applyNSToAttributeName, it's 'namespace:full:uri^attribute_name'.
+ assert((std::count(sName.getStr(), sName.getStr() + sName.getLength(), u':') <= 1
+ || std::count(sName.getStr(), sName.getStr() + sName.getLength(), u'^') == 1)
&& "too many colons");
// TODO: this assertion fails in tests!
// assert(std::none_of(mAttributes.begin(), mAttributes.end(),