GLS, Stardict: Fix some links handling

This commit is contained in:
Abs62 2017-03-20 17:36:28 +03:00
parent ffd56c73dc
commit 94583da9a3
2 changed files with 4 additions and 9 deletions

9
gls.cc
View file

@ -819,7 +819,7 @@ QString & GlsDictionary::filterResource( QString & article )
// Handle links to articles
QRegExp linksReg( "<a(\\s*[^>]*)href\\s*=\\s*['\"](?:bword://)?([^'\"]+)['\"]" );
QRegExp linksReg( "<a(\\s*[^>]*)href\\s*=\\s*['\"](bword://)?([^'\"]+)['\"]" );
linksReg.setMinimal( true );
int pos = 0;
@ -829,7 +829,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;
@ -1148,11 +1148,6 @@ void GlsArticleRequest::run()
result += i->second.second;
}
result = QString::fromUtf8( result.c_str() )
.replace( QRegExp( "(<\\s*a\\s+[^>]*href\\s*=\\s*[\"']\\s*)bword://", Qt::CaseInsensitive ),
"\\1bword:" )
.toUtf8().data();
Mutex::Lock _( dataMutex );
data.resize( result.size() );

View file

@ -351,7 +351,7 @@ string StardictDictionary::handleResource( char type, char const * resource, siz
// Handle links to articles
QRegExp linksReg( "<a(\\s*[^>]*)href\\s*=\\s*['\"](?:bword://)?([^'\"]+)['\"]" );
QRegExp linksReg( "<a(\\s*[^>]*)href\\s*=\\s*['\"](bword://)?([^'\"]+)['\"]" );
linksReg.setMinimal( true );
int pos = 0;
@ -361,7 +361,7 @@ string StardictDictionary::handleResource( char type, char const * resource, siz
if( pos < 0 )
break;
QString link = linksReg.cap( 2 );
QString link = linksReg.cap( 3 );
if( link.indexOf( ':' ) < 0 )
{
QString newLink;