From 6f6391e5b8cf8589fe91a7de1dcb3a2a2fa9a9d0 Mon Sep 17 00:00:00 2001 From: Xiao Yi Fang Date: Sat, 15 Jun 2024 13:45:20 +0800 Subject: [PATCH] fix: stardict regex invertedgreedy match --- src/dict/stardict.cc | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/dict/stardict.cc b/src/dict/stardict.cc index 22a2d2aac..7b4d87d42 100644 --- a/src/dict/stardict.cc +++ b/src/dict/stardict.cc @@ -454,11 +454,9 @@ string StardictDictionary::handleResource( char type, char const * resource, siz QString articleText = QString( "
" ) + QString::fromUtf8( resource, size ) + "
"; QRegularExpression imgRe( R"((<\s*(?:img|script)\s+[^>]*src\s*=\s*["']?)(?!(?:data|https?|ftp):))", - QRegularExpression::CaseInsensitiveOption - | QRegularExpression::InvertedGreedinessOption ); + QRegularExpression::CaseInsensitiveOption ); QRegularExpression linkRe( R"((<\s*link\s+[^>]*href\s*=\s*["']?)(?!(?:data|https?|ftp):))", - QRegularExpression::CaseInsensitiveOption - | QRegularExpression::InvertedGreedinessOption ); + QRegularExpression::CaseInsensitiveOption ); articleText.replace( imgRe, "\\1bres://" + QString::fromStdString( getId() ) + "/" ) .replace( linkRe, "\\1bres://" + QString::fromStdString( getId() ) + "/" ); @@ -517,8 +515,7 @@ string StardictDictionary::handleResource( char type, char const * resource, siz QRegularExpression audioRe( R"(<\s*audio\s*src\s*=\s*(["']+)([^"']+)(["'])\s*>(.*))", QRegularExpression::CaseInsensitiveOption - | QRegularExpression::DotMatchesEverythingOption - | QRegularExpression::InvertedGreedinessOption ); + | QRegularExpression::DotMatchesEverythingOption ); pos = 0;