From a18183064d2e530ad6b3fa4452f385ab193d33a3 Mon Sep 17 00:00:00 2001 From: Abs62 Date: Fri, 29 Mar 2013 23:19:50 +0400 Subject: [PATCH] Fix link handling in Aard dictionaries (issue #243) --- aard.cc | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/aard.cc b/aard.cc index a7bbb5a2..7798585c 100644 --- a/aard.cc +++ b/aard.cc @@ -24,6 +24,7 @@ #include #include #include +#include #include "ufile.hh" #include "wstring_qt.hh" @@ -500,7 +501,26 @@ void AardDictionary::loadArticle( uint32_t address, string link; readJSONValue( text, link, n ); if( !link.empty() ) - articleText = "" + link + ""; + { + string encodedLink; + encodedLink.reserve( link.size() ); + bool prev = false; + for( string::const_iterator i = link.begin(); i != link.end(); ++i ) + { + if( *i == '\\' ) + { + if( !prev ) + { + prev = true; + continue; + } + } + encodedLink.push_back( *i ); + prev = false; + } + encodedLink = string( QUrl::toPercentEncoding( QString::fromUtf8( encodedLink.c_str() ) ).data() ); + articleText = "" + link + ""; + } } }