]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
fts-solr: Fixed sending empty parameters.
authorTimo Sirainen <tss@iki.fi>
Fri, 27 Nov 2015 13:49:58 +0000 (15:49 +0200)
committerTimo Sirainen <tss@iki.fi>
Fri, 27 Nov 2015 13:49:58 +0000 (15:49 +0200)
Solr probably doesn't do anything useful with them, but we shouldn't get 400
Bad Request errors.

src/plugins/fts-solr/fts-backend-solr-old.c
src/plugins/fts-solr/fts-backend-solr.c

index 68f957c4ab008eb26275fde9d2292a3bc9435090..c77c18e67aef0d3d574ed6765e615d9a40a5dc0c 100644 (file)
@@ -146,6 +146,9 @@ static const char *solr_escape(const char *str)
        string_t *ret;
        unsigned int i;
 
+       if (str[0] == '\0')
+               return "\"\"";
+
        ret = t_str_new(strlen(str) + 16);
        for (i = 0; str[i] != '\0'; i++) {
                if (strchr(solr_escape_chars, str[i]) != NULL)
index 9b53f4e3f64dc26423a40d9da1800a6937488136..83deb3fdc84fd0f6d5bd92104c562e9e56f005ce 100644 (file)
@@ -161,7 +161,10 @@ static const char *solr_escape(const char *str)
 
 static void solr_quote_http(string_t *dest, const char *str)
 {
-       http_url_escape_param(dest, solr_escape(str));
+       if (str[0] != '\0')
+               http_url_escape_param(dest, solr_escape(str));
+       else
+               str_append(dest, "\"\"");
 }
 
 static struct fts_backend *fts_backend_solr_alloc(void)
@@ -649,7 +652,8 @@ static void solr_add_str_arg(string_t *str, struct mail_search_arg *arg)
        /* currently we'll just disable fuzzy searching if there are any
           parameters that need escaping. solr doesn't seem to give good
           fuzzy results even if we did escape them.. */
-       if (!arg->fuzzy || solr_need_escaping(arg->value.str))
+       if (!arg->fuzzy || arg->value.str[0] == '\0' ||
+           solr_need_escaping(arg->value.str))
                solr_quote_http(str, arg->value.str);
        else {
                http_url_escape_param(str, arg->value.str);