X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Frpn2solr.c;h=70b2f6c642a4054a9b52d10b58070d01a032122b;hp=89b8b9163478eb5c864661b6ea84cc9e28d27a77;hb=12ab7a040623d875c3e324e6a1df20652087b551;hpb=a6755038fe15be8e6aca7e062a0577407bb640a2 diff --git a/src/rpn2solr.c b/src/rpn2solr.c index 89b8b91..70b2f6c 100644 --- a/src/rpn2solr.c +++ b/src/rpn2solr.c @@ -245,6 +245,7 @@ static int rpn2solr_simple(solr_transform_t ct, { size_t i; int must_quote = 0; + for (i = 0 ; i < lterm; i++) if (sterm[i] == ' ') must_quote = 1; @@ -253,7 +254,13 @@ static int rpn2solr_simple(solr_transform_t ct, /* Bug 2878: Check and add Truncation */ if (checkForLeftTruncation(apt->attributes)) wrbuf_puts(w, "*"); - wrbuf_write(w, sterm, lterm); + for (i = 0 ; i < lterm; i++) { + /* BUG 4415: Escape special characters in string terms */ + if (strchr("+-&|!(){}[]^\"~*?:\\", sterm[i])) { + wrbuf_putc(w, '\\'); + } + wrbuf_putc(w, sterm[i]); + } /* Bug 2878: Check and add Truncation */ if (checkForRightTruncation(apt->attributes)) wrbuf_puts(w, "*");