upstream nepomuk_unicode patch

This commit is contained in:
Rex Dieter 2011-10-09 09:50:55 -05:00
parent 3e5dba2ecf
commit 04b87d0cde
2 changed files with 72 additions and 1 deletions

View File

@ -0,0 +1,65 @@
diff --git a/nepomuk/query/querybuilderdata_p.h b/nepomuk/query/querybuilderdata_p.h
index 055482e..3880e13 100644
--- a/nepomuk/query/querybuilderdata_p.h
+++ b/nepomuk/query/querybuilderdata_p.h
@@ -32,6 +32,28 @@
#include "query_p.h"
#include "groupterm_p.h"
+namespace {
+/// A hack to avoid passing extended chars to the bif:search_excerpts method which cannot handle
+/// utf8 chars which use more than one char, ie. wide chars.
+/// Thus, we simply truncate each term at the first wide char.
+QStringList stripExtendedCharsHack(const QStringList& terms) {
+ QStringList newTerms;
+ foreach(const QString& term, terms) {
+ int i = 0;
+ while(i < term.length()) {
+ if(term[i].unicode() > 0x7f) {
+ break;
+ }
+ ++i;
+ }
+ if(i > 0) {
+ newTerms.append(term.left(i));
+ }
+ }
+ return newTerms;
+}
+}
+
namespace Nepomuk {
namespace Query {
class QueryBuilderData
@@ -246,16 +268,23 @@ namespace Nepomuk {
for( QHash<QString, QStringList>::const_iterator it = m_fullTextSearchTerms.constBegin();
it != m_fullTextSearchTerms.constEnd(); ++it ) {
const QString& varName = it.key();
- const QStringList& terms = it.value();
- // bif:search_excerpt wants a vector of all search terms
- excerptParts
- << QString::fromLatin1("bif:search_excerpt(bif:vector(bif:charset_recode('%1', '_WIDE_', 'UTF-8')), %2)")
- .arg( terms.join(QLatin1String("','")),
- varName );
+ const QStringList terms = stripExtendedCharsHack(it.value());
+ if(terms.count()) {
+ // bif:search_excerpt wants a vector of all search terms
+ excerptParts
+ << QString::fromLatin1("bif:search_excerpt(bif:vector('%1'), %2)")
+ .arg( terms.join(QLatin1String("','")),
+ varName );
+ }
}
- return QString::fromLatin1("(bif:concat(%1)) as ?_n_f_t_m_ex_")
- .arg(excerptParts.join(QLatin1String(",")));
+ if(excerptParts.count()) {
+ return QString::fromLatin1("(bif:concat(%1)) as ?_n_f_t_m_ex_")
+ .arg(excerptParts.join(QLatin1String(",")));
+ }
+ else {
+ return QString();
+ }
}
else {
return QString();

View File

@ -20,7 +20,7 @@
Summary: KDE Libraries
Version: 4.7.2
Release: 1%{?dist}
Release: 2%{?dist}
Name: kdelibs
Epoch: 6
@ -122,6 +122,8 @@ Patch50: kdelibs-4.7.0-knewstuff2_gpg2.patch
Patch51: kdelibs-4.6.2-uri_mimetypes.patch
## upstream
# fix nepomuk queries *not* using wide-unicode
Patch100: kdelibs-4.7.2-nepomuk_unicode.patch
## security fix
# Not Upstreamed? why not ? -- Rex
@ -313,6 +315,7 @@ sed -i -e "s|@@VERSION_RELEASE@@|%{version}-%{release}|" kio/kio/kprotocolmanage
%patch51 -p1 -b .uri_mimetypes
# upstream patches
%patch100 -p1 -b .nepomuk_unicode
# security fixes
%patch200 -p1 -b .CVE-2009-2702
@ -562,6 +565,9 @@ rm -rf %{buildroot}
%changelog
* Sun Oct 09 2011 Rex Dieter <rdieter@fedoraproject.org> 4.7.2-2
- upstream nepomuk_unicode patch
* Tue Oct 04 2011 Rex Dieter <rdieter@fedoraproject.org> 4.7.2-1
- 4.7.2