|
|
44721b |
From 7018cdcaa9954271cd82ba1c2620ecdfea176fae Mon Sep 17 00:00:00 2001
|
|
|
44721b |
From: Cristiano Nunes <cfgnunes@gmail.com>
|
|
|
44721b |
Date: Tue, 7 Apr 2020 14:47:41 +0000
|
|
|
44721b |
Subject: [PATCH] search-engine-tracker: Fix broken query under some locales
|
|
|
44721b |
|
|
|
44721b |
We set a 5.0 rank for filename matches in the SPARQL query as a float
|
|
|
44721b |
argument in a format string.
|
|
|
44721b |
|
|
|
44721b |
However, the floats in format strings are translated with the decimal
|
|
|
44721b |
separator from the locale. This means in some locales the rank has a
|
|
|
44721b |
comma instead of a dot, which results in a query error. In turn, this
|
|
|
44721b |
effectively broke the shell search provider.
|
|
|
44721b |
|
|
|
44721b |
Instead of using a format specifier and passing the value as an
|
|
|
44721b |
argument, we should just use compile-time concatenation to insert '5.0'
|
|
|
44721b |
in the query unmodified.
|
|
|
44721b |
|
|
|
44721b |
Fixes https://gitlab.gnome.org/GNOME/nautilus/-/issues/1412 and #1437
|
|
|
44721b |
|
|
|
44721b |
Cherry-picked from 7f00ede9b410e88106cef34c634cb46e46015e37
|
|
|
44721b |
---
|
|
|
44721b |
src/nautilus-search-engine-tracker.c | 7 +++----
|
|
|
44721b |
1 file changed, 3 insertions(+), 4 deletions(-)
|
|
|
44721b |
|
|
|
44721b |
diff --git a/src/nautilus-search-engine-tracker.c b/src/nautilus-search-engine-tracker.c
|
|
|
44721b |
index 32b6039a9..571467a25 100644
|
|
|
44721b |
--- a/src/nautilus-search-engine-tracker.c
|
|
|
44721b |
+++ b/src/nautilus-search-engine-tracker.c
|
|
|
44721b |
@@ -287,7 +287,7 @@ search_finished_idle (gpointer user_data)
|
|
|
44721b |
}
|
|
|
44721b |
|
|
|
44721b |
/* This is used to compensate rank if fts:rank is not set (resp. fts:match is
|
|
|
44721b |
- * not used). The value was determined experimentally. I am conviced that
|
|
|
44721b |
+ * not used). The value was determined experimentally. I am convinced that
|
|
|
44721b |
* fts:rank is currently always set to 5.0 in case of filename match.
|
|
|
44721b |
*/
|
|
|
44721b |
#define FILENAME_RANK 5.0
|
|
|
44721b |
@@ -372,10 +372,9 @@ nautilus_search_engine_tracker_start (NautilusSearchProvider *provider)
|
|
|
44721b |
" {"
|
|
|
44721b |
" ?urn nfo:fileName ?filename ."
|
|
|
44721b |
" FILTER(fn:contains(fn:lower-case(?filename), '%s')) ."
|
|
|
44721b |
- " BIND(%f AS ?rank2) ."
|
|
|
44721b |
+ " BIND(" FILENAME_RANK " AS ?rank2) ."
|
|
|
44721b |
" }",
|
|
|
44721b |
- search_text,
|
|
|
44721b |
- FILENAME_RANK);
|
|
|
44721b |
+ search_text);
|
|
|
44721b |
|
|
|
44721b |
g_string_append_printf (sparql, " . FILTER( ");
|
|
|
44721b |
|
|
|
44721b |
--
|
|
|
44721b |
2.26.2
|
|
|
44721b |
|