mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-24 08:34:08 +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() );
|
printf( "clicked %s\n", url.toString().toLocal8Bit().data() );
|
||||||
|
|
||||||
if ( url.scheme() == "bword" )
|
if ( url.scheme() == "bword" )
|
||||||
showDefinition( ( url.host().startsWith( "xn--" ) ?
|
{
|
||||||
QUrl::fromPunycode( url.host().toLatin1() ) :
|
QString host = url.host();
|
||||||
url.host() ) + url.path(),
|
|
||||||
|
// 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 );
|
getGroup( ref ), scrollTo, contexts );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
if ( url.scheme() == "gdlookup" ) // Plain html links inherit gdlookup scheme
|
if ( url.scheme() == "gdlookup" ) // Plain html links inherit gdlookup scheme
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue