Reputation: 175
We use Freemarker 2.3.20 and came across a strange behavior, when using the default operator together with string escaping like this:
${picture.@author[0]!""?js_string}
in this case, quotes in the authors value are not escaped if !"" is present.
We need to check first for the value and can't use the default op:
<#if picture.@author[0]??>${picture.@author[0]?js_string}</#if>
this is quite ugly and blown up code.
Is this a bug or a feature?
Upvotes: 0
Views: 309
Reputation: 31112
It's because of the operator precedences. ${picture.@author[0]!""?js_string}
means ${picture.@author[0]!(""?js_string)}
. What you want is ${(picture.@author[0]!"")?js_string}
.
Upvotes: 2