Skip to content

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

Not planned
@snicoll

Description

@snicoll

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 escaped ${prop1} is still evaluated even though it should not be.

Activity

added this to the 6.2.x milestone on Jan 27, 2025
self-assigned this
on Jan 27, 2025
added
in: coreIssues in core modules (aop, beans, core, context, expression)
on Jan 28, 2025
snicoll

snicoll commented on Feb 3, 2025

@snicoll
MemberAuthor

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.

removed their assignment
on Feb 14, 2025
modified the milestones: 6.2.x, 6.2.6 on Mar 21, 2025
self-assigned this
on Mar 21, 2025
modified the milestones: 6.2.6, 6.2.x on Apr 16, 2025

11 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: supersededAn issue that has been superseded by anothertype: bugA general bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Participants

    @sbrannen@sdeleuze@snicoll@jhoeller

    Issue actions

      Escaped placeholders are evaluated if the PropertySource has placeholder support · Issue #34326 · spring-projects/spring-framework