From d35e4a5877f061d21de6e1fd41e9f99acd0d948c Mon Sep 17 00:00:00 2001 From: Konstantin Isakov Date: Mon, 31 Aug 2009 14:27:19 +0000 Subject: [PATCH] +! Correctly handle bword:// links when they contain non-ascii letters and dots by independently decoding IDN for each part. --- src/articleview.cc | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/articleview.cc b/src/articleview.cc index 522afee6..9bec108b 100644 --- a/src/articleview.cc +++ b/src/articleview.cc @@ -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 {