Bug 12688 - [spotlight] FILTER in generated query doesn't handle nested directories with spaces
Summary: [spotlight] FILTER in generated query doesn't handle nested directories with ...
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: Other (show other bugs)
Version: 4.6.0
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Ralph Böhme
QA Contact: Samba QA Contact
Depends on:
Reported: 2017-03-14 17:53 UTC by mmpestorich
Modified: 2018-10-07 19:45 UTC (History)
2 users (show)

See Also:

Patch for URL Escaping Path Qualifier (1.64 KB, patch)
2017-03-14 17:53 UTC, mmpestorich
no flags Details
Patch for master (1.73 KB, patch)
2017-03-15 12:42 UTC, Ralph Böhme
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description mmpestorich 2017-03-14 17:53:10 UTC
Created attachment 13058 [details]
Patch for URL Escaping Path Qualifier

I originally submitted this patch to the samba-technical mailing list but received no response so I am submitting it along with this bug report.

Previous discussion can be found at:


Basically, when running a search from within a nested directory and that directory’s path contains spaces, the generated sparql query will always return and empty result set. The problem is that the patch needs to be escaped and it is not.

For example, when searching for a file that starts with "Deposit" in given the path "/srv/smb/Groups/My Folder/Deposits/2011/" the query currently generated is:

19 Aug 2016, 02:24:15: Tracker: ---- [21|smbd|7822] query: SELECT ?url WHERE { ?obj fts:match 'Deposit*' . ?obj nie:url ?url . FILTER(tracker:uri-is-descendant('file:///srv/smb/Groups/My Folder/Deposits/2011/', ?url)) }
19 Aug 2016, 02:24:15: Tracker: ---> [21|smbd|7822] Success, no error given

...this query will always return an empty result even if there are files located within the search directory that start with the word "Deposit". The correct query should look like:

SELECT ?url WHERE { ?obj fts:match 'Deposit*' . ?obj nie:url ?url . FILTER(tracker:uri-is-descendant('file:///srv/smb/Groups/My%20Folder/Deposits/2011/', ?url)) }

The attached patch modifies “map_spotlight_to_sparql_query” in “samba/source3/rpc_server/mdssvc/sparql_parser.c” to url encode the directory path when generating the “FILTER” statement.
Comment 1 Ralph Böhme 2017-03-15 12:33:18 UTC
Sorry for dropping the ball on this one! I'll pick this up asap.
Comment 2 Ralph Böhme 2017-03-15 12:42:06 UTC
Created attachment 13063 [details]
Patch for master

Here's a slightly modified version based on your patch. Can you test it and report back please?
Comment 3 mmpestorich 2017-03-15 16:45:35 UTC
Thanks! Will do.
Comment 4 Ralph Böhme 2017-07-08 18:35:11 UTC
Comment 5 mmpestorich 2018-01-06 00:50:01 UTC
Very Sorry. I thought I responded a long time ago to this. I went to check the status of this ticket today and realized that I never did. I can confirm that your updated patch fixes this issue. I have ran it against both 4.6.x and 4.7.x without any issues for over six months now.
Comment 6 mmpestorich 2018-10-07 19:45:33 UTC
Looks this your patch was applied at some point... at least as of the 4.9.1 release its there. All still seems well. This issue is resolved.