[Libreoffice-commits] online.git: loolwsd/test loolwsd/Util.hpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Tue Sep 27 02:32:54 UTC 2016
loolwsd/Util.hpp | 12 +++++++-----
loolwsd/test/httpwstest.cpp | 2 ++
loolwsd/test/integration-http-server.cpp | 4 +++-
3 files changed, 12 insertions(+), 6 deletions(-)
New commits:
commit 1fdb4bf8626ffa67c7732fe55f0cccf733894c15
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Mon Sep 26 22:29:53 2016 -0400
loolwsd: replace Poco regex with std
Change-Id: Id761d964708bf34b58146b8a3d5ff19df7452b67
Reviewed-on: https://gerrit.libreoffice.org/29309
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/loolwsd/Util.hpp b/loolwsd/Util.hpp
index cf6aba5..f038005 100644
--- a/loolwsd/Util.hpp
+++ b/loolwsd/Util.hpp
@@ -10,19 +10,19 @@
#ifndef INCLUDED_UTIL_HPP
#define INCLUDED_UTIL_HPP
+#include <atomic>
#include <cassert>
#include <functional>
#include <memory>
+#include <regex>
#include <set>
#include <sstream>
#include <string>
-#include <atomic>
#include <Poco/File.h>
#include <Poco/Net/WebSocket.h>
#include <Poco/Path.h>
#include <Poco/Process.h>
-#include <Poco/RegularExpression.h>
#define LOK_USE_UNSTABLE_API
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
@@ -173,16 +173,18 @@ namespace Util
}
// Not a perfect match, try regex.
+ const int length = subject.size();
for (const auto& value : set)
{
try
{
// Not performance critical to warrant caching.
- Poco::RegularExpression re(value, Poco::RegularExpression::RE_CASELESS);
- Poco::RegularExpression::Match reMatch{0, 0};
+ std::regex re(value, std::regex::icase);
+ std::smatch match;
// Must be a full match.
- if (re.match(subject, reMatch) && reMatch.offset == 0 && reMatch.length == subject.size())
+ if (std::regex_match(subject, match, re) &&
+ match.position() == 0 && match.length() == length)
{
return true;
}
diff --git a/loolwsd/test/httpwstest.cpp b/loolwsd/test/httpwstest.cpp
index 0d30d32..ab27da3 100644
--- a/loolwsd/test/httpwstest.cpp
+++ b/loolwsd/test/httpwstest.cpp
@@ -33,10 +33,12 @@
#include <Poco/Net/Socket.h>
#include <Poco/Net/WebSocket.h>
#include <Poco/Path.h>
+#include <Poco/RegularExpression.h>
#include <Poco/StreamCopier.h>
#include <Poco/StringTokenizer.h>
#include <Poco/Thread.h>
#include <Poco/URI.h>
+
#include <cppunit/extensions/HelperMacros.h>
#include "Common.hpp"
diff --git a/loolwsd/test/integration-http-server.cpp b/loolwsd/test/integration-http-server.cpp
index 390ea55..6899476 100644
--- a/loolwsd/test/integration-http-server.cpp
+++ b/loolwsd/test/integration-http-server.cpp
@@ -13,14 +13,16 @@
#include <Poco/Net/FilePartSource.h>
#include <Poco/Net/HTMLForm.h>
#include <Poco/Net/HTTPClientSession.h>
-#include <Poco/Net/HTTPSClientSession.h>
#include <Poco/Net/HTTPRequest.h>
#include <Poco/Net/HTTPResponse.h>
+#include <Poco/Net/HTTPSClientSession.h>
#include <Poco/Net/InvalidCertificateHandler.h>
#include <Poco/Net/PrivateKeyPassphraseHandler.h>
#include <Poco/Net/SSLManager.h>
+#include <Poco/RegularExpression.h>
#include <Poco/StreamCopier.h>
#include <Poco/URI.h>
+
#include <cppunit/extensions/HelperMacros.h>
#include <Common.hpp>
More information about the Libreoffice-commits
mailing list