diff options
author | Lars Knoll <lars.knoll@theqtcompany.com> | 2016-02-04 23:07:26 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@theqtcompany.com> | 2016-02-05 17:34:00 +0000 |
commit | b64a94516b7c789fd36a7a2d4a7ecec10c3bfe17 (patch) | |
tree | 06c0f779acefc4c691dc29e004648061b2f63c8f /src/corelib/xml/qxmlutils.cpp | |
parent | 0b8ff1cc9990cbe88ef94638c689071dfa1d8b6b (diff) |
Get rid of the QRegExp dependency in qxmlutils.
This makes the XML parser 100% independent of having regexp
support enabled.
Change-Id: I73004b0fb71e8086618995c71a985a86c292df3d
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/xml/qxmlutils.cpp')
-rw-r--r-- | src/corelib/xml/qxmlutils.cpp | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/corelib/xml/qxmlutils.cpp b/src/corelib/xml/qxmlutils.cpp index 51c52cd3d0..23caae2935 100644 --- a/src/corelib/xml/qxmlutils.cpp +++ b/src/corelib/xml/qxmlutils.cpp @@ -37,7 +37,6 @@ ** ****************************************************************************/ -#include <qregexp.h> #include <qstring.h> #include "qxmlutils_p.h" @@ -230,14 +229,20 @@ bool QXmlUtils::isBaseChar(const QChar c) */ bool QXmlUtils::isEncName(const QString &encName) { - /* Right, we here have a dependency on QRegExp. Writing a manual parser to - * replace that regexp is probably a 70 lines so I prioritize this to when - * the dependency is considered alarming, or when the rest of the bugs - * are fixed. */ - QRegExp encNameRegExp(QLatin1String("[A-Za-z][A-Za-z0-9._\\-]*")); - Q_ASSERT(encNameRegExp.isValid()); - - return encNameRegExp.exactMatch(encName); + // Valid encoding names are given by "[A-Za-z][A-Za-z0-9._\\-]*" + const ushort *c = encName.utf16(); + int l = encName.length(); + if (l < 1 || !((c[0] >= 'a' && c[0] <= 'z') || (c[0] >= 'A' && c[0] <= 'Z'))) + return false; + for (int i = 1; i < l; ++i) { + if ((c[i] >= 'a' && c[i] <= 'z') + || (c[i] >= 'A' && c[i] <= 'Z') + || (c[i] >= '0' && c[i] <= '9') + || c[i] == '.' || c[i] == '_' || c[i] == '-') + continue; + return false; + } + return true; } /*! |