Bug 79 : propertyEvaluator eats characters beween tokens
Priority 
High
Reported Version 
 
Logged By 
imario
Status 
Fixed
Fixed Version 
1.1.0
Assigned To 
 
Product 
Ebean - core
Duplicate Of 
 
Created 
24/02/2009
Updated 
24/02/2009
Type 
Bug
 
Attachments 
No attachments

the propertyEvaluator eats everything between e.g. anyText${token1}FOO${token2} - FOO gets lost

This patch fixes it:

Index: ../ebean/src/com/avaje/ebean/server/lib/PropertyEvaluator.java
===================================================================
--- ../ebean/src/com/avaje/ebean/server/lib/PropertyEvaluator.java (revision 141)
+++ ../ebean/src/com/avaje/ebean/server/lib/PropertyEvaluator.java Tue Feb 24 12:28:30 CET 2009
@@ -158,6 +157,8 @@
if (sp > -1) {
int ep = val.indexOf(END, sp + 1);
if (ep > -1) {
+ // append what is between the last token and the new one (if startPos == sp nothing gets added)
+ sb.append(val.substring(startPos, sp));
String cal = evalExpression(val, sp, ep);
sb.append(cal);
eval(val, ep + 1, sb);

 
Rob 25 Feb 09:54
Fixed in HEAD

Confirmed and fixed in HEAD.

imario 25 Feb 17:58
Hmmm .... just a very minor issue :-)

you added it right after
if (sp > -1) {
while I had it after
if (ep > -1) {

so, only if the token will be replaced, the content between two tokens gets readded.
In any other case, no starting ${ found or no ending } found it falls through to "append whats left" which was already there.

If, for some reason one has an errorneous config like
param=my${strange}and${wrong config
the word "and" will be added twice, once by the new "in between text append" and once by the already existing append at the end of the method.

But as I wrote in the summary. A VERY minor issue ;-)

woResponse

Upload a file