From 9f6ed1eec2fde2db2ce9540b3a2e0bb5711748f8 Mon Sep 17 00:00:00 2001 From: Xiao YiFang Date: Sat, 19 Nov 2022 16:23:43 +0800 Subject: [PATCH] zim img src link replace regex changes --- zim.cc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/zim.cc b/zim.cc index 28604fe5..0f15802f 100644 --- a/zim.cc +++ b/zim.cc @@ -838,7 +838,7 @@ string ZimDictionary::convert( const string & in ) QString( "]*)src=(\"|)(\\.\\.|)/" ), + text.replace( QRegularExpression( "<\\s*(img|script)\\s+([^>]*)src=(\"|)(\\.\\./)*" ), QString( "<\\1 \\2src=\\3bres://%1/").arg( getId().c_str() ) ); // Fix links without '"' @@ -1488,9 +1488,9 @@ void ZimResourceRequest::run() } sptr< Dictionary::DataRequest > ZimDictionary::getResource( string const & name ) - { - return new ZimResourceRequest( *this, name ); + auto formatedName = QString::fromStdString(name).replace(QRegularExpression("[\\.\\/]"),""); + return new ZimResourceRequest( *this, formatedName.toStdString() ); } //} // anonymous namespace @@ -1662,8 +1662,6 @@ vector< sptr< Dictionary::Class > > makeDictionaries( } else { -// url.insert( url.begin(), '/' ); -// url.insert( url.begin(), nameSpace ); auto formatedUrl = QString::fromStdString(url).replace(QRegularExpression("[\\.\\/]"),""); indexedResources.addSingleWord( Utf8::decode( formatedUrl.toStdString() ), n ); }