commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r191157 - in /jakarta/commons/proper/configuration/trunk: conf/test.properties src/java/org/apache/commons/configuration/PropertiesConfiguration.java src/test/org/apache/commons/configuration/TestPropertiesConfiguration.java xdocs/changes.xml
Date Fri, 17 Jun 2005 13:40:54 GMT
Author: oheger
Date: Fri Jun 17 06:40:50 2005
New Revision: 191157

URL: http://svn.apache.org/viewcvs?rev=191157&view=rev
Log:
Fix for issue 35119: Corrected handling of trailing backslashes in PropertiesConfiguration

Modified:
    jakarta/commons/proper/configuration/trunk/conf/test.properties
    jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/PropertiesConfiguration.java
    jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestPropertiesConfiguration.java
    jakarta/commons/proper/configuration/trunk/xdocs/changes.xml

Modified: jakarta/commons/proper/configuration/trunk/conf/test.properties
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/conf/test.properties?rev=191157&r1=191156&r2=191157&view=diff
==============================================================================
--- jakarta/commons/proper/configuration/trunk/conf/test.properties (original)
+++ jakarta/commons/proper/configuration/trunk/conf/test.properties Fri Jun 17 06:40:50 2005
@@ -65,3 +65,12 @@
 test.short.array = 3
 
 test.overwrite = 1
+
+#
+# Test complex line ending escaping
+#
+
+test.path = C:\\path1\\
+test.path = C:\\path2\\
+test.path = C:\\path3\\\
+complex\\test\\

Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/PropertiesConfiguration.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/PropertiesConfiguration.java?rev=191157&r1=191156&r2=191157&view=diff
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/PropertiesConfiguration.java
(original)
+++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/PropertiesConfiguration.java
Fri Jun 17 06:40:50 2005
@@ -443,7 +443,7 @@
                     continue;
                 }
 
-                if (line.endsWith("\\"))
+                if (checkCombineLines(line))
                 {
                     line = line.substring(0, line.length() - 1);
                     buffer.append(line);
@@ -455,6 +455,21 @@
                 }
             }
             return buffer.toString();
+        }
+        
+        /**
+         * Checks if the passed in line should be combined with the following.
+         * This is true, if the line ends with an odd number of backslashes.
+         * 
+         * @param line the line
+         * @return a flag if the lines should be combined
+         */
+        private static boolean checkCombineLines(String line)
+        {
+            int bsCount = 0;
+            for (int idx = line.length()-1; idx >= 0 && line.charAt(idx) == '\\';
idx--, bsCount++)
+                ;
+            return bsCount % 2 == 1;
         }
     } // class PropertiesReader
 

Modified: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestPropertiesConfiguration.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestPropertiesConfiguration.java?rev=191157&r1=191156&r2=191157&view=diff
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestPropertiesConfiguration.java
(original)
+++ jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestPropertiesConfiguration.java
Fri Jun 17 06:40:50 2005
@@ -336,4 +336,15 @@
         PropertiesConfiguration.setDelimiter(delimiter);
     }
 
+    /**
+     * Tests escaping of an end of line with a backslash.
+     */
+    public void testNewLineEscaping()
+    {
+        List list = conf.getList("test.path");
+        assertEquals(3, list.size());
+        assertEquals("C:\\path1\\", list.get(0));
+        assertEquals("C:\\path2\\", list.get(1));
+        assertEquals("C:\\path3\\complex\\test\\", list.get(2));
+    }
 }

Modified: jakarta/commons/proper/configuration/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/xdocs/changes.xml?rev=191157&r1=191156&r2=191157&view=diff
==============================================================================
--- jakarta/commons/proper/configuration/trunk/xdocs/changes.xml (original)
+++ jakarta/commons/proper/configuration/trunk/xdocs/changes.xml Fri Jun 17 06:40:50 2005
@@ -23,6 +23,11 @@
   <body>
 
     <release version="1.2-dev" date="in SVN">
+      <action dev="oheger" type="update" issue="35119">
+        PropertiesConfiguration's handling of backslash characters at the end
+        of line was incorrect when there was an even number of trailing
+        backslashes. This is now fixed.
+      </action>
       <action dev="oheger" type="update" issue="35210">
         Fixed a problem related to file based configurations that are loaded
         from a URL which is application/x-www-form-urlencoded: the save() method



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message