summaryrefslogtreecommitdiff
path: root/src/xmlpatterns/schema
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2012-04-23 16:29:18 +0200
committerQt by Nokia <qt-info@nokia.com>2012-04-24 14:39:38 +0200
commitc1623a0d42c9869e5a1d04081e7660722a863de5 (patch)
tree17a58be3a4c80b143add805b7ff8218daab61106 /src/xmlpatterns/schema
parentc18f589a757b2c4cb8c5e66a92f34ac005223cfe (diff)
downloadqtxmlpatterns-c1623a0d42c9869e5a1d04081e7660722a863de5.tar.gz
Don't use the QRegExp methods that modify the object
QRegExp matching methods modify the object, which we don't want to. In particular, when we receive a QRegExp from the user or we store in a context that might require thread-safety, make sure we make a copy before using it. QRegularExpression has no such shortcoming. Task-number: QTBUG-25064 Change-Id: I2c4d5f4b60d6b3569568103cd7107cd2adaa3ae8 Reviewed-by: Giuseppe D'Angelo <dangelog@gmail.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src/xmlpatterns/schema')
-rw-r--r--src/xmlpatterns/schema/qxsdschemachecker.cpp2
-rw-r--r--src/xmlpatterns/schema/qxsdschemaparser.cpp4
-rw-r--r--src/xmlpatterns/schema/qxsdtypechecker.cpp20
3 files changed, 13 insertions, 13 deletions
diff --git a/src/xmlpatterns/schema/qxsdschemachecker.cpp b/src/xmlpatterns/schema/qxsdschemachecker.cpp
index 0536fca..33e2679 100644
--- a/src/xmlpatterns/schema/qxsdschemachecker.cpp
+++ b/src/xmlpatterns/schema/qxsdschemachecker.cpp
@@ -1124,7 +1124,7 @@ void XsdSchemaChecker::checkConstrainingFacets(const XsdFacet::Hash &facets, con
for (int i = 0; i < multiValue.count(); ++i) {
const DerivedString<TypeString>::Ptr value = multiValue.at(i);
- const QRegExp exp = PatternPlatform::parsePattern(value->stringValue(), m_context, &reflection);
+ QRegExp exp = PatternPlatform::parsePattern(value->stringValue(), m_context, &reflection);
if (!exp.isValid()) {
m_context->error(QtXmlPatterns::tr("%1 facet contains invalid regular expression").arg(formatKeyword("pattern.")), XsdSchemaContext::XSDError, sourceLocation(simpleType));
return;
diff --git a/src/xmlpatterns/schema/qxsdschemaparser.cpp b/src/xmlpatterns/schema/qxsdschemaparser.cpp
index a00b77e..292886e 100644
--- a/src/xmlpatterns/schema/qxsdschemaparser.cpp
+++ b/src/xmlpatterns/schema/qxsdschemaparser.cpp
@@ -511,7 +511,7 @@ void XsdSchemaParser::parseSchema(ParserType parserType)
if (hasAttribute(CommonNamespaces::XML, QString::fromLatin1("lang"))) {
const QString value = readAttribute(QString::fromLatin1("lang"), CommonNamespaces::XML);
- const QRegExp exp(QString::fromLatin1("[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*"));
+ QRegExp exp(QString::fromLatin1("[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*"));
if (!exp.exactMatch(value)) {
attributeContentError("xml:lang", "schema", value);
return;
@@ -1286,7 +1286,7 @@ XsdDocumentation::Ptr XsdSchemaParser::parseDocumentation()
if (hasAttribute(CommonNamespaces::XML, QString::fromLatin1("lang"))) {
const QString value = readAttribute(QString::fromLatin1("lang"), CommonNamespaces::XML);
- const QRegExp exp(QString::fromLatin1("[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*"));
+ QRegExp exp(QString::fromLatin1("[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*"));
if (!exp.exactMatch(value)) {
attributeContentError("xml:lang", "documentation", value);
return documentation;
diff --git a/src/xmlpatterns/schema/qxsdtypechecker.cpp b/src/xmlpatterns/schema/qxsdtypechecker.cpp
index e0ce55b..af09816 100644
--- a/src/xmlpatterns/schema/qxsdtypechecker.cpp
+++ b/src/xmlpatterns/schema/qxsdtypechecker.cpp
@@ -452,7 +452,7 @@ bool XsdTypeChecker::checkConstrainingFacetsString(const QString &value, const X
bool found = false;
for (int j = 0; j < multiValue.count(); ++j) {
const QString pattern = multiValue.at(j)->as<DerivedString<TypeString> >()->stringValue();
- const QRegExp exp = PatternPlatform::parsePattern(pattern, m_context, m_reflection);
+ QRegExp exp = PatternPlatform::parsePattern(pattern, m_context, m_reflection);
if (exp.exactMatch(value)) {
found = true;
break;
@@ -547,7 +547,7 @@ bool XsdTypeChecker::checkConstrainingFacetsSignedInteger(long long value, const
bool found = false;
for (int j = 0; j < multiValue.count(); ++j) {
const QString pattern = multiValue.at(j)->as<DerivedString<TypeString> >()->stringValue();
- const QRegExp exp = PatternPlatform::parsePattern(pattern, m_context, m_reflection);
+ QRegExp exp = PatternPlatform::parsePattern(pattern, m_context, m_reflection);
if (exp.exactMatch(lexicalValue)) {
found = true;
break;
@@ -633,7 +633,7 @@ bool XsdTypeChecker::checkConstrainingFacetsUnsignedInteger(unsigned long long v
bool found = false;
for (int j = 0; j < multiValue.count(); ++j) {
const QString pattern = multiValue.at(j)->as<DerivedString<TypeString> >()->stringValue();
- const QRegExp exp = PatternPlatform::parsePattern(pattern, m_context, m_reflection);
+ QRegExp exp = PatternPlatform::parsePattern(pattern, m_context, m_reflection);
if (exp.exactMatch(lexicalValue)) {
found = true;
break;
@@ -719,7 +719,7 @@ bool XsdTypeChecker::checkConstrainingFacetsDouble(double value, const QString &
bool found = false;
for (int j = 0; j < multiValue.count(); ++j) {
const QString pattern = multiValue.at(j)->as<DerivedString<TypeString> >()->stringValue();
- const QRegExp exp = PatternPlatform::parsePattern(pattern, m_context, m_reflection);
+ QRegExp exp = PatternPlatform::parsePattern(pattern, m_context, m_reflection);
if (exp.exactMatch(lexicalValue)) {
found = true;
break;
@@ -820,7 +820,7 @@ bool XsdTypeChecker::checkConstrainingFacetsDateTime(const QDateTime &value, con
bool found = false;
for (int j = 0; j < multiValue.count(); ++j) {
const QString pattern = multiValue.at(j)->as<DerivedString<TypeString> >()->stringValue();
- const QRegExp exp = PatternPlatform::parsePattern(pattern, m_context, m_reflection);
+ QRegExp exp = PatternPlatform::parsePattern(pattern, m_context, m_reflection);
if (exp.exactMatch(lexicalValue)) {
found = true;
break;
@@ -898,7 +898,7 @@ bool XsdTypeChecker::checkConstrainingFacetsDuration(const AtomicValue::Ptr&, co
bool found = false;
for (int j = 0; j < multiValue.count(); ++j) {
const QString pattern = multiValue.at(j)->as<DerivedString<TypeString> >()->stringValue();
- const QRegExp exp = PatternPlatform::parsePattern(pattern, m_context, m_reflection);
+ QRegExp exp = PatternPlatform::parsePattern(pattern, m_context, m_reflection);
if (exp.exactMatch(lexicalValue)) {
found = true;
break;
@@ -925,7 +925,7 @@ bool XsdTypeChecker::checkConstrainingFacetsBoolean(bool, const QString &lexical
bool found = false;
for (int j = 0; j < multiValue.count(); ++j) {
const QString pattern = multiValue.at(j)->as<DerivedString<TypeString> >()->stringValue();
- const QRegExp exp = PatternPlatform::parsePattern(pattern, m_context, m_reflection);
+ QRegExp exp = PatternPlatform::parsePattern(pattern, m_context, m_reflection);
if (exp.exactMatch(lexicalValue)) {
found = true;
break;
@@ -1038,7 +1038,7 @@ bool XsdTypeChecker::checkConstrainingFacetsQName(const QXmlName &value, const Q
bool found = false;
for (int j = 0; j < multiValue.count(); ++j) {
const QString pattern = multiValue.at(j)->as<DerivedString<TypeString> >()->stringValue();
- const QRegExp exp = PatternPlatform::parsePattern(pattern, m_context, m_reflection);
+ QRegExp exp = PatternPlatform::parsePattern(pattern, m_context, m_reflection);
if (exp.exactMatch(lexicalValue)) {
found = true;
break;
@@ -1215,7 +1215,7 @@ bool XsdTypeChecker::checkConstrainingFacetsList(const QStringList &values, cons
bool found = false;
for (int j = 0; j < multiValue.count(); ++j) {
const QString pattern = multiValue.at(j)->as<DerivedString<TypeString> >()->stringValue();
- const QRegExp exp = PatternPlatform::parsePattern(pattern, m_context, m_reflection);
+ QRegExp exp = PatternPlatform::parsePattern(pattern, m_context, m_reflection);
if (exp.exactMatch(lexicalValue)) {
found = true;
break;
@@ -1272,7 +1272,7 @@ bool XsdTypeChecker::checkConstrainingFacetsUnion(const QString &value, const QS
bool found = false;
for (int j = 0; j < multiValue.count(); ++j) {
const QString pattern = multiValue.at(j)->as<DerivedString<TypeString> >()->stringValue();
- const QRegExp exp = PatternPlatform::parsePattern(pattern, m_context, m_reflection);
+ QRegExp exp = PatternPlatform::parsePattern(pattern, m_context, m_reflection);
if (exp.exactMatch(lexicalValue)) {
found = true;
break;