mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 19:24:08 +00:00
Merge pull request #401 from xiaoyifang/fix/epwing-load-article
fix: epwing load article protection when load invalid address
This commit is contained in:
commit
b3a1d27c2f
26
epwing.cc
26
epwing.cc
|
@ -352,6 +352,8 @@ void EpwingDictionary::loadArticleNextPage(string & articleHeadword, string & ar
|
|||
{
|
||||
text = QString( "Article reading error: %1")
|
||||
.arg( QString::fromUtf8( e.what() ) );
|
||||
articleText = string( text.toUtf8().data() );
|
||||
return;
|
||||
}
|
||||
|
||||
articleHeadword = string( headword.toUtf8().data() );
|
||||
|
@ -384,9 +386,11 @@ void EpwingDictionary::loadArticlePreviousPage(
|
|||
{
|
||||
Mutex::Lock _( eBook.getLibMutex() );
|
||||
pos = eBook.getArticlePreviousPage( headword, text, articlePage, articleOffset, false );
|
||||
} catch( std::exception & e )
|
||||
{
|
||||
text = QString( "Article reading error: %1" ).arg( QString::fromUtf8( e.what() ) );
|
||||
}
|
||||
catch( std::exception & e ) {
|
||||
text = QString( "Article reading error: %1" ).arg( QString::fromUtf8( e.what() ) );
|
||||
articleText = string( text.toUtf8().data() );
|
||||
return;
|
||||
}
|
||||
|
||||
articleHeadword = string( headword.toUtf8().data() );
|
||||
|
@ -629,17 +633,17 @@ void EpwingArticleRequest::run()
|
|||
articlesIncluded.insert( chain[ x ].articleOffset );
|
||||
}
|
||||
|
||||
// Also try to find word in the built-in dictionary index
|
||||
getBuiltInArticle(word, pages, offsets, mainArticles );
|
||||
for( unsigned x = 0; x < alts.size(); ++x )
|
||||
{
|
||||
getBuiltInArticle( alts[ x ], pages, offsets, alternateArticles );
|
||||
}
|
||||
|
||||
|
||||
QRegularExpressionMatch m = RX::Epwing::refWord.match( gd::toQString( word ) );
|
||||
bool ref = m.hasMatch();
|
||||
|
||||
if( !ref ) {
|
||||
// Also try to find word in the built-in dictionary index
|
||||
getBuiltInArticle( word, pages, offsets, mainArticles );
|
||||
for( unsigned x = 0; x < alts.size(); ++x ) {
|
||||
getBuiltInArticle( alts[ x ], pages, offsets, alternateArticles );
|
||||
}
|
||||
}
|
||||
|
||||
if ( mainArticles.empty() && alternateArticles.empty() && !ref)
|
||||
{
|
||||
// No such word
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include "resourceschemehandler.h"
|
||||
|
||||
#include "keyboardstate.hh"
|
||||
#include "base/globalregex.hh"
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
#include "macmouseover.hh"
|
||||
|
@ -4186,7 +4187,9 @@ void MainWindow::focusWordList()
|
|||
|
||||
void MainWindow::addWordToHistory( const QString & word )
|
||||
{
|
||||
history.addItem( History::Item( 1, word.trimmed() ) );
|
||||
if(QRegularExpressionMatch m = RX::Epwing::refWord.match( word ); m.hasMatch() )
|
||||
return;
|
||||
history.addItem( History::Item( 1, word.trimmed() ) );
|
||||
}
|
||||
|
||||
void MainWindow::forceAddWordToHistory( const QString & word )
|
||||
|
|
Loading…
Reference in a new issue