]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
fts-solr: Solr breaks when it sees control characters, so replace them with spaces.
authorTimo Sirainen <tss@iki.fi>
Mon, 23 Mar 2009 20:33:11 +0000 (16:33 -0400)
committerTimo Sirainen <tss@iki.fi>
Mon, 23 Mar 2009 20:33:11 +0000 (16:33 -0400)
--HG--
branch : HEAD

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

index 28481049c1704b87acf25abbe9948aabc6dd8039..3bdedbbcfba30e335283aa99ca887dde2cf41443 100644 (file)
@@ -64,9 +64,21 @@ xml_encode_data(string_t *dest, const unsigned char *data, unsigned int len)
                case '>':
                        str_append(dest, "&gt;");
                        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;
                }
        }
 }