+! Correctly handle bword:// links when they contain non-ascii

letters and dots by independently decoding IDN for each part.
This commit is contained in:
Konstantin Isakov 2009-08-31 14:27:19 +00:00
parent 8f23e83ac0
commit d35e4a5877

View file

@ -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
{