You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by yo...@apache.org on 2006/12/19 18:08:17 UTC
svn commit: r488728 - in /incubator/solr/trunk: CHANGES.txt
src/java/org/apache/solr/util/StrUtils.java
src/test/org/apache/solr/util/TestUtils.java
Author: yonik
Date: Tue Dec 19 09:08:17 2006
New Revision: 488728
URL: http://svn.apache.org/viewvc?view=rev&rev=488728
Log:
fix escapes in StrUtils.split*: SOLR-87
Added:
incubator/solr/trunk/src/test/org/apache/solr/util/TestUtils.java (with props)
Modified:
incubator/solr/trunk/CHANGES.txt
incubator/solr/trunk/src/java/org/apache/solr/util/StrUtils.java
Modified: incubator/solr/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/solr/trunk/CHANGES.txt?view=diff&rev=488728&r1=488727&r2=488728
==============================================================================
--- incubator/solr/trunk/CHANGES.txt (original)
+++ incubator/solr/trunk/CHANGES.txt Tue Dec 19 09:08:17 2006
@@ -35,14 +35,20 @@
--------------------
New Features
+ 1.
Changes in runtime behavior
+ 1.
Optimizations
+ 1.
Bug Fixes
-
+ 1. SOLR-87: Parsing of synonym files did not correctly handle escaped
+ whitespace such as \r\n\t\b\f. (yonik)
+
Other Changes
+ 1.
================== Release 1.1.0, YYYYMMDD ==================
Modified: incubator/solr/trunk/src/java/org/apache/solr/util/StrUtils.java
URL: http://svn.apache.org/viewvc/incubator/solr/trunk/src/java/org/apache/solr/util/StrUtils.java?view=diff&rev=488728&r1=488727&r2=488728
==============================================================================
--- incubator/solr/trunk/src/java/org/apache/solr/util/StrUtils.java (original)
+++ incubator/solr/trunk/src/java/org/apache/solr/util/StrUtils.java Tue Dec 19 09:08:17 2006
@@ -93,11 +93,11 @@
ch = s.charAt(pos++);
if (decode) {
switch(ch) {
- case 'n' : ch='\n';
- case 't' : ch='\t';
- case 'r' : ch='\r';
- case 'b' : ch='\b';
- case 'f' : ch='\f';
+ case 'n' : ch='\n'; break;
+ case 't' : ch='\t'; break;
+ case 'r' : ch='\r'; break;
+ case 'b' : ch='\b'; break;
+ case 'f' : ch='\f'; break;
}
}
}
@@ -134,11 +134,11 @@
ch = s.charAt(pos++);
if (decode) {
switch(ch) {
- case 'n' : ch='\n';
- case 't' : ch='\t';
- case 'r' : ch='\r';
- case 'b' : ch='\b';
- case 'f' : ch='\f';
+ case 'n' : ch='\n'; break;
+ case 't' : ch='\t'; break;
+ case 'r' : ch='\r'; break;
+ case 'b' : ch='\b'; break;
+ case 'f' : ch='\f'; break;
}
}
}
Added: incubator/solr/trunk/src/test/org/apache/solr/util/TestUtils.java
URL: http://svn.apache.org/viewvc/incubator/solr/trunk/src/test/org/apache/solr/util/TestUtils.java?view=auto&rev=488728
==============================================================================
--- incubator/solr/trunk/src/test/org/apache/solr/util/TestUtils.java (added)
+++ incubator/solr/trunk/src/test/org/apache/solr/util/TestUtils.java Tue Dec 19 09:08:17 2006
@@ -0,0 +1,63 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.util;
+
+import junit.framework.TestCase;
+
+import java.util.List;
+
+/**
+ * @author yonik
+ * @version $Id$
+ */
+public class TestUtils extends TestCase {
+ public static void testSplitEscaping() {
+ List<String> arr = StrUtils.splitSmart("\\r\\n:\\t\\f\\b", ":", true);
+ assertEquals(2,arr.size());
+ assertEquals("\r\n",arr.get(0));
+ assertEquals("\t\f\b",arr.get(1));
+
+ arr = StrUtils.splitSmart("\\r\\n:\\t\\f\\b", ":", false);
+ assertEquals(2,arr.size());
+ assertEquals("\\r\\n",arr.get(0));
+ assertEquals("\\t\\f\\b",arr.get(1));
+
+ arr = StrUtils.splitWS("\\r\\n \\t\\f\\b", true);
+ assertEquals(2,arr.size());
+ assertEquals("\r\n",arr.get(0));
+ assertEquals("\t\f\b",arr.get(1));
+
+ arr = StrUtils.splitWS("\\r\\n \\t\\f\\b", false);
+ assertEquals(2,arr.size());
+ assertEquals("\\r\\n",arr.get(0));
+ assertEquals("\\t\\f\\b",arr.get(1));
+
+ arr = StrUtils.splitSmart("\\:foo\\::\\:bar\\:", ":", true);
+ assertEquals(2,arr.size());
+ assertEquals(":foo:",arr.get(0));
+ assertEquals(":bar:",arr.get(1));
+
+ arr = StrUtils.splitWS("\\ foo\\ \\ bar\\ ", true);
+ assertEquals(2,arr.size());
+ assertEquals(" foo ",arr.get(0));
+ assertEquals(" bar ",arr.get(1));
+ }
+
+
+
+}
Propchange: incubator/solr/trunk/src/test/org/apache/solr/util/TestUtils.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/solr/trunk/src/test/org/apache/solr/util/TestUtils.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: incubator/solr/trunk/src/test/org/apache/solr/util/TestUtils.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL