GNOME Bugzilla – Bug 730399
Search strings should be escaped
Last modified: 2014-07-27 11:59:41 UTC
I have some video files on my laptop whose filenames begin "Bob's Burgers - ". Searching for "Bob's Burgers" pops up a message box which says: Search Error Failed to query: 1.488: syntax error, expected `}' And causes this output on a terminal: (totem:18488): Grilo-WARNING **: [tracker-source-request] grl-tracker-source-api.c:436: Could not execute sparql query id=196: 1.488: syntax error, expected `}' The search term being passed to grilo/tracker appears to be unescaped, so the ' is causing problems. "Bob\'s Burgers" will find the correct files. "*" works as a wildcard. While this could be useful for some, I'd imagine it'd be more useful to most people to escape the search terms. OS: Arch Linux totem 3.12.1-1 grilo 0.2.10-1 grilo-plugins 0.2.12-2 tracker 1.0.1-1 libtracker-sparql 1.0.1-1
This is a bug in grilo. We shouldn't have to escape anything.
Created attachment 281630 [details] [review] tracker: escape search strings
Review of attachment 281630 [details] [review]: ::: src/tracker/grl-tracker-source-api.c @@ +78,3 @@ "%s " \ "?urn tracker:available ?tr . " \ + "?urn fts:match \"%s\" . " \ What happens if the search string contains "?
yeah, it fails. Actually, I tried to run a sparql sentence with a " in the fts:match function, and it was rejected all time. Moreover, I'm starting to think that fts:match is not what we should use, and rather explictly search in the fields we want (like filename, title, album and artist).
Created attachment 281777 [details] [review] tracker: escape search strings Use Tracker functions to perform the escape, because it is designed to hand-craft later a SPARQL query with the escaped string.
I've upload a new version that uses Tracker escape function. In this case, the " is correctly handled, as this function is designed for later use the escaped string inside a hand-crafted SPARQL query. Actually, this is exactly what the tracker-search tool uses.
For now I would just fix the search algorithm we are using atm. I'll work on a different issue to improve the search to cover other fields relevant.
Review of attachment 281777 [details] [review]: Looks good.
Attachment 281777 [details] pushed as 3155abd - tracker: escape search strings