mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-24 04:24:09 +00:00
+! Correctly handle bword:// links when they contain non-ascii
letters and dots by independently decoding IDN for each part.
This commit is contained in:
parent
8f23e83ac0
commit
d35e4a5877
|
@ -486,10 +486,33 @@ void ArticleView::openLink( QUrl const & url, QUrl const & ref,
|
|||
printf( "clicked %s\n", url.toString().toLocal8Bit().data() );
|
||||
|
||||
if ( url.scheme() == "bword" )
|
||||
showDefinition( ( url.host().startsWith( "xn--" ) ?
|
||||
QUrl::fromPunycode( url.host().toLatin1() ) :
|
||||
url.host() ) + url.path(),
|
||||
{
|
||||
QString host = url.host();
|
||||
|
||||
// If the host has punycode in its domains, decode it
|
||||
|
||||
QStringList domains = host.split( '.' );
|
||||
|
||||
bool hadPunycode = false;
|
||||
|
||||
for( QStringList::iterator i = domains.begin(); i != domains.end(); ++i )
|
||||
{
|
||||
if ( i->startsWith( "xn--" ) )
|
||||
{
|
||||
*i = QUrl::fromPunycode( i->toLatin1() );
|
||||
hadPunycode = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( hadPunycode )
|
||||
{
|
||||
// Join back the result
|
||||
host = domains.join( "." );
|
||||
}
|
||||
|
||||
showDefinition( host + url.path(),
|
||||
getGroup( ref ), scrollTo, contexts );
|
||||
}
|
||||
else
|
||||
if ( url.scheme() == "gdlookup" ) // Plain html links inherit gdlookup scheme
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue