Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escaped placeholders are evaluated if the PropertySource has placeholder support #34326

Open
snicoll opened this issue Jan 27, 2025 · 1 comment
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Milestone

Comments

@snicoll
Copy link
Member

snicoll commented Jan 27, 2025

This is a follow-up of #34315

Consider the following example:

prop1=value1  
prop2=value2\\${prop1}  

prop2 should evaluate to value2${prop1} as the placeholder has been escaped. This works for basic PropertySource implementations but if the source is backed by PropertySourcesPlaceholderConfigurer the escape ${prop1} is still evaluated and should not.

@snicoll snicoll added the type: bug A general bug label Jan 27, 2025
@snicoll snicoll added this to the 6.2.x milestone Jan 27, 2025
@snicoll snicoll self-assigned this Jan 27, 2025
@jhoeller jhoeller added the in: core Issues in core modules (aop, beans, core, context, expression) label Jan 28, 2025
@snicoll
Copy link
Member Author

snicoll commented Feb 3, 2025

So the problem is that PropertySourcesPropertyResolver contains a nested PlaceholderResolver itself. When prop2 is requested, it goes to a first round where it is resolved to value2\\${prop1} which is then parsed as value2${prop1} where the escaped character is removed and ${prop1} is considered as a litteral string.

The problem is that this resolved value come back to the original parser. Rather than seeing value2\\${prop1} it gets value2${prop1} and it resolves the nested placeholder since it has lost its escape character.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants