From: Timo Sirainen Date: Mon, 23 Mar 2009 20:33:11 +0000 (-0400) Subject: fts-solr: Solr breaks when it sees control characters, so replace them with spaces. X-Git-Tag: 1.2.beta4~16 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=62e2644111a1a53b6a8cf2b39f4d7fd0330ebdd6;p=thirdparty%2Fdovecot%2Fcore.git fts-solr: Solr breaks when it sees control characters, so replace them with spaces. --HG-- branch : HEAD --- diff --git a/src/plugins/fts-solr/fts-backend-solr.c b/src/plugins/fts-solr/fts-backend-solr.c index 28481049c1..3bdedbbcfb 100644 --- a/src/plugins/fts-solr/fts-backend-solr.c +++ b/src/plugins/fts-solr/fts-backend-solr.c @@ -64,9 +64,21 @@ xml_encode_data(string_t *dest, const unsigned char *data, unsigned int len) case '>': str_append(dest, ">"); break; - default: + case '\t': + case '\n': + case '\r': + /* exceptions to the following control char check */ str_append_c(dest, data[i]); break; + default: + if (data[i] < 32) { + /* SOLR doesn't like control characters. + replace them with spaces. */ + str_append_c(dest, ' '); + } else { + str_append_c(dest, data[i]); + } + break; } } }