Fix PQF to Solr conversion may produce invalid Solr query YAZ-792
authorAdam Dickmeiss <adam@indexdata.dk>
Tue, 7 Oct 2014 17:38:42 +0000 (19:38 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Tue, 7 Oct 2014 17:38:42 +0000 (19:38 +0200)
Just deal with the empty PQF term and quote that as well.

src/rpn2solr.c

index f790ea2..1a39204 100644 (file)
@@ -228,9 +228,14 @@ static int emit_term(solr_transform_t ct, WRBUF w, Z_Term *term, Odr_int trunc)
         size_t i;
         int must_quote = 0;
 
         size_t i;
         int must_quote = 0;
 
-        for (i = 0 ; i < lterm; i++)
-            if (sterm[i] == ' ')
-                must_quote = 1;
+        if (lterm == 0)
+            must_quote = 1;
+        else
+        {
+            for (i = 0 ; i < lterm; i++)
+                if (sterm[i] == ' ')
+                    must_quote = 1;
+        }
         if (must_quote)
             wrbuf_puts(w, "\"");
         if (trunc == 2 || trunc == 3)
         if (must_quote)
             wrbuf_puts(w, "\"");
         if (trunc == 2 || trunc == 3)