Santiago Gala wrote:
> We have a problem in Jetspeed when saving ExtendedProperties. One of the
(...)
I hate replying myself, but I noticed that the patch was wrong (a missing line).
It was functionally equivalent to the previous version. Here it goes the correct
patch, only tested now. It works.
Index: src/java/org/apache/turbine/util/ExtendedProperties.java
===================================================================
RCS file:
/products/cvs/turbine/turbine/src/java/org/apache/turbine/util/ExtendedProperties.java,v
retrieving revision 1.1
diff -u -r1.1 ExtendedProperties.java
--- src/java/org/apache/turbine/util/ExtendedProperties.java
2001/01/05 00:04:29 1.1
+++ src/java/org/apache/turbine/util/ExtendedProperties.java
2001/02/16 00:46:19
@@ -136,6 +136,7 @@
* @see org.apache.turbine.util.Configurations
* @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Jon S. Stevens</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Santiago Gala</a>
* @version $Id: ExtendedProperties.java,v 1.1 2001/01/05 00:04:29 dlr
Exp $
*/
public class ExtendedProperties
@@ -442,7 +443,7 @@
StringBuffer currentOutput = new StringBuffer();
currentOutput.append(key);
currentOutput.append("=");
- currentOutput.append((String) value);
+ writeEscaped(currentOutput, (String) value);
theWrtr.println(currentOutput.toString());
}
else if(value instanceof Vector)
@@ -456,7 +457,7 @@
StringBuffer currentOutput = new
StringBuffer();
currentOutput.append(key);
currentOutput.append("=");
- currentOutput.append(currentElement);
+ writeEscaped(currentOutput, currentElement);
theWrtr.println(currentOutput.toString());
}
}
@@ -465,5 +466,23 @@
theWrtr.flush();
}
}
+ }
+
+ /**
+ * Escape values when saving.
+ * Appends a String to a StringBuffer, escaping commas.
+ * @param sink a StringBuffer to write output
+ * @param element a value to be written
+ */
+ protected void writeEscaped( StringBuffer sink, String element ) {
+ int upTo = element.indexOf(",");
+ if( upTo == -1 ) {
+ sink.append( element );
+ return;
+ }
+ sink.append( element.substring( upTo ) );
+ sink.append( "\\," );
+ writeEscaped( sink, element.substring( upTo+1, element.length()
) );
+ return;
}
}
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?: [EMAIL PROTECTED]