Bug 12688 - [spotlight] FILTER in generated query doesn't handle nested directories with spaces
[spotlight] FILTER in generated query doesn't handle nested directories with ...
Status: ASSIGNED
Product: Samba 4.1 and newer
Classification: Unclassified
Component: Other
4.6.0
All All
: P5 normal
: ---
Assigned To: Ralph Böhme
Samba QA Contact
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2017-03-14 17:53 UTC by mmpestorich
Modified: 2017-07-08 18:35 UTC (History)
1 user (show)

See Also:


Attachments
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:

https://lists.samba.org/archive/samba-technical/2016-August/115712.html

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
*ping*