see gh-3071
Limitation
MessageSourceInterpolatorDelegate
does not support \
escape character. The escape character is not supported because there is no way to configurePropertyPlaceholderHelper
with it.
Is it possible to add escape support in Spring Framework
?
Thanks
Comment From: philwebb
I've raise https://github.com/spring-projects/spring-framework/issues/23348 to look at extending PropertyPlaceholderHelper
Comment From: nosan
Thanks, @philwebb !
Comment From: nosan
Hi @philwebb,
I did some research related to this issue, and my idea to use PropertyPlaceholderHelper
was doomed initially.
I thought if PropertyPlaceholderHelper
had escape support it would be possible to
resolve parameters via MessageSource
, but it is not possible because Bean Validation Specification
has quite a specific behavior of interpolating messages and of course, PropertyPlaceholderHelper
would not be able to support such behavior.
I made a comparison between Bean Validation
and Apache StringSubstitutor
, and of course, they have different behavior and most probably PropertyPlaceholderHelper
would have something different.
Message Template | Bean Validation (Hibernate) | Apache StringSubstitutor | Bean Validation (org.apache.bval) |
---|---|---|---|
{message} | must be false | must be false | must be false |
{{message}} | {{message}} | {{message}} | {must be false} |
\\{message} | \must be false | \{message} | \must be false |
\{message} | \{message} | {message} | {message} |
{message\} | {message\} | {message\} | {message} |
\{message\} | {message} | {message\} | {message} |
I think https://github.com/spring-projects/spring-framework/issues/23348 should be closed, as it would not help us here.
UPDATE:
It is recommended that MessageInterpolator implementations delegate final interpolation to the Bean Validation default MessageInterpolator to ensure standard Bean Validation interpolation rules are followed.
It means that MessageSourceInterpolatorDelegate
should not resolve any escape symbols and have to replace only message parameters where it is possible.
Comment From: nosan
PR has been updated and ready for the review. Thanks in advance!
Comment From: wilkinsona
Thanks very much, @nosan, both for the PR and for your patience while we found time to process it.
Comment From: nosan
No problem at all @wilkinsona Thanks a lot.