Skip to content

Commit

Permalink
Fix path escaping in Spotlight so paths with spaces or special charac…
Browse files Browse the repository at this point in the history
…ters

can be properly matched to tracker paths.
  • Loading branch information
dbuckley committed Oct 29, 2015
1 parent f89d85e commit 4473897
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions etc/afpd/spotlight.c
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,9 @@ static int sl_rpc_openQuery(AFPObj *obj,
sl_query = dalloc_value_for_key(query, "DALLOC_CTX", 0,
"DALLOC_CTX", 1,
"kMDQueryString");

LOG(log_debug, logtype_sl, "Spotlight query pre-conversion: \"%s\"", sl_query);

if (sl_query == NULL) {
EC_FAIL;
}
Expand Down Expand Up @@ -890,14 +893,23 @@ static int sl_rpc_openQuery(AFPObj *obj,

scope_array = dalloc_value_for_key(query, "DALLOC_CTX", 0, "DALLOC_CTX", 1,
"kMDScopeArray");
char *scope;

if (scope_array == NULL) {
slq->slq_scope = talloc_strdup(slq, v->v_path);
scope = g_uri_escape_string(v->v_path,
G_URI_RESERVED_CHARS_ALLOWED_IN_PATH, TRUE);
} else {
slq->slq_scope = talloc_strdup(slq, scope_array->dd_talloc_array[0]);
scope = g_uri_escape_string(scope_array->dd_talloc_array[0],
G_URI_RESERVED_CHARS_ALLOWED_IN_PATH, TRUE);
}
if (slq->slq_scope == NULL) {


if (scope == NULL) {
LOG(log_error, logtype_sl, "failed to setup search scope");
EC_FAIL;
} else {
LOG(log_debug, logtype_sl, "Search scope - escaped: \"%s\"", scope);
slq->slq_scope = talloc_strdup(slq, scope);
}

LOG(log_debug, logtype_sl, "Search scope: \"%s\"", slq->slq_scope);
Expand Down

0 comments on commit 4473897

Please sign in to comment.