diff --git a/.github/workflows/AutoTag.yml b/.github/workflows/AutoTag.yml index bc5a2ef9..3f2ee4d8 100644 --- a/.github/workflows/AutoTag.yml +++ b/.github/workflows/AutoTag.yml @@ -22,7 +22,7 @@ jobs: runs-on: ubuntu-latest env: - version: 22.9.24 + version: 22.11.24 version-suffix: alpha prerelease: true diff --git a/.github/workflows/macos-6.x.yml b/.github/workflows/macos-6.x.yml index addae0c2..146b433f 100644 --- a/.github/workflows/macos-6.x.yml +++ b/.github/workflows/macos-6.x.yml @@ -29,7 +29,7 @@ jobs: qt_arch: [clang_64] env: targetName: GoldenDict - version: 22.9.24 + version: 22.11.24 version-suffix: alpha prerelease: true diff --git a/.github/workflows/macos-homebrew.yml b/.github/workflows/macos-homebrew.yml index 3c4c6b26..5bdf2103 100644 --- a/.github/workflows/macos-homebrew.yml +++ b/.github/workflows/macos-homebrew.yml @@ -26,7 +26,7 @@ jobs: qt_arch: [clang_64] env: targetName: GoldenDict - version: 22.9.24 + version: 22.11.24 version-suffix: alpha prerelease: true steps: diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 70c8eaba..1f21e05e 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -30,7 +30,7 @@ jobs: qt_arch: [clang_64] env: targetName: GoldenDict - version: 22.9.24 + version: 22.11.24 version-suffix: alpha prerelease: true diff --git a/.github/workflows/ubuntu-6.2.yml b/.github/workflows/ubuntu-6.2.yml index 8f85c9ca..d82678e3 100644 --- a/.github/workflows/ubuntu-6.2.yml +++ b/.github/workflows/ubuntu-6.2.yml @@ -30,7 +30,7 @@ jobs: qt_ver: [6.3.2,6.4.1] qt_arch: [gcc_64] env: - version: 22.9.24 + version: 22.11.24 version-suffix: alpha prerelease: true steps: diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 4db0aff6..2f5b4d8a 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -30,7 +30,7 @@ jobs: qt_ver: [5.15.2] qt_arch: [gcc_64] env: - version: 22.9.24 + version: 22.11.24 version-suffix: alpha prerelease: true steps: diff --git a/.github/workflows/windows-6.x-xapian.yml b/.github/workflows/windows-6.x-xapian.yml index f311b465..7736b7f9 100644 --- a/.github/workflows/windows-6.x-xapian.yml +++ b/.github/workflows/windows-6.x-xapian.yml @@ -27,11 +27,11 @@ jobs: strategy: matrix: os: [windows-2019] - qt_ver: [6.3.2,6.4.1] + qt_ver: [6.3.2] qt_arch: [win64_msvc2019_64] env: targetName: GoldenDict.exe - version: 22.9.24 + version: 22.11.24 version-suffix: alpha prerelease: true steps: diff --git a/.github/workflows/windows-6.x.yml b/.github/workflows/windows-6.x.yml index 7350dc83..0358734a 100644 --- a/.github/workflows/windows-6.x.yml +++ b/.github/workflows/windows-6.x.yml @@ -27,11 +27,11 @@ jobs: strategy: matrix: os: [windows-2019] - qt_ver: [6.3.2,6.4.1] + qt_ver: [6.3.2] qt_arch: [win64_msvc2019_64] env: targetName: GoldenDict.exe - version: 22.9.24 + version: 22.11.24 version-suffix: alpha prerelease: true steps: diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 9bfecbbb..c4c5deeb 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -32,7 +32,7 @@ jobs: qt_arch: [win64_msvc2019_64] env: targetName: GoldenDict.exe - version: 22.9.24 + version: 22.11.24 version-suffix: alpha prerelease: true # 步骤 diff --git a/article_netmgr.cc b/article_netmgr.cc index a91040f6..3a4e6037 100644 --- a/article_netmgr.cc +++ b/article_netmgr.cc @@ -170,14 +170,9 @@ QNetworkReply * ArticleNetworkAccessManager::getArticleReply( QNetworkRequest co if( !path.isEmpty() ) { url.setPath( "" ); - QByteArray referer = req.rawHeader( "Referer" ); - QUrl refererUrl = QUrl::fromEncoded( referer ); Utils::Url::addQueryItem( url, "word", path.mid( 1 ) ); - if( Utils::Url::hasQueryItem( refererUrl, "group" ) ) - { - Utils::Url::addQueryItem( url, "group", Utils::Url::queryItemValue( refererUrl, "group" ) ); - } + Utils::Url::addQueryItem( url, "group", QString::number(GlobalBroadcaster::instance()->currentGroupId ) ); } } @@ -318,7 +313,7 @@ sptr< Dictionary::DataRequest > ArticleNetworkAccessManager::getResource( bool ignoreDiacritics = Utils::Url::queryItemValue( url, "ignore_diacritics" ) == "1"; - if ( phrase.isValid() ) // Require group and phrase to be passed + if ( groupIsValid && phrase.isValid() ) // Require group and phrase to be passed return articleMaker.makeDefinitionFor( phrase, group, contexts, mutedDicts, QStringList(), ignoreDiacritics ); } diff --git a/globalbroadcaster.h b/globalbroadcaster.h index 20b44aea..83f7ff8e 100644 --- a/globalbroadcaster.h +++ b/globalbroadcaster.h @@ -25,6 +25,7 @@ public: void addWhitelist(QString host); bool existedInWhitelist(QString host); static GlobalBroadcaster * instance(); + unsigned currentGroupId; signals: void dictionaryChanges( ActiveDictIds ad ); diff --git a/goldendict.pro b/goldendict.pro index a55ef6a5..a7018b4f 100644 --- a/goldendict.pro +++ b/goldendict.pro @@ -1,6 +1,6 @@ TEMPLATE = app TARGET = goldendict -VERSION = 22.9.24-alpha +VERSION = 22.11.24-alpha # Generate version file. We do this here and in a build rule described later. # The build rule is required since qmake isn't run each time the project is @@ -89,7 +89,7 @@ win32 { win32-msvc* { # VS does not recognize 22.number.alpha,cause errors during compilation under MSVC++ - VERSION = 22.9.24 + VERSION = 22.11.24 DEFINES += __WIN32 _CRT_SECURE_NO_WARNINGS contains(QMAKE_TARGET.arch, x86_64) { DEFINES += NOMINMAX __WIN64 diff --git a/mainwindow.cc b/mainwindow.cc index 82573424..9dfe5fac 100644 --- a/mainwindow.cc +++ b/mainwindow.cc @@ -572,6 +572,7 @@ MainWindow::MainWindow( Config::Class & cfg_ ): igrp->checkMutedDictionaries( &grp->mutedDictionaries ); dictionaryBar.setMutedDictionaries( grp ? &grp->mutedDictionaries : 0 ); } + GlobalBroadcaster::instance()->currentGroupId = cfg.lastMainGroupId; showDictBarNamesTriggered(); // Make update its state according to initial // setting @@ -2323,6 +2324,10 @@ void MainWindow::currentGroupChanged( int ) dictionaryBar.setMutedDictionaries( 0 ); } + if(igrp){ + GlobalBroadcaster::instance()->currentGroupId = cfg.lastMainGroupId; + } + updateDictionaryBar(); // Update word search results diff --git a/zim.cc b/zim.cc index f352383d..8fdbadad 100644 --- a/zim.cc +++ b/zim.cc @@ -128,7 +128,7 @@ __attribute__((packed)) enum { Signature = 0x584D495A, // ZIMX on little-endian, XMIZ on big-endian - CurrentFormatVersion = 3 + BtreeIndexing::FormatVersion + Folding::Version + CurrentFormatVersion = 4 + BtreeIndexing::FormatVersion + Folding::Version }; struct IdxHeader @@ -839,8 +839,44 @@ string ZimDictionary::convert( const string & in ) QString( "
]*)src=(\"|)(\\.\\./)*" ), - QString( "<\\1 \\2src=\\3bres://%1/").arg( getId().c_str() ) ); + // text.replace( QRegularExpression( "<\\s*(img|script)\\s+([^>]*)src=(\")([^\"]*)\\3" ), + // QString( "<\\1 \\2src=\\3bres://%1/").arg( getId().c_str() ) ); + + QRegularExpression rxImgScript( "<\\s*(img|script)\\s+([^>]*)src=(\")([^\"]*)\\3" ); + QRegularExpressionMatchIterator it = rxImgScript.globalMatch( text ); + int pos = 0; + QString newText; + while( it.hasNext() ) + { + QRegularExpressionMatch match = it.next(); + + newText += text.mid( pos, match.capturedStart() - pos ); + pos = match.capturedEnd(); + + QStringList list = match.capturedTexts(); + + QString url = list[ 4 ]; // a url + + QString urlLink = match.captured(); + + QString replacedLink = urlLink; + if( !url.isEmpty() && !url.startsWith( "//" ) && !url.startsWith( "http://" ) && !url.startsWith( "https://" ) ) + { + //<\\1 \\2src=\\3bres://%1/ + url.remove(QRegularExpression("^\\.*\\/[A-Z]\\/", QRegularExpression::CaseInsensitiveOption)); + replacedLink = + QString( "<%1 %2 src=\"bres://%3/%4\"" ).arg( list[ 1 ], list[ 2 ], QString::fromStdString( getId() ), url ); + } + + newText += replacedLink; + } + if( pos ) + { + newText += text.mid( pos ); + text = newText; + } + newText.clear(); + // Fix links without '"' text.replace( QRegularExpression( "href=(\\.\\.|)/([^\\s>]+)" ), @@ -860,9 +896,8 @@ string ZimDictionary::convert( const string & in ) // these links will be translated into local definitions // QRegularExpression rxLink( "<\\s*(?:a|meta)\\s+([^>]*)(?:href|url)=\"?(?!(?:\\w+://|#|mailto:|tel:))()([^\"]*)\"\\s*(title=\"[^\"]*\")?[^>]*>" ); - QRegularExpressionMatchIterator it = rxLink.globalMatch( text ); - int pos = 0; - QString newText; + it = rxLink.globalMatch( text ); + pos = 0; while( it.hasNext() ) { QRegularExpressionMatch match = it.next(); @@ -1485,7 +1520,7 @@ void ZimResourceRequest::run() sptr< Dictionary::DataRequest > ZimDictionary::getResource( string const & name ) { - auto formatedName = QString::fromStdString(name).replace(RX::Zim::linkSpecialChar,""); + auto formatedName = QString::fromStdString(name).remove(QRegularExpression("^\\.*\\/[A-Z]\\/", QRegularExpression::CaseInsensitiveOption)); return new ZimResourceRequest( *this, formatedName.toStdString() ); } @@ -1658,8 +1693,10 @@ vector< sptr< Dictionary::Class > > makeDictionaries( } else { - auto formatedUrl = QString::fromStdString(url).replace(RX::Zim::linkSpecialChar,""); - indexedResources.addSingleWord( Utf8::decode( formatedUrl.toStdString() ), n ); +// url.insert( url.begin(), '/' ); +// url.insert( url.begin(), nameSpace ); +// auto formatedUrl = QString::fromStdString(url).replace(RX::Zim::linkSpecialChar," "); + indexedResources.addSingleWord( Utf8::decode( url ), n ); } } else @@ -1689,16 +1726,14 @@ vector< sptr< Dictionary::Class > > makeDictionaries( } } else - if( nameSpace == 'X' ) + if( nameSpace == 'X' || nameSpace=='V' || nameSpace=='U'|| nameSpace=='W' ) { continue; } else { -// url.insert( url.begin(), '/' ); -// url.insert( url.begin(), nameSpace ); - auto formatedUrl = QString::fromStdString(url).replace(RX::Zim::linkSpecialChar,""); - indexedResources.addSingleWord( Utf8::decode( formatedUrl.toStdString() ), n ); +// auto formatedUrl = QString::fromStdString(url).replace(RX::Zim::linkSpecialChar," "); + indexedResources.addSingleWord( Utf8::decode( url ), n ); } }