From 5b80f7563745ce5897b293b9312019d034d0de15 Mon Sep 17 00:00:00 2001 From: Abs62 Date: Sun, 12 Mar 2017 14:40:45 +0300 Subject: [PATCH] GLS, Stardict: Fix some links handling --- gls.cc | 8 ++++---- stardict.cc | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gls.cc b/gls.cc index 42605de9..1c4c758f 100644 --- a/gls.cc +++ b/gls.cc @@ -796,14 +796,14 @@ void GlsDictionary::loadArticle( uint32_t address, QString & GlsDictionary::filterResource( QString & article ) { - article.replace( QRegExp( "(<\\s*img\\s+[^>]*src\\s*=\\s*[\"']+)((?!data:)[^\"']*)", Qt::CaseInsensitive ), + article.replace( QRegExp( "(<\\s*img\\s+[^>]*src\\s*=\\s*[\"']+)((?!(data|https?|ftp):)[^\"']*)", Qt::CaseInsensitive ), "\\1bres://" + QString::fromStdString( getId() ) + "/\\2" ) - .replace( QRegExp( "(<\\s*link\\s+[^>]*href\\s*=\\s*[\"']+)((?!data:)[^\"']*)", Qt::CaseInsensitive ), + .replace( QRegExp( "(<\\s*link\\s+[^>]*href\\s*=\\s*[\"']+)((?!(data|https?|ftp):)[^\"']*)", Qt::CaseInsensitive ), "\\1bres://" + QString::fromStdString( getId() ) + "/\\2" ); // Handle links to articles - QRegExp linksReg( "]*)href=['\"]([^'\"]+)['\"]" ); + QRegExp linksReg( "]*)href=['\"](bword://)?([^'\"]+)['\"]" ); int pos = 0; while( pos >= 0 ) @@ -812,7 +812,7 @@ QString & GlsDictionary::filterResource( QString & article ) if( pos < 0 ) break; - QString link = linksReg.cap( 2 ); + QString link = linksReg.cap( 3 ); if( link.indexOf( ':' ) < 0 ) { QString newLink; diff --git a/stardict.cc b/stardict.cc index b1b223a0..1235ffda 100644 --- a/stardict.cc +++ b/stardict.cc @@ -341,9 +341,9 @@ string StardictDictionary::handleResource( char type, char const * resource, siz { QString articleText = QString( "
" ) + QString::fromUtf8( resource, size ) + "
"; - articleText.replace( QRegExp( "(<\\s*img\\s+[^>]*src\\s*=\\s*[\"']+)((?!data:)[^\"']*)", Qt::CaseInsensitive ), + articleText.replace( QRegExp( "(<\\s*img\\s+[^>]*src\\s*=\\s*[\"']+)((?!(data|https?|ftp):)[^\"']*)", Qt::CaseInsensitive ), "\\1bres://" + QString::fromStdString( getId() ) + "/\\2" ) - .replace( QRegExp( "(<\\s*link\\s+[^>]*href\\s*=\\s*[\"']+)((?!data:)[^\"']*)", Qt::CaseInsensitive ), + .replace( QRegExp( "(<\\s*link\\s+[^>]*href\\s*=\\s*[\"']+)((?!(data|https?|ftp):)[^\"']*)", Qt::CaseInsensitive ), "\\1bres://" + QString::fromStdString( getId() ) + "/\\2" ); // Handle links to articles