From d60ea38cb8acfcab5b9f952e7b56d0f079001642 Mon Sep 17 00:00:00 2001 From: Stuart Mumford Date: Fri, 25 Jun 2021 12:14:45 +0100 Subject: [PATCH 1/3] Add another regex to match inline img tags using single quotes Signed-off-by: Stuart Mumford --- src/timeline/TimelineModel.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp index 067f219a..5d2d5a68 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp @@ -532,6 +532,10 @@ TimelineModel::data(const mtx::events::collections::TimelineEvents &event, int r const static QRegularExpression matchImgUri( "(]*)src=\"mxc://([^\"]*)\"([^>]*>)"); formattedBody_.replace(matchImgUri, "\\1 src=\"image://mxcImage/\\2\"\\3"); + // Same regex but for single quotes around the src + const static QRegularExpression matchImgUri2( + "(]*)src=\'mxc://([^\"]*)\'([^>]*>)"); + formattedBody_.replace(matchImgUri2, "\\1 src=\"image://mxcImage/\\2\"\\3"); const static QRegularExpression matchEmoticonHeight( "(]*)height=\"([^\"]*)\"([^>]*>)"); formattedBody_.replace(matchEmoticonHeight, From 9194b87bdc1674506706c75f3482ea838d6afe50 Mon Sep 17 00:00:00 2001 From: Stuart Mumford Date: Fri, 25 Jun 2021 15:21:04 +0100 Subject: [PATCH 2/3] Update src/timeline/TimelineModel.cpp --- src/timeline/TimelineModel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp index 5d2d5a68..d77e4409 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp @@ -534,7 +534,7 @@ TimelineModel::data(const mtx::events::collections::TimelineEvents &event, int r formattedBody_.replace(matchImgUri, "\\1 src=\"image://mxcImage/\\2\"\\3"); // Same regex but for single quotes around the src const static QRegularExpression matchImgUri2( - "(]*)src=\'mxc://([^\"]*)\'([^>]*>)"); + "(]*)src=\'mxc://([^\']*)\'([^>]*>)"); formattedBody_.replace(matchImgUri2, "\\1 src=\"image://mxcImage/\\2\"\\3"); const static QRegularExpression matchEmoticonHeight( "(]*)height=\"([^\"]*)\"([^>]*>)"); From 7fab2925b4e3b712a8d78dad5481c9729f8133d2 Mon Sep 17 00:00:00 2001 From: Stuart Mumford Date: Fri, 25 Jun 2021 15:44:15 +0100 Subject: [PATCH 3/3] Apply suggestions from code review --- src/timeline/TimelineModel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp index d77e4409..5f92aaae 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp @@ -534,7 +534,7 @@ TimelineModel::data(const mtx::events::collections::TimelineEvents &event, int r formattedBody_.replace(matchImgUri, "\\1 src=\"image://mxcImage/\\2\"\\3"); // Same regex but for single quotes around the src const static QRegularExpression matchImgUri2( - "(]*)src=\'mxc://([^\']*)\'([^>]*>)"); + "(]*)src=\'mxc://([^\']*)\'([^>]*>)"); formattedBody_.replace(matchImgUri2, "\\1 src=\"image://mxcImage/\\2\"\\3"); const static QRegularExpression matchEmoticonHeight( "(]*)height=\"([^\"]*)\"([^>]*>)");